Expert Raw API
najaeda ships two Python API levels:
najaeda.netlistis the supported high-level API for most tools.najaeda.najais the raw compiled extension module, historically also importable as top-levelnajain some build layouts.
The raw layer is useful, but it is intentionally not the first documentation entry point. It exposes native SNL objects directly and assumes that callers understand database ownership, object lifetimes, uniquification, and the SNL hierarchy model.
When to use the raw API
Use najaeda.naja when you need to:
construct SNL objects using native factory methods;
call a native method that is not wrapped by
najaeda.netlist;inspect exact SNL IDs, paths, occurrences, libraries, or databases;
use live SystemVerilog frontend intent helpers;
debug the high-level API or compare wrapper behavior against native state.
Prefer najaeda.netlist for application code that edits hierarchical
designs. If you edit raw objects directly, automatic high-level
uniquification does not protect you.
Importing the raw module
Use the package export in user code:
from najaeda import naja
print(naja.getVersion())
universe = naja.NLUniverse.get()
Some development and test layouts also place the extension on PYTHONPATH
as top-level naja. Prefer from najaeda import naja in documentation
and reusable scripts because it works with bundled package layouts too.
Importing the native module does not write a performance report by default.
Set NAJA_PERF=1 to write naja_perf.log, or set NAJA_PERF to a file
path to select another destination. An unset or empty value disables the
performance report, which is appropriate when embedding Naja in a host Python
process.
Object identity and hashing
Raw SNL objects returned by repeated accessor calls are not guaranteed to be
the same Python wrapper object. Do not use id(obj) to identify nets,
terms, instances, paths, occurrences, or other wrapped SNL objects across
calls. Use == for equality and use the wrapped object itself as a
dict key or set element when the object is hashable. Objects with a
native NLID hash from that NLID. SNLPath and SNLOccurrence
are hashable by composing the NLID values of their referenced objects.
SNLAttribute is hashable from its name and typed value. Other raw value
wrappers without an NLID are intentionally unhashable.
Relationship to high-level wrappers
High-level wrappers store or recover native objects internally:
High-level object |
Typical raw object |
Notes |
|---|---|---|
Carries occurrence context; edits may uniquify. |
||
|
May represent top terms or instance terms. |
|
|
Use high-level wrappers for hierarchical net edits. |
|
Native object used for flat connectivity. |
||
Metadata attached to SNL design objects. |
Raw construction example
The exact factory signatures are native CPython bindings. The following pattern shows the intended ownership flow:
from najaeda import naja
universe = naja.NLUniverse.create()
db = naja.NLDB.create(universe)
lib = naja.NLLibrary.create(db, "work")
design = naja.SNLDesign.create(lib, "top")
universe.setTopDesign(design)
a = naja.SNLScalarTerm.create(design, naja.SNLTerm.Direction.Input, "a")
y = naja.SNLScalarTerm.create(design, naja.SNLTerm.Direction.Output, "y")
n = naja.SNLScalarNet.create(design, "n")
a.setNet(n)
y.setNet(n)
Object lifetime and safety
Raw objects are views of native C++ objects. After calling destroy() or
after resetting/destroying the owning universe, database, library, or design,
do not keep using Python objects that referenced the destroyed native object.
The raw API also exposes shared model state. Renaming, reconnecting, or destroying an object through a raw handle mutates the underlying SNL object directly. If the same model is instantiated in multiple places, that change can affect all occurrences unless you explicitly uniquify first.
SystemVerilog frontend intent helpers
The raw module includes expert helpers for live SystemVerilog frontend data:
These helpers return plain Python data or capsules tied to the latest retained SystemVerilog frontend state. Treat capsules as opaque handles.
Raw module reference
The compiled extension exposes the following public objects in the current binding. Read this table as an expert index; the C++ SNL API remains the semantic source of truth.
Object |
Main public methods and values |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Module functions |
|
Detailed raw reference
When Sphinx can import the compiled extension, the following section exposes clickable class and method anchors generated from the raw binding itself. Documentation builders that do not have the binary available show the static expert reference above.