naja-scope
v0.2.1Let AI agents explore SystemVerilog, Verilog and VHDL designs: connectivity, hierarchy, source.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
open_schematic
Serve an interactive browser schematic of the current design. Returns a local URL to open on the MCP server's machine; requires the schematic extra. Uses the loaded design and supports anonymous #id instances.
| Parameter | Type | Description |
|---|---|---|
path | Instance path to focus; omit for the top. | |
view_options | Drawing options: instance_label (name/model/both), sink_rows, max_sinks (0 = all), group_by (model/hierarchy/role/pin), convergence_outline. |
show_schematic_net
Draw a pin's net or fan-in cone in the browser schematic. Returns a local viewer URL. Uses the current design; supports anonymous #id paths.
| Parameter | Type | Description |
|---|---|---|
path * | array | Exact pin/port names, e.g. ['top', 'u_cpu', 'D']; select a bus bit with bit. |
add | boolean | Add to existing traces; false clears the drawing first. |
bit | Bus bit index, separate from the literal name; omit for the whole object. | |
color | Optional trace color, #rrggbb. | |
trace | boolean | Draw the combinational fan-in cone back to flops, ports and blackboxes. |
export_schematic
Export a fresh schematic from the loaded design without a browser. Supply 1–200 total targets. Returns file, format and byte size, without embedding image data. Browser annotations and traces are independent.
| Parameter | Type | Description |
|---|---|---|
file * | string | Local destination .svg or .png file; existing file may be overwritten. |
instances | Scope instance paths to draw as boxes; excludes the top. | |
nets | Scope pin/port paths for one-net traces; select bus bits. | |
scale | number | PNG pixels per SVG pixel (0 < scale <= 64); ignored for SVG. |
traces | Scope pin/port paths for combinational fan-in cones; select bus bits. | |
view_options | Drawing options as open_schematic; also title, caption, legend, hide_ui_glyphs for exports. |
annotate_schematic
Replace schematic annotations on instances or pins/ports. Returns the local viewer URL and count. Annotations clear when the design changes.
| Parameter | Type | Description |
|---|---|---|
items * | array | Up to 200 annotations: path (scope path), kind (instance or term), severity (info, warning, error), message (up to 2000 characters). Whole pins/ports only; [] clears overlays. |
get_schematic_selection
Return the last browser-selected instance as a naja-scope path, or null. Use the returned path with module-card, source, or hierarchy tools.
status
Inspect the current in-memory session without changing it. Use this before design queries to confirm a design is loaded and whether get_intent is live (`intent_loaded`) or can be reloaded (`intent_loadable`). Returns `loaded` and, when available, the top summary and loaded source files.
load_systemverilog
Elaborate local SystemVerilog sources into the active design session. Use this for SystemVerilog RTL; use load_vhdl for VHDL (beta), or load_verilog with load_liberty/load_primitives for a structural gate netlist. Requires at least `files` or `flist` and changes the in-memory design session. Anonymous lowered objects are addressable by #<id>. defines are preprocessor -D entries ("NAME" or "NAME=VALUE"). allow_unknown_designs=True blackboxes any module still undefined instead of failing (e.g. undelivered hard macros in a partly-open-source design). blackbox_multi…
| Parameter | Type | Description |
|---|---|---|
allow_unknown_designs | boolean | Black-box unresolved module definitions instead of failing elaboration. |
blackbox_multi_writer_memories | boolean | Black-box whole modules whose memories have unsupported multiple writers instead of failing. |
default_timescale | Fallback time scale for modules without an explicit time unit, e.g. 1ns/1ps; omit to use the frontend default. | |
defines | Preprocessor definitions as "NAME" or "NAME=VALUE" entries. | |
files | Local SystemVerilog source file paths; optional when flist is provided. | |
flist | Path to a simulator-style file list; optional when files are provided. | |
intent | boolean | Retain the live SNL-to-slang link required by get_intent; uses more memory. |
keep_assigns | boolean | Preserve continuous assignments as explicit lowered objects. |
top | Top module name; omit to use najaeda's inferred top. |
load_verilog
Load local gate-level or structural Verilog into the active session. First call load_liberty for Liberty cells or load_primitives for built-ins; use load_systemverilog instead for RTL elaboration. Unknown modules fail unless `allow_unknown_designs` is true. get_source shows the netlist declaration of an object; for Yosys output, yosys_source_attributes=True also records its RTL `origins` (get_source origin=N). get_intent cannot answer for netlists.
| Parameter | Type | Description |
|---|---|---|
files * | array | One or more local structural Verilog netlist paths. |
allow_unknown_designs | boolean | Black-box unresolved cell/module definitions instead of failing. |
keep_assigns | boolean | Preserve continuous assignments as explicit objects. |
yosys_source_attributes | boolean | Decode Yosys `(* src = ... *)` attributes into source origins pointing back to the RTL. |
load_vhdl
Load VHDL into the active session (beta, restricted two-state RTL subset). Prefer passing every file of the design as one list (any order; units are resolved across files). Single-file calls still work: load package files first, then the top. Package-only files or entities awaiting generics may return top=null. Use hierarchy, cards and connectivity queries on the elaborated design. Use get_source for entity, port, signal, instance and process source references. intent=True enables get_intent for enum literals, record fields, generics and symbolic ranges. Uns…
| Parameter | Type | Description |
|---|---|---|
file * | A local VHDL source path (.vhd/.vhdl), or a list of paths loaded as one batch in any order. | |
intent | boolean | Retain VHDL source intent for get_intent; the last load_vhdl call decides whether it stays live. |
library | VHDL library the files compile into, for designs that name it, as in `library neorv32;`. Omit for designs that use `work`. | |
top | Top entity name; omit to infer the top. |
load_liberty
Register standard-cell models from local Liberty `.lib` files in the active session. Use this before load_verilog when a gate netlist instantiates those cells; use load_primitives instead for the built-in Xilinx or Yosys model sets. This changes session state and returns `{"ok": true}`.
| Parameter | Type | Description |
|---|---|---|
files * | array | One or more local Liberty .lib file paths. |
load_primitives
Register primitive models in the active session from either a built-in `name` (`xilinx` or `yosys`) or one local Python `file` defining `load(db)`. Provide one source; `name` takes precedence when both are set. A custom file executes unsandboxed Python in the server process, so only use trusted code. Use load_liberty instead for standard-cell `.lib` files. Returns `{"ok": true}`.
| Parameter | Type | Description |
|---|---|---|
file | Local Python file defining load(db); used only when name is omitted. | |
name | Built-in primitive set to register; when set, file is ignored. |
save_snapshot
Write the active design and source metadata to a local directory for fast reload. Use after loading a design; load_snapshot reads the result. Existing snapshot files in the directory may be overwritten. Snapshots are tied to their producing najaeda version, and returns include the saved path.
| Parameter | Type | Description |
|---|---|---|
directory * | string | Local destination directory for naja-if and metadata files. |
load_snapshot
Load a compatible save_snapshot directory into the active session in seconds instead of re-elaborating. Use load_systemverilog/load_verilog/load_vhdl when no compatible snapshot exists. The directory must match this najaeda version. intent=True also re-elaborates the warm intent layer from the flist saved in the snapshot (for get_intent).
| Parameter | Type | Description |
|---|---|---|
directory * | string | Local directory previously created by save_snapshot. |
intent | boolean | Also rebuild the warm intent layer from saved elaboration inputs. |
reset_universe
Discard the active design and all in-memory session state. Use before starting an unrelated design; do not use merely to inspect status. This is destructive to the current session but does not delete source or snapshots. Repeating it is safe and returns `{"ok": true}`.
resolve
Resolve a known hierarchical object path to instance, term, or net descriptors with source references. Every list element is literal. Example: path=["top", "u_uart", "tx_o"], bit=0. Use find when the path is unknown; use get_hierarchy to browse children. This read-only query requires a loaded design and returns did-you-mean suggestions on failure.
| Parameter | Type | Description |
|---|---|---|
path * | array | List of exact names; optional top first. Use the separate bit field. |
bit | Bus bit index, separate from the literal name; omit for the whole object. | |
kind | Optional object-kind filter for otherwise ambiguous paths. | |
limit | Maximum matches to return; defaults to 20 and is capped at 200. |
find
Search case-sensitive object names across the loaded design with a glob. Use this when an exact path is unknown; use resolve once a path is known or get_hierarchy to browse structure. Use ["**", "*state*"] to search names at any depth. Each glob matches exactly one name; ** matches zero or more levels. Parameters and package members are source intent: use get_intent. Returns typed descriptors in `matches` plus `count`, `has_more`, and an opaque `next_cursor` for pagination.
| Parameter | Type | Description |
|---|---|---|
pattern * | array | List of per-element case-sensitive globs. Use ** for recursive descent; optional top first. |
cursor | Opaque next_cursor from the previous response; omit for the first page. | |
kind | string | Restrict results to one design-object kind, or any. |
limit | Page size; defaults to 20 and is capped at 200. |
get_hierarchy
Browse the instance tree below `path` (or the top instance). Use this for structural children; use find for design-wide name search or get_stats for aggregate model counts. Lists only non-assign children (real submodules + leaf primitives); `assign` glue is reported as `assign_count`, not enumerated. Each child carries a `leaf` flag (submodule vs leaf primitive). depth<=5; the non-assign set is paginated at the root via limit/cursor (next_cursor/has_more), deeper levels via children_truncated.
| Parameter | Type | Description |
|---|---|---|
cursor | Opaque root-level next_cursor from a previous response. | |
depth | integer | Tree depth from 1 through 5; out-of-range values are clamped. |
limit | Maximum non-assign children per level; root default 20, maximum 100. | |
path | Hierarchical instance path; omit to start at the top instance. |
get_drivers
List the immediate upstream endpoints that drive a term or net across hierarchy. Use this for direct sources; use get_loads for downstream readers or trace_cone for the transitive combinational fanin. Returns leaf drivers (FF/gate instances with pin, model, source ref) and top-level ports. Lowered assign glue is traversed rather than reported as an endpoint. Literal assign drivers include `constant` (0, 1, X, or Z); bus entries include `queried_bit`; endpoint pin indices use `pin_bit`. Capped at limit (default 20, max 200) with a `truncated` flag; no cursor —…
| Parameter | Type | Description |
|---|---|---|
path * | array | Exact hierarchical path to a term or net in the loaded design. |
bit | Bus bit index, separate from the literal name; omit for the whole object. | |
limit | Maximum endpoint entries; defaults to 20 and is capped at 200. |
get_loads
List the immediate downstream endpoints that consume a term or net across hierarchy. Use this for direct readers; use get_drivers for upstream sources or trace_cone for the transitive combinational fanout. Returns leaf readers (instances with pin, model, source ref) and top-level ports. Lowered assign glue is traversed rather than reported as an endpoint. Capped at limit (default 20, max 200) with a `truncated` flag; no cursor — raise limit to see more.
| Parameter | Type | Description |
|---|---|---|
path * | array | Exact hierarchical path to a term or net in the loaded design. |
bit | Bus bit index, separate from the literal name; omit for the whole object. | |
limit | Maximum endpoint entries; defaults to 20 and is capped at 200. |
trace_cone
Trace the combinational fanin/fanout cone of a term/net via naja's LogicCone. Use this for transitive logic reachability; use get_drivers or get_loads for only immediate endpoints. direction: fanin|fanout. The cone crosses hierarchy and combinatorial arcs and always stops at flops, top ports, and opaque black-box cells. Returns node_count, counts_by_kind, counts_by_model, and a `frontier` of {flops, ports, blackboxes} with exact counts and lists capped at max_frontier (<=200) with a truncation marker. `cross_hierarchy` groups the flop frontier by top-level submo…
| Parameter | Type | Description |
|---|---|---|
direction * | string | Traverse upstream fanin or downstream fanout logic. |
path * | array | Exact hierarchical path to the cone's root term or net. |
bit | Bus bit index, separate from the literal name; omit for the whole object. | |
max_frontier | integer | Maximum listed endpoints per frontier kind; clamped to 1..200. |
get_source
Read the bounded source excerpt that produced an object (for example, an SV FF instance maps to its `always_ff` block; a netlist cell maps to its instantiation line). Use when exact source text is needed; use get_intent for typedef/enum/parameter semantics. When the response lists `origins` (e.g. Yosys src attributes), call again with origin=N to read that RTL. Returns object, file, start/end range, text, and truncation status without modifying files; missing paths and source ranges return structured errors.
| Parameter | Type | Description |
|---|---|---|
path * | array | Exact hierarchical path to a loaded design object. |
bit | Bus bit index, separate from the literal name; omit for the whole object. | |
context_lines | integer | Extra lines before and after the source range; clamped to 0..20. |
origin | Index into the object's `origins` list to read an upstream source (e.g. the RTL behind a Yosys netlist cell) instead of its declaration. |
get_module_card
Deterministic module summary: ports, instance counts by model, sequential cell and register-bit counts, bounded RAM/ROM details (width, depth, ports, initialization preview), and source ref. Clock/reset candidates are name-based guesses; verify before relying on them. Use this for one model's interface; use get_stats for counts below an instance.
| Parameter | Type | Description |
|---|---|---|
module * | string | Elaborated module/model name, not an instance path. |
get_content_hash
Versioned SHA-256 of a model and its descendants, computed on demand. Compare elaborated content across snapshots using the same format_version. Names and IDs participate; source metadata and primitive definitions are excluded. Track naja_git_hash separately for engine changes. This is not functional equivalence. Large hierarchies can take time to hash.
| Parameter | Type | Description |
|---|---|---|
module | Elaborated module/model name; omit for the top design. |
get_stats
Summarize instance population by model below `path` or the top design. Use this for aggregate leaf/sequential/model counts, register bits, and RAM/ROM counts and capacity; use get_hierarchy for actual child instances or get_module_card for one model's ports. This read-only query requires a loaded design. Returns `root_model`, flat totals, `total_models`, and an empty `models` list by default. Pass limit or the returned next_cursor to retrieve model details with pagination. Register bits count modeled flip-flop/latch states, excluding memories; unknown sequential…
| Parameter | Type | Description |
|---|---|---|
cursor | Opaque next_cursor from the previous response; omit for the first page. | |
limit | Opt into model details with this page size (maximum 200). Omit limit and cursor for summary only; cursor-only pages default to 25. | |
path | Hierarchical instance path; omit to summarize the top design. |
get_intent
Retrieve source-level intent that netlist lowering erases (warm-only). Use when the answer is in the SystemVerilog or VHDL *type/declaration*, not the flattened gates: enum/typedef state names + encodings (incl. PACKAGE typedefs whose members live in another file), and symbolic PARAMETER or generic expressions (the formula behind a baked-in width). ref: an exact-name list (["cva6", "csr_regfile_i", "priv_lvl_q"]), a package member (["riscv::PLEN"]), a parameter (["top", "inst", "PARAM"]), an instance list for its parameters, or ["pkg"] to list package parameters.…
| Parameter | Type | Description |
|---|---|---|
ref * | array | List of exact object/instance/parameter names. Package name or pkg::NAME is a single-element list. |
bit | Bus bit index, separate from the literal name; omit for the whole object. | |
want | string | Intent fact to retrieve; auto selects from the reference. |
load_intent
Make the warm source-intent layer available for get_intent. Use after a SystemVerilog or VHDL load that did not retain intent; do not call for gate-level Verilog, and prefer `intent=True` on the initial load. This is a no-op when the link is already live; otherwise it replaces the active universe by re-elaborating from explicit or captured `flist`/`files`. Returns `intent_loaded`; missing inputs produce a structured error.
| Parameter | Type | Description |
|---|---|---|
files | RTL source paths; omit to reuse captured load inputs. | |
flist | SystemVerilog file-list path (not VHDL); omit to reuse captured load inputs. | |
top | Top module/entity name; omit to reuse the captured or inferred top. |