Ready-to-run snippets

Code Examples

Ready-to-run Verilog, SystemVerilog, and UVM examples. Click any to open it live in the IDE.

← All examples

Wait_order

SystemVerilog Interprocess Communication

wait_order(a, b, c) passes only when the three events fire in that exact sequence, with an else branch for the wrong order.

Open in IDE
testbench.sv
module tb;
  // Declare three events that can be triggered separately
  event a, b, c;
  
  // This block triggers each event one by one
  initial begin
    #10 -> a;
    #10 -> b;
    #10 -> c;
  end
  
  // This block waits until each event is triggered in the
  // given order
  initial begin
    
    wait_order (a,b,c) 
    	$display ("Events were executed in the correct order");
    else 
      	$display ("Events were NOT executed in the correct order !");	
  end
endmodule

/*
Simulation Log:
---------------
Compiler version P-2019.06-1; Runtime version P-2019.06-1;  Dec 28 06:00 2019
Events were executed in the correct order
           V C S   S i m u l a t i o n   R e p o r t 
Time: 30 ns
CPU Time:      0.500 seconds;       Data structure size:   0.0Mb
*/
design.sv
// Code your design here
Admin mode — edit and delete controls are visible on each row. Use the IDE to add new snippets via File → Save as Snippet.