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: $unit:: Doesn't Add Forward Visibility

SystemVerilog Advanced Features

Runnable example from the SystemVerilog $unit Compilation Scope tutorial ($unit:: Doesn't Add Forward Visibility)

Open in IDE
testbench.sv
int x;

module tb;
  initial begin
    x = 5 + limit;           // illegal: 'limit' isn't declared yet at this point
    x = 5 + $unit::limit;    // also illegal: $unit:: grants no forward visibility
  end
endmodule

int limit = 10;   // declared after the module that tried to use it
Admin mode — edit and delete controls are visible on each row. Use the IDE to add new snippets via File → Save as Snippet.