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

$unit Compilation Scope: Accessing It Explicitly with $unit::

SystemVerilog Advanced Features

Runnable example from the SystemVerilog $unit Compilation Scope tutorial (Accessing It Explicitly with $unit::)

Open in IDE
testbench.sv
int counter = 100;   // $unit-scope declaration

module tb;
  initial begin
    int counter = 5;   // this local declaration shadows the $unit-scope one

    $display("counter        = %0d", counter);
    $display("$unit::counter = %0d", $unit::counter);
  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.