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

Immediate Assertion in Testbench

SystemVerilog Assertions

Runnable example from the SystemVerilog Immediate Assertions tutorial (Immediate Assertion in Testbench)

Open in IDE
testbench.sv
class Packet;
  rand bit [7:0] addr;
  
  constraint c_addr { addr > 5; addr < 3; }
endclass

module tb;
  initial begin
    Packet m_pkt = new();
  
    m_pkt.randomize();
  end
endmodule
Admin mode — edit and delete controls are visible on each row. Use the IDE to add new snippets via File → Save as Snippet.