Forum Discussion
Altera_Forum
Honored Contributor
7 years ago --- Quote Start --- The second code wont match between simulation and synthesis as you dont have count in the sensitivity list. Also, I recommend using non-blocking assignments in always blocks <= --- Quote End --- The first statement I agree with. Not so the second; it depends on what you are trying to accomplish. If you are trying to model physical registers, than using the non-blocking assignment <= makes sense, as it evaluates the right side, and then assigns the result to the left side based on the event used in the enclosing always block (typically 'posedge clk'). If you want to model pure combinatorial logic and use 'reg' variables as intermediate holding values, with no intercycle memory, then blocking = assignment makes more sense, as it works within the procedural flow. Example:
begin : label
reg tmp;
tmp = a;
if (b == c) tmp = d;
if (e == f) tmp = g;
h = tmp;
end produces the same result as: h = (e == f) ? g : ((b == c) ? d : a); Of course this is a very contrived example but sometimes it is more clear to write out the combinatorial logic as a multi line procedure rather than to combine the whole thing into a single equation.