0
\$\begingroup\$

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?

\$\endgroup\$
1
2
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\begingroup\$ Yeah i have edited the post, but synchronous or asynchronous, my question applies to both types. \$\endgroup\$ Jun 20 '20 at 17:53
  • \$\begingroup\$ @AshleshaSunilAgate The first part of my answer applies to both async and sync reset. \$\endgroup\$ Jun 20 '20 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.