Skip to content

netlist_carpentry.io.read.abstract_reader

Base module for reading circuit content from a text file.

Classes:

  • AbstractReader

    Abstract class for reading circuit content from a text file.

AbstractReader

AbstractReader(path: Union[str, Path])

Abstract class for reading circuit content from a text file.

An implementation example is given with the netlist_carpentry.io.read.yosys.YosysNetlistReader class, which reads Yosys-generated JSON netlists and transforms the read content into a Circuit object.

Methods:

  • read

    Reads a circuit design file and returns a dict-like data structure containing the raw circuit data.

  • transform_to_circuit

    This method transforms the content read via the read function into a Circuit.

read

read() -> object

Reads a circuit design file and returns a dict-like data structure containing the raw circuit data.

Not implemented in the base class AbstractReader, must be implemented in derived classes. See the implementation in the netlist_carpentry.io.read.yosys.YosysNetlistReader class for an example.

Raises:

  • NotImplementedError

    Not implemented in the base class, must be implemented in derived classes.

Returns:

  • object ( object ) –

    A dict-like data structure containing the raw circuit data. May be processed by the transform_to_circuit() method to retrieve a Circuit object.

transform_to_circuit

transform_to_circuit(name: Optional[str] = None) -> Circuit

This method transforms the content read via the read function into a Circuit.

Not implemented in the base class AbstractReader, must be implemented in derived classes. See the implementation in the netlist_carpentry.io.read.yosys.YosysNetlistReader class for an example.

Parameters:

  • name

    (Optional[str], default: None ) –

    A circuit name. If None, a generic name is given. Defaults to None.

Raises:

  • NotImplementedError

    Not implemented in the base class, must be implemented in derived classes.

Returns:

  • Circuit ( Circuit ) –

    The circuit with the elements as described in the read circuit design file.