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

Case #1: Wait_trigger -> Trigger

UVM Reporting & Utilities

uvm_event: process_b is already blocked on wait_trigger() when process_a fires trigger() at #100, so process_b unblocks.

Open in IDE
testbench.sv
//----------------------------------------------------------------
// www.chipverify.com
//----------------------------------------------------------------


`include "uvm_macros.svh"
import uvm_pkg::*;

class my_test extends uvm_test;
  `uvm_component_utils(my_test)
  
  function new(string name="my_test", uvm_component parent=null);
    super.new(name, parent);
  endfunction
  
  uvm_event 	m_event;
  
  virtual function void build_phase(uvm_phase phase);    
    super.build_phase(phase);
    
    m_event = new();
  endfunction
  
  virtual task run_phase(uvm_phase phase);
    super.run_phase(phase);

    phase.raise_objection(this);
    
    fork
      process_a();
      process_b();
    join
    
    phase.drop_objection(this);
  endtask
  
  virtual task process_a();
    #100;
    `uvm_info(get_type_name(), $sformatf("[process_a] Before event.trigger"), UVM_MEDIUM)
    m_event.trigger();
    `uvm_info(get_type_name(), $sformatf("[process_a] After event.trigger"), UVM_MEDIUM)
  endtask
  
  virtual task process_b();
    `uvm_info(get_type_name(), $sformatf("[process_b] Waiting for event.trigger"), UVM_MEDIUM)
    m_event.wait_trigger();
    `uvm_info(get_type_name(), $sformatf("[process_b] Received event.trigger"), UVM_MEDIUM)    
  endtask
endclass


module tb;
  initial begin
    run_test("my_test");
  end
endmodule
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.