-
Notifications
You must be signed in to change notification settings - Fork 89
Initial implementation of GateGraph, an alternative PyRTL logic representation
#470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…resentation: `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.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## development #470 +/- ##
=============================================
+ Coverage 91.3% 91.3% +0.1%
=============================================
Files 24 25 +1
Lines 6786 6967 +181
=============================================
+ Hits 6193 6359 +166
- Misses 593 608 +15 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
* `dest_fanout` -> `dests` * `dest_name` -> `name` * `dest_bitwidth` -> `bitwidth` * `dest_is_output` -> `is_output Add documentation on the differences between `LogicNet.dests` and `Gate.dests`. Minor other documentation improvements.
Member
Author
|
I'm planning to merge this pull request tomorrow, so let me know soon if you have comments. |
…s to. I'd rather not have this bridge between the two representations, if possible. It should (eventually) be possible to do everything with only the new `Gate` representation. This also adds some more documentation pointers to `GateGraph`.
…'s easier to perform unions and intersections. Add more useful sets of `Gates` like `inputs`, `registers`, etc.
…mem_writes`. Also improve documentation: - Explain why `Gate` is implemented separately, rather than as a part of `WireVector`. - Don't publish documentation for `Gate.__init__`, as it should only be called by `GateGraph`. - Add more examples.
…es between `LogicNet.dests` and `Gate.dests`.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
GateGraphis an alternative PyRTL logic representation that attempts to address several issues with PyRTL's standardWireVectorandLogicNetrepresentation:A
GateGraphcan be directly traversed, without the help of side data structures like thewire_src_dictandwire_sink_dictreturned bynet_connections.GateGraphbuilds a graph where each node is aGate, and the edges are all references to otherGates. By using only one node type, rather than two (WireVector,LogicNet), it becomes easier to work with the nodes in aGateGraph, because every node is the same type, with the same interface.GateGraphdecouples the user interface and the internal representation. Users directly instantiateWireVectorsas they build circuits. A user that is only building circuits should never interact with aGateGraphor aGate. Users should only interact withGateGraphwhen they need reflection, which typically happens when writing an analysis or optimization pass.Another advantage of this decoupling is that
Gatedoes not need to supportWireVector's quality-of-life features for users, like inferring bitwidth from assignment.I'm migrating
output_to_verilogto use thisGateGraphrepresentation in a separate change.