Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
intro_example:chp_fifo [2022/05/17 13:54] – [A ten-place buffer] rajit | intro_example:chp_fifo [2022/06/26 18:37] (current) – [Simulating the buffer] rajit | ||
---|---|---|---|
Line 141: | Line 141: | ||
Note once again the use of angle brackets to specify template parameters. | Note once again the use of angle brackets to specify template parameters. | ||
+ | ===== Simulating the buffer ===== | ||
+ | |||
+ | Assuming all the process definitions above are in a file '' | ||
+ | |||
+ | <file act test.act> | ||
+ | import " | ||
+ | |||
+ | defproc test_source (chan!(int) X) | ||
+ | { | ||
+ | int i; | ||
+ | chp { | ||
+ | i := 0; | ||
+ | *[ i < 10 -> X!i; i := i + 1 ] | ||
+ | } | ||
+ | } | ||
+ | |||
+ | defproc test_sink (chan?(int) X) | ||
+ | { | ||
+ | int x; | ||
+ | chp { | ||
+ | *[ X?x; log (" | ||
+ | } | ||
+ | } | ||
+ | |||
+ | defproc test() | ||
+ | { | ||
+ | one_place_buffer b; | ||
+ | test_source tsrc; | ||
+ | test_sink tsink; | ||
+ | b.L = tsrc.X; | ||
+ | b.R = tsink.X; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | This can be simulated using '' | ||
+ | |||
+ | < | ||
+ | % actsim test.act test | ||
+ | |||
+ | actsim> cycle | ||
+ | WARNING: test_sink<>: | ||
+ | WARNING: test_source<>: | ||
+ | WARNING: one_place_buffer<>: | ||
+ | actsim> cycle | ||
+ | [ 30] < | ||
+ | [ 50] < | ||
+ | [ 70] < | ||
+ | [ 90] < | ||
+ | [ 110] < | ||
+ | [ 130] < | ||
+ | [ 150] < | ||
+ | [ 170] < | ||
+ | [ 190] < | ||
+ | [ 210] < | ||
+ | actsim> | ||
+ | </ | ||
+ | The first set of numbers is the time (default delays are 10 time units for each step in the CHP program). Next, the instance name is specified in angle brackets. Finally the log message is displayed. |