FABulous.fabric_definition.Yosys_obj

Object representation of the Yosys Json file.

Classes

class YosysCellDetails[source]

Represents a cell instance in a Yosys module.

Cells are instantiated components like logic gates, flip-flops, or user-defined modules.

hide_name[source]

Whether to hide the cell name in output (1=hide, 0=show).

Type:

Literal[1, 0]

type[source]

Cell type/primitive name (e.g., “AND”, “DFF”, custom module name).

Type:

str

parameters[source]

Cell parameters as string key-value pairs.

Type:

KeyValue

attributes[source]

Cell attributes including metadata and synthesis directives.

Type:

KeyValue

connections[source]

Port connections mapping port names to bit vectors.

Type:

dict[str, BitVector]

port_directions[source]

Direction of each port. Default is empty dict.

Type:

dict[str, Literal[“input”, “output”, “inout”]], optional

model[source]

Associated model name. Default is “”.

Type:

str, optional

class YosysJson(path)[source]

Root object representing a complete Yosys JSON file.

Load and parse a HDL file to a Yosys JSON object.

This class provides the main interface for loading and analyzing Yosys JSON netlists. It contains all modules in the design and provides utility methods for common netlist analysis tasks.

Parameters:

path (Path) – Path to a HDL file.

srcPath[source]

Path to the source JSON file.

Type:

Path

creator[source]

Tool that created the JSON (usually “Yosys”).

Type:

str

modules[source]

Dictionary mapping module names to YosysModule objects.

Type:

dict[str, YosysModule]

models[source]

Dictionary of behavioral models (implementation-specific).

Type:

dict

Raises:
  • FileNotFoundError – If the JSON file doesn’t exist.

  • InvalidFileType – If the file type is not .vhd, .vhdl, .v, or .sv.

  • RuntimeError – If Yosys or GHDL fails to process the file.

  • ValueError – If there is a miss match in the VHDL entity and the Yosys top module.

Parameters:

path (Path)

Methods:

getNetPortSrcSinks(net)[source]

Find the source and sink connections for a given net.

This method analyzes the netlist to determine what drives a net (source) and what it connects to (sinks).

Parameters:

net (int) – Net ID to analyze.

Returns:

A tuple containing: - Source: (cell_name, port_name) tuple for the driving cell/port - Sinks: List of (cell_name, port_name) tuples for driven cells/ports

Return type:

tuple[tuple[str, str], list[tuple[str, str]]]

Raises:

ValueError – If net is not found or has multiple drivers.

Notes

If no driver is found, the source will be (“”, “z”) indicating a high-impedance or undriven net.

getTopModule()[source]

Find and return the top-level module in the design.

The top module is identified by having a “top” attribute.

Returns:

A tuple containing: - The name of the top-level module (str) - The YosysModule object for the top-level module

Return type:

tuple[str, YosysModule]

Raises:

ValueError – If no top module is found in the design.

isTopModuleNet(net)[source]

Check if a net ID corresponds to a top-level module port.

Parameters:

net (int) – Net ID to check.

Returns:

True if the net is connected to a top module port, False otherwise.

Return type:

bool

class YosysMemoryDetails[source]

Represents memory block details in a Yosys module.

Memory blocks are inferred or explicitly instantiated memory elements.

hide_name[source]

Whether to hide the memory name in output (1=hide, 0=show).

Type:

Literal[1, 0]

attributes[source]

Memory attributes and metadata.

Type:

KeyValue

width[source]

Data width in bits.

Type:

int

start_offset[source]

Starting address offset.

Type:

int

size[source]

Memory size (number of addressable locations).

Type:

int

class YosysModule(*, attributes, parameter_default_values, ports, cells, memories, netnames)[source]

Represents a module in a Yosys design.

A module contains the structural description of a digital circuit including its interface (ports), internal components (cells), memory blocks, and interconnections (nets).

Parameters:
  • attributes (KeyValue) – Module attributes dictionary.

  • parameter_default_values (KeyValue) – Parameter defaults dictionary.

  • ports (dict[str, YosysPortDetails]) – Ports dictionary (will be converted to YosysPortDetails objects).

  • cells (dict[str, YosysCellDetails]) – Cells dictionary (will be converted to YosysCellDetails objects).

  • memories (dict[str, YosysMemoryDetails]) – Memories dictionary (will be converted to YosysMemoryDetails objects).

  • netnames (dict[str, YosysNetDetails]) – Netnames dictionary (will be converted to YosysNetDetails objects).

attributes[source]

Module attributes and metadata (e.g., “top” for top module).

Type:

KeyValue

parameter_default_values[source]

Default values for module parameters.

Type:

KeyValue

ports[source]

Dictionary mapping port names to YosysPortDetails.

Type:

dict[str, YosysPortDetails]

cells[source]

Dictionary mapping cell names to YosysCellDetails.

Type:

dict[str, YosysCellDetails]

memories[source]

Dictionary mapping memory names to YosysMemoryDetails.

Type:

dict[str, YosysMemoryDetails]

netnames[source]

Dictionary mapping net names to YosysNetDetails.

Type:

dict[str, YosysNetDetails]

Methods:

class YosysNetDetails[source]

Represents net/wire details in a Yosys module.

Nets are the connections between cells and ports in the design.

hide_name[source]

Whether to hide the net name in output (1=hide, 0=show).

Type:

Literal[1, 0]

bits[source]

Bit vector representing the net’s signals.

Type:

BitVector

attributes[source]

Net attributes including unused bit information.

Type:

KeyValue

offset[source]

Bit offset for multi-bit nets.

Type:

int

upto[source]

Upper bound for bit ranges.

Type:

int

signed[source]

Whether the net is signed (0=unsigned, 1=signed).

Type:

int

class YosysPortDetails[source]

Represents port details in a Yosys module.

direction[source]

Port direction.

Type:

Literal[“input”, “output”, “inout”]

bits[source]

Bit vector representing the port’s signals.

Type:

BitVector

offset[source]

Bit offset for multi-bit ports.

Type:

int

upto[source]

Upper bound for bit ranges.

Type:

int

signed[source]

Whether the port is signed (0=unsigned, 1=signed).

Type:

int

Functions

Module Attributes

BitVector[source]
KeyValue[source]