Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
intro_example:standard_sim [2025/05/14 18:24] – rajit | intro_example:standard_sim [2025/05/14 18:40] (current) – rajit | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
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. '' | 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. '' | ||
- | <code act> | + | <file act etest.act> |
import sim; | import sim; | ||
Line 19: | Line 19: | ||
sim:: | sim:: | ||
- | | + | 4 /* 4 data values */, |
- | {1,5,8,53} /* data values */, | + | |
- | false /* repeat these data values forever */, | + | |
- | 0 /* source ID for log messages */, | + | |
- | | + | |
- | | + | t1(b.I); |
sim:: | sim:: | ||
- | | + | |
- | true /* detailed log messages turned on */> | + | true /* detailed log messages turned on */> |
- | t2(b.O); | + | |
} | } | ||
+ | </ | ||
+ | |||
+ | In this example, we use the '' | ||
+ | can be used to generate a sequence of data outputs whose values are provided by an array passed as a template parameter. | ||
+ | |||
+ | Running this produces the following result: | ||
+ | < | ||
+ | $ actsim -p test etest.act | ||
+ | WARNING: source_sequence< | ||
+ | WARNING: buffer<>: | ||
+ | WARNING: sink< | ||
+ | actsim> cycle | ||
+ | [ 50] < | ||
+ | [ 80] < | ||
+ | [ 110] < | ||
+ | [ 140] < | ||
+ | [ 140] < | ||
</ | </ | ||
+ | Instead of using a hard-coded set of values in the the test environment, | ||
+ | <code act> | ||
+ | sim:: | ||
+ | 0 /* file ID */, | ||
+ | false /* don't loop file contents */, | ||
+ | 0 /* source ID */, | ||
+ | false /* turn off verbose logs */> | ||
+ | t1(b.I); | ||
+ | </ | ||
+ | instead of a '' | ||
+ | |||
+ | <file txt _infile_.0> | ||
+ | 0x493 | ||
+ | 0x29 | ||
+ | 0x3 | ||
+ | 4 | ||
+ | </ | ||
+ | |||
+ | The result is: | ||
+ | < | ||
+ | $ actsim -p test etest.act | ||
+ | WARNING: source_file< | ||
+ | WARNING: buffer<>: | ||
+ | WARNING: sink< | ||
+ | actsim> cycle | ||
+ | [ 50] < | ||
+ | [ 70] < | ||
+ | [ 90] < | ||
+ | [ 110] < | ||
+ | [ 110] < | ||
+ | </ |