Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
intro_example:standard_sim [2025/05/14 18:22] – created 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 18: | Line 18: | ||
buffer b; | buffer b; | ||
- | sim:: | + | sim:: |
- | sim:: | + | 4 /* 4 data values */, |
+ | {1, | ||
+ | false /* repeat these data values forever */, | ||
+ | 0 /* source ID for log messages */, | ||
+ | false /* detailed log messages turned off */ > | ||
+ | | ||
+ | sim:: | ||
+ | | ||
+ | | ||
+ | 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] < | ||
+ | </ |