Using shared variables to communicate between threads requires that the user abides by self-imposed protocol conventions.
Typical patterns are:
Some protocols cannot be pipelined, some degrade throughput when pipelined and others are designed for it
Some approaches completely ban shared variables and enforce use of channels (Handel-C and the main Bluespec dialect). »(LINK: Handlec.pdf)
Bluespec infers channel-like behaviour from user syntax that looks like conventional reads and writes of shared variables.
Handel-C uses explicit Occam/CSP-like channels ('!' to write, '?' to read):
// Generator (src) // Processor // Consumer (sink) while (1) while(1) while(1) { { { ch1 ! (x); ch2 ! (ch1? + 2) $display(ch2?); x += 3; } } }
Using channels makes concurrency explict and allows synthesis to re-time the design.
In both languages, handshaking wires internal to a module may disappear during synthesis.
21: (C) 2008-13, DJ Greaves, University of Cambridge, Computer Laboratory. |