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 (pling to write, query to read):
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 may dissapear during synthesis.
Bluespec Verilog also provides rule-based design expression (see later notes).