Commit 5d5cdea
committed
Initial implementation of
`GateGraph` attempts to address several issues with PyRTL's standard
`WireVector` and `LogicNet` representation:
1. A `GateGraph` can be directly traversed, without the help of side data
structures like the `wire_src_dict` and `wire_sink_dict` returned by
`net_connections`.
2. `GateGraph` builds a graph where each node is a `Gate`, and the edges are
all references to other `Gates`. By using only one node type, rather than
two (`WireVector`, `LogicNet`), it becomes easier to work with the nodes in
a `GateGraph`, because every node is the same type, with the same interface.
3. `GateGraph` decouples the user interface and the internal representation.
Users directly instantiate `WireVectors` as they build circuits. A user that
is only building circuits should never interact with a `GateGraph` or a
`Gate`. Users should only interact with `GateGraph` when they need
reflection, which typically happens when writing an analysis or optimization
pass.
Another advantage of this decoupling is that `Gate` does not need to support
`WireVector`'s quality-of-life features for users, like inferring bitwidth
from assignment.GateGraph, an alternative PyRTL logic representation:1 parent 370aa4b commit 5d5cdea
4 files changed
Lines changed: 993 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
160 | 162 | | |
161 | 163 | | |
162 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
163 | 168 | | |
164 | 169 | | |
165 | 170 | | |
| |||
0 commit comments