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

Clocking Blocks Part 2: Output Skew in Detail

SystemVerilog Interfaces & Modports

Runnable example from the SystemVerilog Clocking Blocks Part 2 tutorial (Output Skew in Detail)

Open in IDE
design.sv
interface _if (input logic clk);
  logic req;

  clocking cb_0 @(posedge clk);
    output #0ns req;    // driven in Re-NBA region (same edge)
  endclocking

  clocking cb_1 @(posedge clk);
    output #2ns req;    // driven 2ns after posedge
  endclocking

  clocking cb_2 @(posedge clk);
    output #5ns req;    // driven 5ns after posedge
  endclocking
endinterface
testbench.sv
module tb;
  logic clk;

  initial clk = 0;
  always #10 clk = ~clk;

  _if vif (.clk(clk));

  initial begin
    for (int i = 0; i < 3; i++) begin
      repeat (2) @(vif.cb_0);   // wait 2 posedges

      case (i)
        0: vif.cb_0.req <= 1;   // driven at Re-NBA of posedge
        1: vif.cb_1.req <= 1;   // driven 2ns after posedge
        2: vif.cb_2.req <= 1;   // driven 5ns after posedge
      endcase

      repeat (2) @(vif.cb_0);
      vif.req <= 0;             // direct reset between rounds (no clocking block skew intended here)
    end
    #20 $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.