This is an old revision of the document!
Standard simulation environments
Simulating CHP programs often requires creating an environment to inject data into the circuit being tested, and an environment that reads the outputs of the circuit to check their values. actsim
comes with a simulation library that has some common functionality that can be used for this purpose.
import sim; defproc buffer(chan?(int) I; chan!(int) O) { int x; chp { *[ I?x; O!(x+2) ] } } defproc test() { buffer b; sim::source_sequence<32 /* 32-bit test */, 4 /* 4 data values */, {1,5,8,53} /* data values */, false /* repeat these data values forever */, 0 /* source ID for log messages */, false /* detailed log messages turned off */ > t1(b.I); sim::sink<32 /* 32-bit data */, 0 /* sink ID for log messages */, true /* detailed log messages turned on */> t2(b.O); }