I am trying to use synchronous reset within an always block for a Moore FSM. Following are 2 blocks of code implementing the same, one uses Non-Blocking assignment and other uses Blocking assignment.
always @(posedge clock, posedge reset) begin
if(reset==1)
current_state <= Zero;
else
current_state <= next_state;
end
vs
always @(posedge clock, posedge reset)
begin
if(reset==1)
current_state = Zero;
else
current_state = next_state;
end
What would be the difference in outputs between these 2 blocks of code?
-
\$\begingroup\$ Have a look here: electronics.stackexchange.com/questions/163018/… \$\endgroup\$P2000– P20002020年06月21日 05:29:05 +00:00Commented Jun 21, 2020 at 5:29
1 Answer 1
From a synthesis perspective, there will be no difference between the two pieces of code.
For simulation, in isolation, both pieces of code will have the same behaviour. However, if you start mixing blocking and non-blocking assignments for synchronous logic, this can sometimes cause weird/inaccurate simulation behaviour due to the way simulators convert the parallel logic into sequential operations.
The same applies to both synchronous and asynchronous reset cases.
-
\$\begingroup\$ Yeah i have edited the post, but synchronous or asynchronous, my question applies to both types. \$\endgroup\$Ashlesha Sunil Agate– Ashlesha Sunil Agate2020年06月20日 17:53:57 +00:00Commented Jun 20, 2020 at 17:53
-
\$\begingroup\$ @AshleshaSunilAgate The first part of my answer applies to both async and sync reset. \$\endgroup\$Tom Carpenter– Tom Carpenter2020年06月20日 18:00:52 +00:00Commented Jun 20, 2020 at 18:00