Instance Class

Instance Overview

In najaeda, an najaeda.netlist.Instance encapsulates the concept of an instance in its hierarchical context.

When an Instance is modified through editing methods, najaeda will automatically manage the necessary uniquification.

Generic Gates (and, or, etc.)

najaeda supports generic gates as defined in Verilog, specifically:

  • n-input gates: and, nand, or, nor, xor, xnor

  • n-output gates: buf, not

In this model:

  • n-input gates have a single scalar output and a bus input terminal (of size n).

  • n-output gates have a scalar input and a bus output terminal (of size n).

All terminals in these generic instances are unnamed (see najaeda.netlist.Instance.is_unnamed).

Instance Attributes

class najaeda.netlist.Instance(path=najaeda.naja.SNLPath)[source]

Bases: object

Class 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:

Net

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:

Instance

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:

Term

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:

Term

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:

Term

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:

Term

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:

Net

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:

Term

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:

Term

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.

delete()[source]

Delete this instance.

dump_context_dot(path: str)[source]
dump_full_dot(path: str)[source]

Dump the full dot file of this instance.

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_design() Instance[source]
Returns:

the Instance containing this instance.

Return type:

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]

get_truth_table()[source]
Returns:

the truth table of the instance.

Return type:

list[str]

has_modeling() bool[source]
Returns:

True if this instance has timing modeling.

Return type:

bool

is_assign() bool[source]

(assign a=b) will create an instance of assign connecting the wire a to the output of the assign and b to the input.

Returns:

True if this is an assign (represented by an unnamed assign instance).

Return type:

bool

is_blackbox() bool[source]
Returns:

True if this is a blackbox.

Return type:

bool

is_buf() bool[source]
Returns:

True if this is a buffer.

Return type:

bool

is_const() bool[source]
Returns:

True if this is a constant generator.

Return type:

bool

is_const0() bool[source]
Returns:

True if this is a constant 0 generator.

Return type:

bool

is_const1() bool[source]
Returns:

True if this is a constant 1 generator.

Return type:

bool

is_inv() bool[source]
Returns:

True if this is an inverter.

Return type:

bool

is_leaf() bool[source]
Returns:

True if this is a leaf.

Return type:

bool

is_primitive() bool[source]
Returns:

True if this is a primitive.

Return type:

bool

is_sequential() bool[source]
Returns:

True if this is a sequential element.

Return type:

bool

is_top() bool[source]
Returns:

True if this is the top design.

Return type:

bool

set_name(name: str)[source]

Set the name of this instance.

Parameters:

name (str) – the new name of the instance.