Electrical – In Verilog , if the always@ block is executed sequentially , how do non-blocking statements work since they are executed parallely

digital-logicverilog

I am getting totally confused because contradictory things are given.

https://class.ece.uw.edu/371/peckol/doc/Always@.pdf

In this pdf, it is said that whether the 'always block' will be executed sequentially or parallelly will depend on the assignment used. If nonblocking->parallely else sequentially.
But many answers like this

Are Verilog if blocks executed sequentially or concurrently?
Says it is always executed sequentially.
So I have two doubts

  1. Is the 'always' block executed sequentially or parallelly?
  2. If sequentially, how do nonblocking statements execute?

Best Answer

Nonblocking assignments simply defer the actual update of the value until all of the statements in the current always block are evaluated. It has the appearance that all of the statements run "concurrently" or "in parallel", but if this was actually the case, it creates an ambiguity: what happens when you assign the same reg two different values in the same always block? If things are truly concurrent, this is a race condition and the new value will be unpredictable. However, the language semantics dictate something else: that the statements must be evaluated sequentially. If you assign the same reg from multiple places in the same always block, the last one takes precedence. Hence, you can consider that the statements are "evaluated" sequentially, but the regs are all updated with new values concurrently.

The synthesizer will convert the HDL code into logic that implements the equivalent functionality. In hardware, things will naturally be evaluated in parallel if there are no data dependencies, but the ordering of the statements would determine the precedence - which value is selected to be loaded into the next register or logic gate.