Program Block Vs Module In System Verilog

ECE 232 Verilog tutorial 8 ° Lines that begin with // are comments (ignored by simulation) ° About 100 keywords in total (keywords are case sensitive) ° module: Building block in Verilog ° Always terminates with endmodule ° module followed by circuit name and port list ° Each port is either an input or output //HDL Example 2 //.

In the article, Blocking And Non-blocking in Verilog, we will discuss the topics of Verilog blocking and non-blocking.

Blocking And Non-blocking In Verilog:

The execution of the blocking statements will be in series. This blocking statement will block the next statement until the present statement executes successfully.

  • Simulation: Program Control tasks @0ns count = x @1ns count = 0 5ns inside dosomething task 10ns inside dosomething task 15ns inside dosomething task 20ns inside dosomething task @23ns count = 1 25ns inside dosomething task @25ns count = 2 @27ns count = 3 @29ns count = 4 30ns inside dosomething task @31ns count = 5 35ns inside do.
  • .System Verilog designs and testbenches There are two ways to drive stimulus if the test bench is coded in system verilog. Drive stimulus on inactive clock edge similar to verilog (This method is not highly recommended over clocking block) clocking ram @(posedge clk); 14 input #1 dout; 15 output #1 din,addr,ce,we; 16 endclocking b.

Systemverilog Spec

The execution of the non-blocking statements will be in parallel. This non-blocking statement first it will evaluate all RHS values after that all this will be assigned to the LHS at a time.

The Eda playground example for the Blocking:

module blocking_example;
int asic,verif;
initialbegin
asic =10;
verif =15;
$display('!! @%gns !! BLOCKING :: First Assignment Value of asic is :: %0d',$time,asic);
$display('!! @%gns !! BLOCKING :: First Assignment Value of verif is :: %0d',$time,verif);
asic = verif;
verif =25;
$display('!! @%gns !! BLOCKING :: Second Assignment Value of asic is :: %0d',$time,asic);
$display('!! @%gns !! BLOCKING :: Second Assignment Value of verif is :: %0d',$time,verif);
end
endmodule: blocking_example
RESULT:
!!@0ns !! BLOCKING :: First Assignment Value of asic is ::10
!!@0ns !! BLOCKING :: First Assignment Value of verif is ::15
!!@0ns !! BLOCKING :: Second Assignment Value of asic is ::15
!!@0ns !! BLOCKING :: Second Assignment Value of verif is ::25
Verilog

Systemverilog Module

The Eda playground example for the Non-blocking:

module NONblocking_example;
int asic,verif;
int world,verification;
initialbegin
asic =15;
verif =25;
world <= asic + verif;
verification <= asic + verif + world;
$display('!! @%gns !! NON-BLOCKING :: First Assignment Value of world is :: %0d',$time,world);
$display('!! @%gns !! NON-BLOCKING :: First Assignment Value of verification is :: %0d',$time,verification);
#10ns;
$display('!! @%gns !! NON-BLOCKING :: After 10ns First Assignment Value of world is :: %0d',$time,world);
$display('!! @%gns !! NON-BLOCKING :: After 10ns First Assignment Value of verification is :: %0d',$time,verification);
end
finalbegin
$display('!! @%gns !! NON-BLOCKING :: Final Assignment Value of world is :: %0d',$time,world);
$display('!! @%gns !! NON-BLOCKING :: Final Assignment Value of verification is :: %0d',$time,verification);
end
endmodule: NONblocking_example
RESULT:
!!@0ns !! NON-BLOCKING :: First Assignment Value of world is ::0
!!@0ns !! NON-BLOCKING :: First Assignment Value of verification is ::0
!!@10ns!! NON-BLOCKING :: After 10ns First Assignment Value of world is ::40
!!@10ns!! NON-BLOCKING :: After 10ns First Assignment Value of verification is ::40
!!@10ns!! NON-BLOCKING ::Final Assignment Value of world is ::40
!!@10ns!! NON-BLOCKING ::Final Assignment Value of verification is ::40
We can add some delay after displaying each statement.
Program Block Vs Module In System VerilogSystemverilog

The following process will explain how blocking and non-blocking procedural statements will execute:

  1. At the current time-slot, the simulator will evaluate the right-hand side of all assignment statements, those are related to Non-blocking statements.
  2. All the blocking procedural statements will execute at the same time, all the non-blocking statements are set aside for processing.
  3. The non-blocking procedural statements with no timing controls will execute in this third stage.
  4. The non-blocking procedural statements with timing controls will execute in this 4th stage.
  5. Advance the simulation clock.

Finally, we completed the article blocking and non-blocking in Verilog with the topics of Verilog blocking and non-blocking. In the next post, we will discuss the event Scheduling in Verilog.