SILICON
Loading...
Searching...
No Matches
SILICON::core Namespace Reference

Namespaces

namespace  yosys_component_detail

Classes

class  ActiveKeyGuard
class  AndGate
class  BoundaryIoComponent
class  Bus
class  CallbackRegistry
class  Circuit
 Represents a digital circuit as a directed graph of components. More...
struct  CircuitConnection
 Directed logical connection between one component output bus and one input bus. More...
struct  CircuitPort
 Named bus exposed by a circuit boundary component or topology fallback. More...
class  CircuitResolver
class  Component
 Base class for all digital circuit components. More...
class  ComponentRegistry
class  ConstantComponent
 Drives a one-bit constant used by imported hardware netlists. More...
class  DFlipFlop
 D-type flip-flop. More...
class  DLatch
 Active-high, level-sensitive D latch. More...
class  DummyBusInputComponent
 Logical model behind the graphical bus input. More...
class  DummyBusOutputComponent
 Logical model behind the graphical bus output. More...
class  DummyInputComponent
 Logical model behind the graphical single-bit input. More...
class  DummyOutputComponent
 Logical model behind the graphical single-bit output. More...
struct  EdgeProperty
 Property stored in each edge of the circuit graph. More...
class  EFlipFlop
 Enabled D-type flip-flop. More...
class  FlipFlop
 Base class for edge-triggered storage elements with async clear/preset. More...
class  Gate
 Base class for combinational logic gates. More...
class  JKFlipFlop
 JK flip-flop. More...
class  NandGate
class  NorGate
class  NotGate
class  OrGate
struct  ParsedBusValue
 A bit-vector together with the textual interpretation that produced it. More...
class  Register
class  ROM
class  SerializationContext
 Mutable module-building interface passed to component serializers. More...
struct  SourceFile
class  SubcircuitComponent
struct  SubcircuitDefinition
struct  TransparentStringEqual
 Transparent equality functor for string-like keys. More...
struct  TransparentStringHash
 Transparent hash functor for string-like keys. More...
struct  VertexProperty
 Property stored in each vertex of the circuit graph. More...
class  Wire
class  XorGate

Concepts

concept  HasType
 Concept to check if a type has a Type static member.

Typedefs

using CircuitGraph
 Boost graph type representing the circuit topology.
using VertexDescriptor = boost::graph_traits<CircuitGraph>::vertex_descriptor
 Descriptor type for vertices in the circuit graph.
using EdgeDescriptor = boost::graph_traits<CircuitGraph>::edge_descriptor
 Descriptor type for edges in the circuit graph.
using PropertyValue = std::variant<int, bool, std::string, BusValue>
 Variant type for component properties.
using PropertyMap
 Map from property names to their values.
using PropertyCallback = std::function<PropertyValue(const PropertyValue&)>
 Callback function for property validation/transformation.
using PropertyCallbackMap
 Map from property names to their callback functions.
using StringPropertyOptions = std::vector<std::string>
 Allowed values for a constrained string property.
using StringPropertyOptionsMap
 Map from property names to constrained string values.
using Component_ptr = std::shared_ptr<Component>
using Component_weakPtr = std::weak_ptr<Component>
using Component_set = std::set<Component_ptr, std::owner_less<Component_ptr>>
using Wire_ptr = std::shared_ptr<Wire>
using BusValue = std::vector<State>
using BigInt = boost::multiprecision::cpp_int
using Json

Enumerations

enum class  ComponentCategory {
  Gates , Multiplexers , Arithmetic , FlipFlops ,
  Register , Memory , Subcircuits , Inputs ,
  Outputs , Utils
}
enum class  PortRole { None , Input , Output }
 Declares whether a component represents a public circuit boundary port. More...
enum class  State : unsigned char { LOW = '0' , HIGH = '1' , UNKNOWN = 'X' , ERROR = 'E' }
enum class  Signedness : bool { UNSIGNED = false , SIGNED = true }
enum class  BusValueFormat {
  Raw , Signed , Unsigned , Hex ,
  Oct , Bin , Unknown
}

Functions

uint64_t deserializePortId (const nlohmann::json &value)
uint64_t deserializeBoundaryPortId (const nlohmann::json &component)
Circuit deserializeCircuitDocument (const std::string_view contents, const ComponentRegistry &registry, const CircuitResolver *resolver)
SubcircuitDefinition parseCircuitDocument (const std::string_view contents, const ComponentRegistry &registry, const CircuitResolver *resolver)
PropertyValue requireNonNegative (std::string_view name, const PropertyValue &value)
 Validates that an integer property value is non-negative.
PropertyValue requireValidSize (std::string_view name, const PropertyValue &value)
 Validates that an integer property value is a valid bus size.
template<typename T>
void registerComponent (ComponentRegistry &registry)
void registerAllComponents (ComponentRegistry &registry)
std::string_view componentCategoryName (const ComponentCategory category)
State operator&& (const State &a, const State &b)
State operator|| (const State &a, const State &b)
State operator! (const State &a)
State operator^ (const State &a, const State &b)
std::string to_str (State s)
BusValue operator+ (const BusValue &a, const BusValue &b)
BusValue twosComplement (const BusValue &n)
std::partial_ordering compare (const BusValue &lhs, const BusValue &rhs, const Signedness signedness)
BusValue shift (const BusValue &v, const ptrdiff_t amount, const Signedness signedness)
BusValue multiply (const BusValue &a, const BusValue &b, const Signedness signedness)
std::pair< BusValue, BusValue > divide (const BusValue &a, const BusValue &b, Signedness signedness)
void configureOrthogonalRouter (Avoid::Router &router, qreal gridSize)
 Applies SILICON's shared orthogonal-routing policy to a libavoid router.
std::vector< QPointF > extractOrthogonalRoute (Avoid::ConnRef &connector, qreal gridSize)
 Extracts, grid-snaps, and canonicalizes a libavoid display route.
bool isOrthogonalRoute (std::span< const QPointF > points)
 Returns whether every consecutive route segment is axis-aligned.
bool orthogonalRouteSelfIntersects (std::span< const QPointF > points)
 Detects crossings, touches, or retraced portions within one route.
bool orthogonalRouteCrossesObstacleInterior (const std::span< const QPointF > route, const std::span< const QRectF > obstacles)
bool pointOnOrthogonalRoute (QPointF point, std::span< const QPointF > route)
 Returns whether point lies on an orthogonal polyline.
bool orthogonalRoutesTouch (std::span< const QPointF > first, std::span< const QPointF > second)
 Returns whether an endpoint of either route lies on the other route.
bool orthogonalRoutesShareSegment (std::span< const QPointF > first, std::span< const QPointF > second)
 Returns true when two orthogonal polylines share a positive-length segment.
bool orthogonalRoutesIntersect (std::span< const QPointF > first, std::span< const QPointF > second)
 Returns true when two routes overlap or form an ambiguous endpoint junction.
std::size_t orthogonalRouteCrossingCount (std::span< const QPointF > first, std::span< const QPointF > second)
 Counts strict, perpendicular interior crossings between two routes.
std::size_t orthogonalRouteIncidentArmCount (QPointF point, const std::vector< std::vector< QPointF > > &routes)
 Counts the distinct orthogonal arms incident to point.
std::vector< QPointF > canonicalizeOrthogonalRoute (std::vector< QPointF > points)
 Removes consecutive duplicates and redundant collinear interior points.
std::vector< std::vector< QPointF > > mergeOrthogonalRoutes (const std::vector< std::vector< QPointF > > &routes, const std::function< bool()> &progress={})
 Unions several routes of one net into maximal terminal-to-junction paths.
std::vector< QPointF > routeOrthogonalWire (const QPointF start, const QPointF end, const std::vector< QRectF > &obstacleRects, const qreal gridSize)
std::string formatInteger (const BigInt &value, const BusValueFormat format, const std::size_t bitWidth)
std::optional< BigInt > parseInteger (std::string_view text, const BusValueFormat format, const std::size_t bitWidth)
BusValue maxValueForBusWidth (const std::size_t width)
BusValue busValueFromInteger (const BigInt &value, std::size_t width)
 Builds an LSB-first BusValue from the low width bits of an integer. Negative values use two's complement and sign extension; nonnegative values use zero extension. Values are truncated to width bits; zero width is empty.
BigInt integerFromBusValue (const BusValue &value, Signedness signedness=Signedness::UNSIGNED)
 Decodes an LSB-first BusValue as an unsigned arbitrary-precision integer. Empty values yield zero. UNKNOWN or ERROR bits throw std::invalid_argument.
BusValue busValueFromBits (std::string_view bits)
 Strictly decodes an MSB-first raw string containing 0, 1, X, or E.
std::string formatValue (const BusValue &value, BusValueFormat format, std::size_t fixedWidth=0)
 Format an LSB-first BusValue for display.
ParsedBusValue valueFromStr (std::string_view text)
 Parse user-facing decimal, hexadecimal, octal, binary, or four-state text.
std::optional< BusValue > resizeParsedValue (const ParsedBusValue &parsed, std::size_t width)
 Adapts a parsed textual value to an exact destination width.

Typedef Documentation

◆ BigInt

using BigInt = boost::multiprecision::cpp_int

Definition at line 31 of file num_formatting.hpp.

◆ BusValue

using BusValue = std::vector<State>

Definition at line 120 of file wire.hpp.

◆ CircuitGraph

using CircuitGraph
Initial value:
boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, VertexProperty,
Property stored in each edge of the circuit graph.
Definition circuit.hpp:52
Property stored in each vertex of the circuit graph.
Definition circuit.hpp:46

Boost graph type representing the circuit topology.

Boost graph type representing the circuit topology.

Note
Uses vecS for vertex storage - vertex descriptors are indices. If vertices are ever removed, descriptors stored in componentToVertex will be invalidated and require rebuilding.

Definition at line 89 of file circuit.hpp.

◆ Component_ptr

typedef std::shared_ptr< Component > Component_ptr = std::shared_ptr<Component>

Definition at line 33 of file component_registry.hpp.

◆ Component_set

using Component_set = std::set<Component_ptr, std::owner_less<Component_ptr>>

Definition at line 54 of file wire.hpp.

◆ Component_weakPtr

using Component_weakPtr = std::weak_ptr<Component>

Definition at line 52 of file wire.hpp.

◆ EdgeDescriptor

using EdgeDescriptor = boost::graph_traits<CircuitGraph>::edge_descriptor

Descriptor type for edges in the circuit graph.

Definition at line 97 of file circuit.hpp.

◆ Json

using Json

Definition at line 44 of file netlist.hpp.

◆ PropertyCallback

using PropertyCallback = std::function<PropertyValue(const PropertyValue&)>

Callback function for property validation/transformation.

Definition at line 149 of file component.hpp.

◆ PropertyCallbackMap

Initial value:
std::unordered_map<std::string, PropertyCallback, TransparentStringHash,
std::function< PropertyValue(const PropertyValue &)> PropertyCallback
Callback function for property validation/transformation.
Transparent equality functor for string-like keys.
Transparent hash functor for string-like keys.

Map from property names to their callback functions.

Definition at line 152 of file component.hpp.

◆ PropertyMap

using PropertyMap
Initial value:
std::unordered_map<std::string, PropertyValue, TransparentStringHash,
std::variant< int, bool, std::string, BusValue > PropertyValue
Variant type for component properties.

Map from property names to their values.

Definition at line 145 of file component.hpp.

◆ PropertyValue

using PropertyValue = std::variant<int, bool, std::string, BusValue>

Variant type for component properties.

Supports configuration scalars, strings, and native logic-bus values.

Definition at line 142 of file component.hpp.

◆ StringPropertyOptions

using StringPropertyOptions = std::vector<std::string>

Allowed values for a constrained string property.

Definition at line 157 of file component.hpp.

◆ StringPropertyOptionsMap

Initial value:
std::unordered_map<std::string, StringPropertyOptions, TransparentStringHash,
std::vector< std::string > StringPropertyOptions
Allowed values for a constrained string property.

Map from property names to constrained string values.

Definition at line 160 of file component.hpp.

◆ VertexDescriptor

using VertexDescriptor = boost::graph_traits<CircuitGraph>::vertex_descriptor

Descriptor type for vertices in the circuit graph.

Definition at line 94 of file circuit.hpp.

◆ Wire_ptr

using Wire_ptr = std::shared_ptr<Wire>

Definition at line 116 of file wire.hpp.

Enumeration Type Documentation

◆ BusValueFormat

enum class BusValueFormat
strong
Enumerator
Raw 
Signed 
Unsigned 
Hex 
Oct 
Bin 
Unknown 

Definition at line 33 of file num_formatting.hpp.

◆ ComponentCategory

enum class ComponentCategory
strong
Enumerator
Gates 
Multiplexers 
Arithmetic 
FlipFlops 
Register 
Memory 
Subcircuits 
Inputs 
Outputs 
Utils 

Definition at line 47 of file component.hpp.

◆ PortRole

enum class PortRole
strong

Declares whether a component represents a public circuit boundary port.

This is deliberately separate from ComponentCategory : catalog categories may contain components that are not module ports (for example, constants in Inputs).

Enumerator
None 
Input 
Output 

Definition at line 66 of file component.hpp.

◆ Signedness

enum class Signedness : bool
strong
Enumerator
UNSIGNED 
SIGNED 

Definition at line 118 of file wire.hpp.

◆ State

enum class State : unsigned char
strong
Enumerator
LOW 
HIGH 
UNKNOWN 
ERROR 

Definition at line 37 of file wire.hpp.

Function Documentation

◆ busValueFromBits()

BusValue busValueFromBits ( const std::string_view bits)
nodiscard

Strictly decodes an MSB-first raw string containing 0, 1, X, or E.

Definition at line 295 of file num_formatting.cpp.

◆ busValueFromInteger()

BusValue busValueFromInteger ( const BigInt & value,
const std::size_t width )
nodiscard

Builds an LSB-first BusValue from the low width bits of an integer. Negative values use two's complement and sign extension; nonnegative values use zero extension. Values are truncated to width bits; zero width is empty.

Definition at line 257 of file num_formatting.cpp.

◆ canonicalizeOrthogonalRoute()

std::vector< QPointF > canonicalizeOrthogonalRoute ( std::vector< QPointF > points)
nodiscard

Removes consecutive duplicates and redundant collinear interior points.

Definition at line 380 of file wireRouting.cpp.

◆ compare()

std::partial_ordering compare ( const BusValue & lhs,
const BusValue & rhs,
const Signedness signedness )
nodiscard

Definition at line 289 of file wire.cpp.

◆ componentCategoryName()

std::string_view componentCategoryName ( const ComponentCategory category)

Definition at line 97 of file component_registry.cpp.

◆ configureOrthogonalRouter()

void configureOrthogonalRouter ( Avoid::Router & router,
qreal gridSize )

Applies SILICON's shared orthogonal-routing policy to a libavoid router.

Both interactive wire previews and full-circuit autoplacement use this policy so segment costs, shared-path avoidance, and nudging remain consistent.

Definition at line 69 of file wireRouting.cpp.

◆ deserializeBoundaryPortId()

uint64_t deserializeBoundaryPortId ( const nlohmann::json & component)
nodiscard

Read a boundary component's ID, deriving a stable ID for documents without one.

Definition at line 46 of file circuitDocument.cpp.

◆ deserializeCircuitDocument()

Circuit deserializeCircuitDocument ( std::string_view contents,
const ComponentRegistry & registry,
const CircuitResolver * resolver = nullptr )
nodiscard

Parses persisted Circuit document contents while preserving every component, including the boundary I/O components used by document-level serializers.

Definition at line 62 of file circuitDocument.cpp.

◆ deserializePortId()

uint64_t deserializePortId ( const nlohmann::json & value)
nodiscard

Read canonical nonzero numeric port IDs.

Read a canonical nonzero numeric port ID during deserialization.

Definition at line 36 of file circuitDocument.cpp.

◆ divide()

std::pair< BusValue, BusValue > divide ( const BusValue & a,
const BusValue & b,
Signedness signedness )
nodiscard

Definition at line 425 of file wire.cpp.

◆ extractOrthogonalRoute()

std::vector< QPointF > extractOrthogonalRoute ( Avoid::ConnRef & connector,
const qreal gridSize )
nodiscard

Extracts, grid-snaps, and canonicalizes a libavoid display route.

Definition at line 87 of file wireRouting.cpp.

◆ formatInteger()

std::string formatInteger ( const BigInt & value,
BusValueFormat format,
std::size_t bitWidth )
nodiscard

Format the low bitWidth bits of an arbitrary-precision integer. Prefixes are omitted; binary output is padded to the full bit width. A zero bit width throws std::invalid_argument.

Definition at line 166 of file num_formatting.cpp.

◆ formatValue()

std::string formatValue ( const BusValue & value,
const BusValueFormat format,
const std::size_t fixedWidth )
nodiscard

Format an LSB-first BusValue for display.

Definition at line 311 of file num_formatting.cpp.

◆ integerFromBusValue()

BigInt integerFromBusValue ( const BusValue & value,
const Signedness signedness )
nodiscard

Decodes an LSB-first BusValue as an unsigned arbitrary-precision integer. Empty values yield zero. UNKNOWN or ERROR bits throw std::invalid_argument.

Definition at line 272 of file num_formatting.cpp.

◆ isOrthogonalRoute()

bool isOrthogonalRoute ( const std::span< const QPointF > points)
nodiscard

Returns whether every consecutive route segment is axis-aligned.

Definition at line 115 of file wireRouting.cpp.

◆ maxValueForBusWidth()

BusValue maxValueForBusWidth ( const std::size_t width)
nodiscard

Definition at line 252 of file num_formatting.cpp.

◆ mergeOrthogonalRoutes()

std::vector< std::vector< QPointF > > mergeOrthogonalRoutes ( const std::vector< std::vector< QPointF > > & routes,
const std::function< bool()> & progress = {} )
nodiscard

Unions several routes of one net into maximal terminal-to-junction paths.

Shared and intersecting segments are split into a graph and redundant cycles are removed before joining degree-two vertices. Returned paths have distinct endpoints.

Parameters
progressOptional continuation check; false discards all merged paths.
Exceptions
std::invalid_argumentIf an input route has coincident endpoints.

Definition at line 402 of file wireRouting.cpp.

◆ multiply()

BusValue multiply ( const BusValue & a,
const BusValue & b,
const Signedness signedness )
nodiscard

Definition at line 388 of file wire.cpp.

◆ operator!()

State operator! ( const State & a)

Definition at line 55 of file wire.cpp.

◆ operator&&()

State operator&& ( const State & a,
const State & b )

Definition at line 33 of file wire.cpp.

◆ operator+()

BusValue operator+ ( const BusValue & a,
const BusValue & b )

Definition at line 251 of file wire.cpp.

◆ operator^()

State operator^ ( const State & a,
const State & b )

Definition at line 66 of file wire.cpp.

◆ operator||()

State operator|| ( const State & a,
const State & b )

Definition at line 44 of file wire.cpp.

◆ orthogonalRouteCrossesObstacleInterior()

bool orthogonalRouteCrossesObstacleInterior ( std::span< const QPointF > route,
std::span< const QRectF > obstacles )
nodiscard

Returns whether a route enters the interior of any obstacle rectangle.

Definition at line 174 of file wireRouting.cpp.

◆ orthogonalRouteCrossingCount()

std::size_t orthogonalRouteCrossingCount ( const std::span< const QPointF > first,
const std::span< const QPointF > second )
nodiscard

Counts strict, perpendicular interior crossings between two routes.

Definition at line 311 of file wireRouting.cpp.

◆ orthogonalRouteIncidentArmCount()

std::size_t orthogonalRouteIncidentArmCount ( const QPointF point,
const std::vector< std::vector< QPointF > > & routes )
nodiscard

Counts the distinct orthogonal arms incident to point.

Definition at line 341 of file wireRouting.cpp.

◆ orthogonalRouteSelfIntersects()

bool orthogonalRouteSelfIntersects ( const std::span< const QPointF > points)
nodiscard

Detects crossings, touches, or retraced portions within one route.

Definition at line 124 of file wireRouting.cpp.

◆ orthogonalRoutesIntersect()

bool orthogonalRoutesIntersect ( const std::span< const QPointF > first,
const std::span< const QPointF > second )
nodiscard

Returns true when two routes overlap or form an ambiguous endpoint junction.

Definition at line 268 of file wireRouting.cpp.

◆ orthogonalRoutesShareSegment()

bool orthogonalRoutesShareSegment ( const std::span< const QPointF > first,
const std::span< const QPointF > second )
nodiscard

Returns true when two orthogonal polylines share a positive-length segment.

Definition at line 230 of file wireRouting.cpp.

◆ orthogonalRoutesTouch()

bool orthogonalRoutesTouch ( const std::span< const QPointF > first,
const std::span< const QPointF > second )
nodiscard

Returns whether an endpoint of either route lies on the other route.

Definition at line 219 of file wireRouting.cpp.

◆ parseCircuitDocument()

SubcircuitDefinition parseCircuitDocument ( std::string_view contents,
const ComponentRegistry & registry,
const CircuitResolver * resolver = nullptr )
nodiscard

Parses persisted Circuit document contents without constructing graphical objects. Boundary I/O components define the reusable interface and are removed from the returned implementation circuit.

Definition at line 75 of file circuitDocument.cpp.

◆ parseInteger()

std::optional< BigInt > parseInteger ( std::string_view text,
BusValueFormat format,
std::size_t bitWidth )
nodiscard

Parse an integer in the explicitly selected format and return its width-limited two's-complement bit pattern. Invalid and out-of-range values return nullopt.

Definition at line 198 of file num_formatting.cpp.

◆ pointOnOrthogonalRoute()

bool pointOnOrthogonalRoute ( const QPointF point,
const std::span< const QPointF > route )
nodiscard

Returns whether point lies on an orthogonal polyline.

Definition at line 195 of file wireRouting.cpp.

◆ registerAllComponents()

void registerAllComponents ( ComponentRegistry & registry)

Definition at line 41 of file component_registration.cpp.

◆ registerComponent()

template<typename T>
void registerComponent ( ComponentRegistry & registry)
inline

Definition at line 34 of file component_registration.cpp.

◆ requireNonNegative()

PropertyValue requireNonNegative ( std::string_view name,
const PropertyValue & value )
nodiscard

Validates that an integer property value is non-negative.

Parameters
nameProperty name or descriptive prefix used in the error message
valueThe property value to validate
Returns
The validated value unchanged
Exceptions
std::invalid_argumentWhen the value is negative

Definition at line 29 of file component.cpp.

◆ requireValidSize()

PropertyValue requireValidSize ( std::string_view name,
const PropertyValue & value )
nodiscard

Validates that an integer property value is a valid bus size.

Parameters
nameProperty name or descriptive prefix used in the error message
valueThe property value to validate
Returns
The validated value unchanged
Exceptions
std::invalid_argumentWhen the value is below 1 or exceeds the maximum supported bus width

Definition at line 38 of file component.cpp.

◆ resizeParsedValue()

std::optional< BusValue > resizeParsedValue ( const ParsedBusValue & parsed,
std::size_t width )
nodiscard

Adapts a parsed textual value to an exact destination width.

Signed decimal values use two's-complement fit and sign extension. Other formats use unsigned fit and zero extension, except a scalar raw UNKNOWN expands to all UNKNOWN bits. A value that cannot be represented returns std::nullopt.

Definition at line 394 of file num_formatting.cpp.

◆ routeOrthogonalWire()

std::vector< QPointF > routeOrthogonalWire ( const QPointF start,
const QPointF end,
const std::vector< QRectF > & obstacleRects,
const qreal gridSize )
nodiscard

Definition at line 572 of file wireRouting.cpp.

◆ shift()

BusValue shift ( const BusValue & v,
const ptrdiff_t amount,
const Signedness signedness )
nodiscard

Definition at line 367 of file wire.cpp.

◆ to_str()

std::string to_str ( State s)

Definition at line 77 of file wire.cpp.

◆ twosComplement()

BusValue twosComplement ( const BusValue & n)
nodiscard

Definition at line 272 of file wire.cpp.

◆ valueFromStr()

ParsedBusValue valueFromStr ( std::string_view text)
nodiscard

Parse user-facing decimal, hexadecimal, octal, binary, or four-state text.

Unprefixed binary/four-state text is interpreted as an MSB-first raw value; other unprefixed digits are unsigned decimal. A leading + or - selects signed decimal. Invalid text returns BusValueFormat::Unknown.

Definition at line 355 of file num_formatting.cpp.