slang::netlist::NetlistGraph class

Represent the netlist connectivity of an elaborated design.

Base classes

template<class NodeType, class EdgeType>
class DirectedGraph<NetlistNode, NetlistEdge>

Constructors, destructors, conversion operators

NetlistGraph()

Public functions

void finalize()
auto lookup(std::string_view name) const -> NetlistNode*

Protected functions

void processPendingRvalues()
void mergeDrivers(SymbolSlotMap const& procSymbolToSlot, std::vector<SymbolDriverMap> const& procDriverMap, ast::EdgeKind edgeKind = ast::EdgeKind::None)
auto handleLvalue(const ast::ValueSymbol& symbol, std::pair<uint32_t, uint32_t> bounds, NetlistNode* node) -> auto
void addPort(ast::PortSymbol const& symbol)
Create a port node in the netlist.
auto getPort(ast::Symbol const* symbol) -> std::optional<NetlistNode*>
void connectInputPort(ast::ValueSymbol const& symbol, std::pair<uint64_t, uint64_t> bounds)

Function documentation

NetlistNode* slang::netlist::NetlistGraph::lookup(std::string_view name) const

Parameters
name The hierarchical name of the node.
Returns A pointer to the node if found, or nullptr if not found.

Lookup a node in the graph by its hierarchical name.

void slang::netlist::NetlistGraph::processPendingRvalues() protected

Process pending R-values after the main AST traversal.

This connects the pending R-values to their respective nodes in the netlist graph. This is necessary to ensure that all drivers are processed before handling R-values, as they may depend on the drivers being present in the graph. This method should be called after the main AST traversal is complete.

void slang::netlist::NetlistGraph::mergeDrivers(SymbolSlotMap const& procSymbolToSlot, std::vector<SymbolDriverMap> const& procDriverMap, ast::EdgeKind edgeKind = ast::EdgeKind::None) protected

Parameters
procSymbolToSlot Mapping from symbols to slot indices.
procDriverMap Mapping from ranges to graph nodes.
edgeKind The kind of edge that triggers the drivers.

Merge symbol drivers from a procedural data flow analysis.

auto slang::netlist::NetlistGraph::handleLvalue(const ast::ValueSymbol& symbol, std::pair<uint32_t, uint32_t> bounds, NetlistNode* node) protected

Parameters
symbol The L-value symbol.
bounds The range of the symbol that is being assigned to.
node The netlist graph node that is the operation driving the L-value.

Handle an L-value that is encountered during netlist construction by updating the global driver map.

std::optional<NetlistNode*> slang::netlist::NetlistGraph::getPort(ast::Symbol const* symbol) protected

Lookup a port netlist node by the internal symbol the port is connected to.

void slang::netlist::NetlistGraph::connectInputPort(ast::ValueSymbol const& symbol, std::pair<uint64_t, uint64_t> bounds) protected

Connect an input port by tracking that it is a driver for the internal symbol it is bound to.