Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
intro_example:chp_fifo [2022/05/17 09:54] rajit [A ten-place buffer] |
intro_example:chp_fifo [2022/06/08 06:51] rajit [Simulating the buffer] |
||
---|---|---|---|
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> | ||
+ | </ |