Hot take: The proper Verilog template for synchronously reset flip-flops looks like this. always @(posedge clk) begin [non-reset code here] if (reset) begin [reset code here] end end
-
-
Replying to @oe1cxw
Yes, and alternately: always @(posedge clock) begin [non-reset code] foo <= (reset == 1'b1) ? [reset value] : foo; bar <= (reset == 1'b1) ? [reset value] : bar; end Why? Compact, and simulates correctly if reset is X or Z. Else reset code fails to apply with an if.
1 reply 0 retweets 4 likes -
Replying to @elaforest
Your foo and bar are stuck at the reset value because non-blocking assignment. (All non-blocking assignment to foo/bar in [non-reset code] will be ignored and blocking assignments are not allowed because you must not mix blocking and non-blocking assignments for the same reg.)
2 replies 0 retweets 2 likes -
Replying to @oe1cxw
Which is to say I agree: the way I wrote it makes it easy to mix blocking and non-blocking statements, which while not forbidden AFAIK, is really asking for trouble.
1 reply 0 retweets 0 likes -
Replying to @elaforest
This is from IEEE Std 1364.1-2002.pic.twitter.com/Q7xYLbgPLt
1 reply 0 retweets 3 likes -
Replying to @oe1cxw
Thanks. Not suprised. I meant that mixing separate blocking/non-blocking statements, not on the same variable, isn't forbidden, but a bad idea anyway. (I need to re-read the LRM apparently...)
1 reply 0 retweets 1 like
Jfyi, IEEE 1364.1 is the synthesis standard. IEEE 1364 is the LRM.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.