Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| intro_example:chp_fifo2 [2025/04/21 23:19] – [Dynamic creation of buffer instances] rajit | intro_example:chp_fifo2 [2025/05/01 10:47] (current) – [Alternate Buffer] rajit | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Alternate Buffer ====== | ====== Alternate Buffer ====== | ||
| - | We start with the previous definition | + | We start with the earlier example |
| <code act> | <code act> | ||
| Line 139: | Line 139: | ||
| } | } | ||
| </ | </ | ||
| + | |||
| + | ... which may be easier to read as follows: | ||
| + | |||
| + | <code act> | ||
| + | template< | ||
| + | defproc buffer (chan?(int) L; chan!(int) R) | ||
| + | { | ||
| + | | ||
| + | (i : N : | ||
| + | | ||
| + | [ i = 0 -> b[i].L=L; | ||
| + | [] i = N-1 -> b[i](.L=b[i-1].R, | ||
| + | [] else -> b[i].L=b[i-1].R; | ||
| + | ] | ||
| + | ) | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | This version is similar to the original version we started with. | ||
| + | |||