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?

Shashank V M
2,36918 silver badges56 bronze badges
asked Jun 20, 2020 at 17:21
\$\endgroup\$
1

1 Answer 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.

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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.