2 ms·
It's exactly like an out parameter. HDL modules tend to have a lot more outputs, partly because you can't easily group them into structures. The main things th
by pjc50 10y ago
It's exactly like an out parameter. HDL modules tend to have a lot more outputs, partly because you can't easily group them into structures.
The main things that trip people up in Verilog coming from programming are the difference between synthesis and simulation, and the intrinsic parallelism with the two kinds of assignment operator.
There are all kinds of idioms that are syntactically valid Verilog that cannot be compiled to hardware. Usually you only use these while constructing a "testbench" to drive the simulated hardware.
There are also two kinds of assignment: = and <=. So for example, starting with a being set to 1 and b being set to zero:
b = a;
c = b+1;
results in c being set to 2.
always @(posedge clk)
b <= a;
c <= b+1;
end
results in b being set to a and c being set to 1: the value of b on the previous cycle plus 1. It also causes flip-flops to be inferred to hold b and c.
(Note that <= behaves differently depending on what's in the sensitivity list, which is also potentially very confusing!)
If I were still doing HDL design I'd advance my plan for modern object(bus)-orientated friendly HDL..