Skip to content

Design hierarchy

Reading code tells you what a module could be; the simulator decides what it is: which value each parameter gets from the instance above it, how many blocks a generate loop creates, which instances exist under which names. The Design Hierarchy tool window shows the design that way, elaborated: built from the top module down as a compiler builds it, with every parameter’s actual value. It comes from slang-server, the language server of the slang compiler, which the plugin starts in the background when you open the window. Without slang-server, the window shows the static hierarchy instead, built from the plugin’s own index (see Without slang-server).

counter #(.MAX(20)) u_counter(...); // in top.sv; counter.sv's default is MAX = 10
// Design Hierarchy:
// top top
// u_counter counter
// MAX int = 20

The steps use the sample project: unzip it, open the folder with File | Open…, and wait until the progress bar at the bottom right of the IDE (indexing) has finished. slang-server must be installed: Settings | Languages & Frameworks | SystemVerilog | slang, Download slang and slang-server (see Compiler checks). Nothing is edited.

  1. Open the hierarchy. Choose View | Tool Windows | Design Hierarchy. The window opens on the right side of the IDE and, after a moment (Loading the hierarchy…), lists top (the instance, in bold) followed by top in gray (its module: a top-level instance takes its module’s name), and the package counter_pkg. Click the arrow before top: you see its ports clk and rst_n (input logic), the variables count and done, the instance u_counter of counter, and the generate block g_lane.

  2. See a parameter’s value. Click the arrow before u_counter. Its first item is MAX int = 20. In rtl/counter.sv the default is parameter int MAX = 10, but rtl/top.sv instantiates it with .MAX(20): the tree shows the value this instance really has. Below it are the ports with their directions, and the variable state with its enum type: state Enum state_t (logic[1:0]).

  3. Go to the instance. Double-click u_counter. rtl/top.sv opens at the line counter #(.MAX(20)) u_counter(.clk, .rst_n, .count(count), .done(done));. Right-click u_counter and choose Go to Module: rtl/counter.sv opens at module counter.

  4. Unroll a generate loop. Click the arrow before g_lane. The loop for (i = 0; i < `LANES; i++) in rtl/top.sv made two blocks, [0] and [1] (LANES is 2 in rtl/defines.svh). Expand [1]: i integer = 1 (a genvar’s value is shown with the type integer) and its own busy.

If the window shows a message instead of the tree, see If it doesn’t work.

The design is read from the files on disk, compiled as Compiler checks describe (the compile file, its options and your Extra flags), and elaborated by slang-server. The window lists the top instances and the packages. An instance’s items are loaded when you expand it, so a large design opens quickly.

A row Shows
An instance its name in bold, then its module, interface or program
A parameter its type and its elaborated value: MAX int = 20
A port, variable or net its type, with the direction for a port: count output logic[7:0]
A generate block or loop its label; a loop’s blocks as [0], [1], … with their own genvar values
A package package

The tree follows the files on disk: when you have saved a change, click Refresh in the window’s toolbar (the circular-arrow icon; hover a toolbar icon to see its name) and the design is elaborated again if a file of it changed. The toolbar also has Stop slang-server and Show slang-server Log; right-click an item for Jump to Source (where it is) and Go to Module (an instance’s module).

slang-server runs only while you use the hierarchy: it starts when the window (or an agent’s sv_hierarchy) first asks, and stops after 10 minutes without a question, when you change the slang settings, and when the project closes. It runs in a folder of its own in the IDE’s system directory and reads no settings file of yours.

When slang-server cannot answer (not installed, no compile file, or stopped after crashing; see If it doesn’t work), the window shows the static hierarchy and says so on a line above the tree: Static hierarchy (parameters as written, generate loops not unrolled): followed by the reason, and a link (Download slang-server, or slang settings). Nothing is elaborated:

Elaborated (slang-server) Static (the plugin’s index)
The top the top instances slang finds the modules of the compile file’s sources (not its -v library files) that no instantiation or bind names; with no compile file, those of all project files
A parameter its elaborated value: MAX int = 20 the value written at the instance (#(.MAX(20)), by name or position: MAX int = 20), else the default as written
A generate loop or if one block per iteration or the branch taken: g_lane, [0], [1] not unrolled, conditions not evaluated: the instances inside are listed under the module (every branch’s), the block labels in their path (top.g_a.u)
Variables listed not listed

On the sample project the static tree shows top, counter_pkg, and under top the ports and u_counter counter, whose MAX reads int = 20 (written in rtl/top.sv); g_lane is not shown, since it holds no instance. Double-click, Jump to Source and Go to Module work the same way. When slang-server is installed, click Refresh to get the elaborated tree.

You see Likely cause What to do
Static hierarchy …: slang-server is not installed… above the tree slang-server is not installed: the static tree is shown Click Download slang-server, then Refresh
Static hierarchy …: no compile file: choose one in Settings | Languages & Frameworks | SystemVerilog above the tree The project has no compile file: the static tree of the whole project is shown Choose one there, then Refresh
A warning line above the tree, starting slang-server: slang-server could not load part of the design (an option it does not know, a missing file); the tree may be partial Hover it for the full text; fix the compile file or Extra flags
Static hierarchy …: slang-server stopped 3 times in 10 minutes… above the tree slang-server keeps crashing on this design (the static tree is shown meanwhile) Open Show slang-server Log; click Stop slang-server, then Refresh to try again
Loading the hierarchy… does not go away slang-server is still elaborating a large design, or is stuck Wait; else open Show slang-server Log, click Stop slang-server, then Refresh
The tree is not the latest code A file has unsaved changes, or the tree was shown before you saved Save it (⌘S / Ctrl+S) and click Refresh

See also Known limitations: slang.