|
SILICON
|
Module-instantiation dependency graph for a Yosys JSON design. More...
#include <netlist.hpp>
Classes | |
| struct | VertexProperty |
| Per-vertex payload holding the declared module name. More... | |
Public Types | |
| using | ModuleNameList = std::vector<std::string> |
| List of module names. | |
| using | Graph |
| Boost graph type: set out-edges, vector vertices, directed. | |
| using | Vertex = boost::graph_traits<Graph>::vertex_descriptor |
| Boost vertex descriptor (an integer index under vecS). | |
| using | NameToVertex |
| O(1) index mapping a module name to its graph vertex. | |
Public Member Functions | |
| void | addModule (std::string_view moduleName) |
| Ensures a module vertex exists, creating it if necessary. | |
| void | addDependency (std::string_view from, std::string_view to) |
Records that from instantiates to. | |
| ModuleNameList | dependenciesOf (std::string_view moduleName) const |
Returns the sorted, unique modules moduleName instantiates. | |
| ModuleNameList | dependencyOrder (const ModuleNameList &roots) const |
Returns the unique dependency closure of roots in dependency-first order. | |
| ModuleNameList | modules () const |
| Returns every declared module name. | |
| bool | containsModule (std::string_view moduleName) const |
| Checks whether a module vertex is present in the graph. | |
| const Graph & | boost () const |
| Read-only access to the underlying Boost graph. | |
Private Member Functions | |
| std::optional< Vertex > | findVertex (std::string_view moduleName) const |
| Vertex | ensureVertex (std::string_view moduleName) |
| Ensures a module vertex exists in this graph (O(1)). | |
| void | rebuildNameIndex () |
| Rebuilds nameToVertex from the current graph. | |
Private Attributes | |
| Graph | graph |
| The dependency graph itself. | |
| NameToVertex | nameToVertex |
| Name-to-vertex index kept in sync with graph. | |
Module-instantiation dependency graph for a Yosys JSON design.
Vertices are declared module names. Edges point from an instantiating module to the declared modules it instantiates; primitive and external cell types are not included. The graph is derived from a Yosys write_json document and is never serialized.
The graph uses boost::vecS for its vertex container, which means vertex descriptors are integer indices. As a consequence, removing a vertex reindexes every subsequent vertex, so the nameToVertex index must be rebuilt after a removal. Name lookup remains average O(1) thanks to the std::unordered_map index.
Definition at line 58 of file netlist.hpp.
| using Graph |
Boost graph type: set out-edges, vector vertices, directed.
Definition at line 69 of file netlist.hpp.
| using ModuleNameList = std::vector<std::string> |
List of module names.
Definition at line 61 of file netlist.hpp.
| using NameToVertex |
O(1) index mapping a module name to its graph vertex.
Definition at line 75 of file netlist.hpp.
Boost vertex descriptor (an integer index under vecS).
Definition at line 72 of file netlist.hpp.
| void addDependency | ( | std::string_view | from, |
| std::string_view | to ) |
Records that from instantiates to.
Both modules are ensured as vertices first. Duplicate edges are ignored, so dependencies remain unique.
| from | Instantiating module name. |
| to | Instantiated declared module name. |
Definition at line 1653 of file deserialization.cpp.
| void addModule | ( | std::string_view | moduleName | ) |
Ensures a module vertex exists, creating it if necessary.
| moduleName | Declared module name to register. |
Definition at line 1648 of file deserialization.cpp.
|
inlinenodiscard |
Read-only access to the underlying Boost graph.
Definition at line 133 of file netlist.hpp.
|
nodiscard |
Checks whether a module vertex is present in the graph.
| moduleName | Declared module name to look up. |
Definition at line 1733 of file deserialization.cpp.
|
nodiscard |
Returns the sorted, unique modules moduleName instantiates.
| moduleName | Declared module name to query. |
Definition at line 1710 of file deserialization.cpp.
|
nodiscard |
Returns the unique dependency closure of roots in dependency-first order.
Explicit roots are included in the result. Shared dependencies occur once, and otherwise-independent names are ordered deterministically.
| std::invalid_argument | If a requested root is unknown. |
| std::runtime_error | If the selected hierarchy is recursive. |
Definition at line 1662 of file deserialization.cpp.
|
private |
Ensures a module vertex exists in this graph (O(1)).
| moduleName | Declared module name. |
Definition at line 1748 of file deserialization.cpp.
|
nodiscardprivate |
Definition at line 1739 of file deserialization.cpp.
|
nodiscard |
Returns every declared module name.
Definition at line 1723 of file deserialization.cpp.
|
private |
Rebuilds nameToVertex from the current graph.
Required after remove_vertex because vecS reindexes descriptors.
Definition at line 1757 of file deserialization.cpp.
|
private |
The dependency graph itself.
Definition at line 137 of file netlist.hpp.
|
private |
Name-to-vertex index kept in sync with graph.
Definition at line 139 of file netlist.hpp.