naja-scope

v0.2.1
io.github.keplertech/naja-scope Checked 2 days ago Published 2 days ago

Let 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.

ParameterTypeDescription
pathInstance path to focus; omit for the top.
view_optionsDrawing 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.

ParameterTypeDescription
path *arrayExact pin/port names, e.g. ['top', 'u_cpu', 'D']; select a bus bit with bit.
addbooleanAdd to existing traces; false clears the drawing first.
bitBus bit index, separate from the literal name; omit for the whole object.
colorOptional trace color, #rrggbb.
tracebooleanDraw 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.

ParameterTypeDescription
file *stringLocal destination .svg or .png file; existing file may be overwritten.
instancesScope instance paths to draw as boxes; excludes the top.
netsScope pin/port paths for one-net traces; select bus bits.
scalenumberPNG pixels per SVG pixel (0 < scale <= 64); ignored for SVG.
tracesScope pin/port paths for combinational fan-in cones; select bus bits.
view_optionsDrawing 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.

ParameterTypeDescription
items *arrayUp 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…

ParameterTypeDescription
allow_unknown_designsbooleanBlack-box unresolved module definitions instead of failing elaboration.
blackbox_multi_writer_memoriesbooleanBlack-box whole modules whose memories have unsupported multiple writers instead of failing.
default_timescaleFallback time scale for modules without an explicit time unit, e.g. 1ns/1ps; omit to use the frontend default.
definesPreprocessor definitions as "NAME" or "NAME=VALUE" entries.
filesLocal SystemVerilog source file paths; optional when flist is provided.
flistPath to a simulator-style file list; optional when files are provided.
intentbooleanRetain the live SNL-to-slang link required by get_intent; uses more memory.
keep_assignsbooleanPreserve continuous assignments as explicit lowered objects.
topTop 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.

ParameterTypeDescription
files *arrayOne or more local structural Verilog netlist paths.
allow_unknown_designsbooleanBlack-box unresolved cell/module definitions instead of failing.
keep_assignsbooleanPreserve continuous assignments as explicit objects.
yosys_source_attributesbooleanDecode 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…

ParameterTypeDescription
file *A local VHDL source path (.vhd/.vhdl), or a list of paths loaded as one batch in any order.
intentbooleanRetain VHDL source intent for get_intent; the last load_vhdl call decides whether it stays live.
libraryVHDL library the files compile into, for designs that name it, as in `library neorv32;`. Omit for designs that use `work`.
topTop 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}`.

ParameterTypeDescription
files *arrayOne 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}`.

ParameterTypeDescription
fileLocal Python file defining load(db); used only when name is omitted.
nameBuilt-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.

ParameterTypeDescription
directory *stringLocal 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).

ParameterTypeDescription
directory *stringLocal directory previously created by save_snapshot.
intentbooleanAlso 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.

ParameterTypeDescription
path *arrayList of exact names; optional top first. Use the separate bit field.
bitBus bit index, separate from the literal name; omit for the whole object.
kindOptional object-kind filter for otherwise ambiguous paths.
limitMaximum 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.

ParameterTypeDescription
pattern *arrayList of per-element case-sensitive globs. Use ** for recursive descent; optional top first.
cursorOpaque next_cursor from the previous response; omit for the first page.
kindstringRestrict results to one design-object kind, or any.
limitPage 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.

ParameterTypeDescription
cursorOpaque root-level next_cursor from a previous response.
depthintegerTree depth from 1 through 5; out-of-range values are clamped.
limitMaximum non-assign children per level; root default 20, maximum 100.
pathHierarchical 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 —…

ParameterTypeDescription
path *arrayExact hierarchical path to a term or net in the loaded design.
bitBus bit index, separate from the literal name; omit for the whole object.
limitMaximum 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.

ParameterTypeDescription
path *arrayExact hierarchical path to a term or net in the loaded design.
bitBus bit index, separate from the literal name; omit for the whole object.
limitMaximum 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…

ParameterTypeDescription
direction *stringTraverse upstream fanin or downstream fanout logic.
path *arrayExact hierarchical path to the cone's root term or net.
bitBus bit index, separate from the literal name; omit for the whole object.
max_frontierintegerMaximum 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.

ParameterTypeDescription
path *arrayExact hierarchical path to a loaded design object.
bitBus bit index, separate from the literal name; omit for the whole object.
context_linesintegerExtra lines before and after the source range; clamped to 0..20.
originIndex 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.

ParameterTypeDescription
module *stringElaborated 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.

ParameterTypeDescription
moduleElaborated 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…

ParameterTypeDescription
cursorOpaque next_cursor from the previous response; omit for the first page.
limitOpt into model details with this page size (maximum 200). Omit limit and cursor for summary only; cursor-only pages default to 25.
pathHierarchical 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.…

ParameterTypeDescription
ref *arrayList of exact object/instance/parameter names. Package name or pkg::NAME is a single-element list.
bitBus bit index, separate from the literal name; omit for the whole object.
wantstringIntent 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.

ParameterTypeDescription
filesRTL source paths; omit to reuse captured load inputs.
flistSystemVerilog file-list path (not VHDL); omit to reuse captured load inputs.
topTop module/entity name; omit to reuse the captured or inferred top.