SILICON
Loading...
Searching...
No Matches
SerializationContext Class Reference

Mutable module-building interface passed to component serializers. More...

#include <netlist.hpp>

Collaboration diagram for SerializationContext:

Classes

struct  Impl

Public Member Functions

Json bits (const core::Bus &bus, std::string_view nullValue="x") const
 Convert a Silicon bus to a Yosys least-significant-bit-first vector.
Json inputBits (const core::Component &component, std::size_t index, std::size_t expectedWidth) const
 Encode a component input, applying its declared unconnected-input default.
Json allocateBits (std::size_t width)
 Allocate module-local temporary signal bits.
std::string componentIdentifier () const
 Stable name of the component being serialized within its module.
void addCell (std::string_view suffix, std::string_view type, Json parameters, Json portDirections, Json connections, Json attributes=Json::object())
 Emit one native Yosys cell for the current Silicon component.
void addPort (std::string name, std::string_view direction, const core::Bus &bus)
 Register a named top-level input or output port.
void addSubcircuitInstance (std::string_view slug, const std::vector< core::Bus > &inputs, const std::vector< core::Bus > &outputs, const core::CircuitResolver *resolver)
 Emit a hierarchical instance and recursively serialize its definition.
 SerializationContext (Impl &impl)

Static Public Member Functions

static Json concatenate (const std::vector< Json > &vectors)
 Concatenate bit vectors in their existing LSB-first order.
static std::string parameter (std::uint64_t value, std::size_t width=32)
 Encode an unsigned Yosys parameter as a fixed-width binary string.

Private Attributes

Impl & impl

Friends

std::string serialize (const core::Circuit &circuit, std::string_view moduleName)
 Serialize a complete Silicon circuit as Yosys write_json-compatible JSON.

Detailed Description

Mutable module-building interface passed to component serializers.

Components use this context to translate their logical behavior into native Yosys cells. Signal numbering, port netnames, and recursive module construction remain owned by the circuit-level serializer.

Definition at line 174 of file netlist.hpp.

Constructor & Destructor Documentation

◆ SerializationContext()

SerializationContext ( Impl & impl)
inlineexplicit

Definition at line 215 of file netlist.hpp.

Member Function Documentation

◆ addCell()

void addCell ( std::string_view suffix,
std::string_view type,
Json parameters,
Json portDirections,
Json connections,
Json attributes = Json::object() )

Emit one native Yosys cell for the current Silicon component.

Definition at line 346 of file netlist.cpp.

◆ addPort()

void addPort ( std::string name,
std::string_view direction,
const core::Bus & bus )

Register a named top-level input or output port.

Definition at line 402 of file netlist.cpp.

◆ addSubcircuitInstance()

void addSubcircuitInstance ( std::string_view slug,
const std::vector< core::Bus > & inputs,
const std::vector< core::Bus > & outputs,
const core::CircuitResolver * resolver )

Emit a hierarchical instance and recursively serialize its definition.

Definition at line 415 of file netlist.cpp.

◆ allocateBits()

Json allocateBits ( std::size_t width)
nodiscard

Allocate module-local temporary signal bits.

Definition at line 314 of file netlist.cpp.

◆ bits()

Json bits ( const core::Bus & bus,
std::string_view nullValue = "x" ) const
nodiscard

Convert a Silicon bus to a Yosys least-significant-bit-first vector.

Definition at line 276 of file netlist.cpp.

◆ componentIdentifier()

std::string componentIdentifier ( ) const
nodiscard

Stable name of the component being serialized within its module.

Definition at line 341 of file netlist.cpp.

◆ concatenate()

Json concatenate ( const std::vector< Json > & vectors)
staticnodiscard

Concatenate bit vectors in their existing LSB-first order.

Definition at line 322 of file netlist.cpp.

◆ inputBits()

Json inputBits ( const core::Component & component,
std::size_t index,
std::size_t expectedWidth ) const
nodiscard

Encode a component input, applying its declared unconnected-input default.

Parameters
componentComponent that owns the input
indexInput bus index
expectedWidthRequired bus width

Definition at line 290 of file netlist.cpp.

◆ parameter()

std::string parameter ( std::uint64_t value,
std::size_t width = 32 )
staticnodiscard

Encode an unsigned Yosys parameter as a fixed-width binary string.

Definition at line 331 of file netlist.cpp.

◆ serialize

std::string serialize ( const core::Circuit & circuit,
std::string_view moduleName )
friend

Serialize a complete Silicon circuit as Yosys write_json-compatible JSON.

Parameters
circuitThe circuit to serialize.
moduleNameThe Yosys module name to assign to the top-level circuit. The circuit itself owns no name; the caller supplies one (e.g. derived from the project document slug).

Definition at line 443 of file netlist.cpp.

Member Data Documentation

◆ impl

Impl& impl
private

Definition at line 218 of file netlist.hpp.


The documentation for this class was generated from the following files: