Complete najaeda API Reference
- class najaeda.netlist.Equipotential(term)[source]
Bases:
objectClass that represents the term and wraps some of the snl occurrence API.
- get_inst_terms()[source]
Iterate over the instance terminals of this equipotential.
- Returns:
an iterator over the instance terminals of this equipotential.
- Return type:
Iterator[Term]
- get_top_terms()[source]
Iterate over the top terminals of this equipotential.
- Returns:
an iterator over the top terminals of this equipotential.
- Return type:
Iterator[Term]
- is_const() bool[source]
Check if this equipotential is a constant generator.
- Returns:
True if this equipotential is a constant generator.
- Return type:
bool
- class najaeda.netlist.Instance(path=najaeda.naja.SNLPath)[source]
Bases:
objectClass that represents an instance in the design hierarchy.
Add input terms that are related to the given clock term.
- Parameters:
clock_term – the clock term to check for related inputs.
input_terms – a list of input terms to add.
- Returns:
None
Add output terms that are related to the given clock term.
- Parameters:
clock_term – the clock term to check for related outputs.
output_terms – a list of output terms to add.
- Returns:
None
- add_combinatorial_arcs(input_terms: List[Term], output_terms: List[Term])[source]
Add input terms that are combinatorial inputs for the given output term.
- Parameters:
output_term – the output term to check for combinatorial inputs.
input_terms – a list of input terms to add.
- Returns:
None
- count_attributes() int[source]
Count the attributes of this Instance.
- Returns:
the number of attributes of this Instance.
- Return type:
int
- count_bit_nets() int[source]
Count the number of scalar nets and bus net bits of this Instance.
- Returns:
the number of bit nets of this Instance.
- Return type:
int
- count_bit_terms() int[source]
Count the number of scalar terms and bus term bits of this Instance.
- Returns:
the number of bit terms of this Instance.
- Return type:
int
- count_child_instances() int[source]
- Returns:
the number of child instances of this instance.
- Return type:
int
- count_input_bit_terms() int[source]
Count the number of scalar input terms and bus input term bits of this Instance.
- Returns:
the number of bit input terms of this Instance.
- Return type:
int
- count_input_terms() int[source]
Count the number of scalar input terms and bus input terms of this Instance.
- Returns:
the number of input terms of this Instance.
- Return type:
int
- count_nets() int[source]
Count the number of scalar nets and bus nets of this Instance.
- Returns:
the number of nets of this Instance.
- Return type:
int
- count_output_bit_terms() int[source]
Count the number of scalar output terms and bus output term bits of this Instance.
- Returns:
the number of bit output terms of this Instance.
- Return type:
int
- count_output_terms() int[source]
Count the number of scalar output terms and bus output terms of this Instance.
- Returns:
the number of output terms of this Instance.
- Return type:
int
- count_terms() int[source]
Count the number of scalar terms and bus terms of this Instance.
- Returns:
the number of terms of this Instance.
- Return type:
int
- create_bus_net(name: str, msb: int, lsb: int) Net[source]
Create a bus Net in this Instance with the given name, msb and lsb.
- Parameters:
name (str) – the name of the Net to create.
msb (int) – the most significant bit of the Net to create.
lsb (int) – the least significant bit of the Net to create.
- Returns:
the created Net.
- Return type:
- create_bus_term(name: str, msb: int, lsb: int, direction: Direction) Term[source]
Create a bus Term in this Instance with the given name, msb, lsb and direction.
- Parameters:
name (str) – the name of the Term to create.
msb (int) – the most significant bit of the Term to create.
lsb (int) – the least significant bit of the Term to create.
direction (Term.Direction) – the direction of the Term to create.
- Returns:
the created Term.
- create_child_instance(model: str, name: str) Instance[source]
Create a child instance with the given model and name.
- Parameters:
model (str) – the name of the model of the instance to create.
name (str) – the name of the instance to create.
- Returns:
the created Instance.
- Return type:
- create_inout_bus_term(name: str, msb: int, lsb: int) Term[source]
Create an inout bus Term in this Instance with the given name, msb and lsb.
- Parameters:
name (str) – the name of the Term to create.
msb (int) – the most significant bit of the Term to create.
lsb (int) – the least significant bit of the Term to create.
- Returns:
the created Term.
- Return type:
- create_inout_term(name: str) Term[source]
Create an inout Term in this Instance with the given name.
- Parameters:
name (str) – the name of the Term to create.
- Returns:
the created Term.
- Return type:
- create_input_bus_term(name: str, msb: int, lsb: int) Term[source]
Create an input bus Term in this Instance with the given name, msb and lsb.
- Parameters:
name (str) – the name of the Term to create.
msb (int) – the most significant bit of the Term to create.
lsb (int) – the least significant bit of the Term to create.
- Returns:
the created Term.
- Return type:
- create_input_term(name: str) Term[source]
Create an input Term in this Instance with the given name.
- Parameters:
name (str) – the name of the Term to create.
- Returns:
the created Term.
- Return type:
- create_net(name: str) Net[source]
Create a scalar Net in this Instance with the given name.
- Parameters:
name (str) – the name of the Net to create.
- Returns:
the created Net.
- Return type:
- create_output_bus_term(name: str, msb: int, lsb: int) Term[source]
Create an output bus Term in this Instance with the given name, msb and lsb.
- Parameters:
name (str) – the name of the Term to create.
msb (int) – the most significant bit of the Term to create.
lsb (int) – the least significant bit of the Term to create.
- Returns:
the created Term.
- Return type:
- create_output_term(name: str) Term[source]
Create an output Term in this Instance with the given name.
- Parameters:
name (str) – the name of the Term to create.
- Returns:
the created Term.
- Return type:
- create_term(name: str, direction: Direction) Term[source]
Create a Term in this Instance with the given name and direction.
- Parameters:
name (str) – the name of the Term to create.
direction (Term.Direction) – the direction of the Term to create.
- Returns:
the created Term.
- dump_verilog(path: str, config: VerilogDumpConfig = None)[source]
Dump the verilog of this instance.
- Parameters:
path (str) – the file path where to dump the verilog.
config – the configuration to use when dumping the verilog.
- Return type:
None
- Raises:
ValueError – if the path does not end with .v.
FileNotFoundError – if the directory of the path does not exist.
- get_attributes() Iterator[Attribute][source]
Iterate over the attributes of this Instance.
- Returns:
the attributes of this Instance.
- Return type:
Iterator[Attribute]
- get_bit_nets()[source]
Iterate over all scalar nets and bus net bits.
- Returns:
an iterator over the nets at bit level of this Instance.
- Return type:
Iterator[Net]
- get_bit_terms()[source]
Iterate over all scalar terms and bus term bits.
- Returns:
the bit terms of this Instance.
- Return type:
Iterator[Term]
- get_child_instance(names: str | list)[source]
- Parameters:
names – the name of the child instance or the path to the child Instance as a list of names.
- Returns:
the child Instance at the given path or None if it does not exist.
- Return type:
Instance or None
- get_child_instance_by_id(ids: int | list[int])[source]
- Parameters:
ids – the ID of the child instance or the path to the child Instance as a list of IDs.
- Returns:
the child Instance at the given path or None if it does not exist.
- Return type:
Instance or None
- get_child_instances()[source]
Iterate over the child instances of this instance. Equivalent to go down one level in hierarchy.
- Returns:
an iterator over the child instances of this instance.
- Return type:
Iterator[Instance]
- get_input_bit_terms()[source]
Iterate over all scalar input terms and bus input term bits of this Instance.
- Returns:
the bit input terms of this Instance.
- Return type:
Iterator[Term]
- get_input_terms()[source]
Iterate over all scalar input terms and bus input terms of this Instance.
- Returns:
the input terms of this Instance.
- Return type:
Iterator[Term]
- get_leaf_children()[source]
Iterate over the leaf children of this Instance. Equivalent to the underlying leaves of the instanciation tree.
- Returns:
an iterator over the leaf children Instance of this Instance.
- Return type:
Iterator[Instance]
- get_model_id() tuple[int, int, int][source]
- Returns:
the ID of the model of this Instance or ID of the top if this is the top.
- get_model_name() str[source]
- Returns:
the name of the model of the instance or name of the top is this is the top.
- Return type:
str
- get_name() str[source]
- Returns:
the name of the instance or name of the top is this is the top.
- Return type:
str
- get_net(name: str) Net[source]
- Parameters:
name (str) – the name of the Net to get.
- Returns:
the Net with the given name or None if it does not exist.
- Return type:
Net or None
- get_nets()[source]
Iterate over all scalar nets and bus nets.
- Returns:
an iterator over the nets of this Instance.
- Return type:
Iterator[Net]
- get_output_bit_terms()[source]
Iterate over all scalar output terms and bus output term bits of this Instance.
- Returns:
the bit output terms of this Instance.
- Return type:
Iterator[Term]
- get_output_terms()[source]
Iterate over all scalar output terms and bus output terms of this Instance.
- Returns:
the output terms of this Instance.
- Return type:
Iterator[Term]
- get_term(name: str) Term[source]
- Parameters:
name (str) – the name of the Term to get.
- Returns:
the Term with the given name.
- Return type:
Term or None
- get_terms()[source]
Iterate over all scalar terms and bus terms of this Instance.
- Returns:
the terms of this Instance.
- Return type:
Iterator[Term]
- class najaeda.netlist.Net(path, net=None, net_concat=None)[source]
Bases:
object- class Type(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum
- count_attributes() int[source]
Count the attributes of this Net.
- Returns:
the number of attributes of this Net.
- Return type:
int
- count_design_terms() int[source]
Count the design terminals of this net.
- Returns:
the number of design terminals of this net.
- Return type:
int
- count_inst_terms() int[source]
Count the instance terminals of this net.
- Returns:
the number of instance terminals of this net.
- Return type:
int
- get_attributes() Iterator[Attribute][source]
Iterate over the attributes of this Net.
- Returns:
the attributes of this Net.
- Return type:
Iterator[Attribute]
- get_bit(index: int)[source]
- Parameters:
index (int) – the index of the bit to get.
- Returns:
the Net bit at the given index or None if it does not exist.
- Return type:
- get_bits()[source]
Iterate over the bits of this Net. The iterator will return itself if the Net is scalar. :return: an iterator over the bits of this Net. :rtype: Iterator[Net]
- get_design_terms()[source]
Return an iterator over the design terminals of the net. This includes only the terminals that are part of the current design. The iterator will yield Term objects bit per bit.
- Returns:
an iterator over the design terminals of the net.
- Return type:
Iterator[Term]
- get_inst_terms()[source]
- Returns:
an iterator over the instance terminals of the net.
- Return type:
Iterator[Term]
- get_lsb() int[source]
- Returns:
the least significant bit of the net if it is a bus.
- Return type:
int
- get_msb() int[source]
- Returns:
the most significant bit of the net if it is a bus.
- Return type:
int
- class najaeda.netlist.SystemVerilogConfig(keep_assigns: bool = True, elaborated_ast_json_path: str = None, diagnostics_report_path: str = None, pretty_print_elaborated_ast_json: bool = True, include_source_info_in_elaborated_ast_json: bool = True, flist: str = None, top: str = None, suppress_warnings: list = None)[source]
Bases:
object- diagnostics_report_path: str = None
- elaborated_ast_json_path: str = None
- flist: str = None
- include_source_info_in_elaborated_ast_json: bool = True
- keep_assigns: bool = True
- pretty_print_elaborated_ast_json: bool = True
- suppress_warnings: list = None
- top: str = None
- class najaeda.netlist.Term(path, term)[source]
Bases:
object- class Direction(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
EnumEnum for the direction of a term.
- bit: int | None
- connect_lower_net(net: Net)[source]
Connect this term to the given lower Net.
- Parameters:
net (Net) – the lower Net to connect to.
- connect_upper_net(net: Net)[source]
Connect this term to the given upper Net.
- Parameters:
net (Net) – the upper Net to connect to.
- count_attributes() int[source]
Count the attributes of this Term.
- Returns:
the number of attributes of this Term.
- Return type:
int
- get_attributes() Iterator[Attribute][source]
Iterate over the attributes of this Term.
- Returns:
the attributes of this Term.
- Return type:
Iterator[Attribute]
- get_bit(index: int)[source]
- Parameters:
index (int) – the index of the bit to get.
- Returns:
the Term bit at the given index or None if it does not exist.
- Return type:
Term or None
- get_bit_number()[source]
- Returns:
the bit index of the term if it is a bit.
- Return type:
int or None
- get_bits()[source]
- Returns:
an iterator over the bits of the term. If the term is scalar, it will return an iterator over itself.
- Return type:
Iterator[Term]
Get all input terms that are related to the given clock term.
- Parameters:
clock_term – the clock term to check for related inputs.
- Returns:
a list of input terms that are related to the clock term.
- Return type:
List[Term]
Get all output terms that are related to the given clock term.
- Parameters:
clock_term – the clock term to check for related outputs.
- Returns:
a list of output terms that are related to the clock term.
- Return type:
List[Term]
- get_combinatorial_inputs()[source]
Get all combinatorial input terms of this instance.
- Returns:
a list of combinatorial input terms.
- Return type:
List[Term]
- get_combinatorial_outputs()[source]
Get all combinatorial output terms of this instance.
- Returns:
a list of combinatorial output terms.
- Return type:
List[Term]
- get_equipotential() Equipotential[source]
- Returns:
the Equipotential of this Term.
- Return type:
- get_lsb() int[source]
- Returns:
the least significant bit of the term if it is a bus.
- Return type:
int or None
- get_msb() int[source]
- Returns:
the most significant bit of the term if it is a bus.
- Return type:
int or None
- class najaeda.netlist.VerilogConfig(keep_assigns: bool = True, allow_unknown_designs: bool = False, preprocess_enabled: bool = False, conflicting_design_name_policy: str = 'forbid')[source]
Bases:
object- allow_unknown_designs: bool = False
- conflicting_design_name_policy: str = 'forbid'
- keep_assigns: bool = True
- preprocess_enabled: bool = False
- class najaeda.netlist.VerilogDumpConfig(dumpRTLInfosAsAttributes: bool = False, dumpAssignsAsInstances: bool = False)[source]
Bases:
object- dumpAssignsAsInstances: bool = False
- dumpRTLInfosAsAttributes: bool = False
- najaeda.netlist.apply_constant_propagation()[source]
Apply constant propagation to the top design. :rtype: None
- najaeda.netlist.apply_dle()[source]
Apply the DLE (Dead Logic Elimination) to the top design. :rtype: None
- najaeda.netlist.create_top(name: str) Instance[source]
Create a top instance with the given name.
- Parameters:
name (str) – the name of the top instance to create.
- Returns:
the created top Instance.
- Return type:
- najaeda.netlist.get_max_fanout() list[source]
Get the maximum fanout of the top design.
- Returns:
the maximum fanout of the top design.
- Return type:
int
- najaeda.netlist.get_max_logic_level() list[source]
Get the maximum logic level of the top design.
- Returns:
the maximum logic level of the top design.
- Return type:
int
- najaeda.netlist.get_model_name(id: tuple[int, int, int]) str[source]
- Parameters:
id (tuple[int, int, int]) – the id of the model.
- Returns:
the name of the model given its id or None if it does not exist.
- Return type:
str or None
- najaeda.netlist.load_liberty(files: str | List[str])[source]
Load liberty files.
- Parameters:
files – a list of liberty files to load or a single file.
- Return type:
None
- Raises:
Exception – if no liberty files are provided.
- najaeda.netlist.load_primitives(name: str)[source]
Loads a primitive library embedded in najaeda.
Currently supported libraries are:
xilinx
yosys
- Parameters:
name (str) – the name of the primitives library to load.
- Raises:
ValueError – if the name is not recognized.
- Return type:
None
- najaeda.netlist.load_primitives_from_file(file: str)[source]
Loads a primitives library from a file.
- Parameters:
file (str) – the path to the primitives library file.
The file must define a function load(db).
- najaeda.netlist.load_system_verilog(files: str | List[str], config: SystemVerilogConfig = None) Instance[source]
Load SystemVerilog files into the top design.
- Parameters:
files – a list of SystemVerilog files to load or a single file.
config – the configuration to use when loading the files.
- Returns:
the top Instance.
- Return type:
- Raises:
Exception – if no files are provided.
- najaeda.netlist.load_verilog(files: str | List[str], config: VerilogConfig = None) Instance[source]
Load verilog files into the top design.
- Parameters:
files – a list of verilog files to load or a single file.
config – the configuration to use when loading the files.
- Returns:
the top Instance.
- Return type:
- Raises:
Exception – if no files are provided.