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

repeat: Using repeat in Verification

SystemVerilog Control Flow & Loops

Runnable example from the SystemVerilog repeat tutorial (Using repeat in Verification)

Open in IDE
testbench.sv
module tb;
  bit         clk;
  logic [7:0] data;

  always #5 clk = ~clk;

  initial begin
    repeat (4) begin                     // drive 4 random data values
      @(posedge clk);
      data <= $urandom_range(0, 255);    // new value on each rising edge
    end
    repeat (2) @(posedge clk);           // then 2 idle cycles
    $finish;
  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.