-
Notifications
You must be signed in to change notification settings - Fork 615
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
Add DataMirror.modulePorts #901
Conversation
Also, strictly speaking, |
How does Chisel preserve port ordering in ports/IOs of a module right now? e.g. the order of val io = IO(new Bundle {
val z = Output(Bool())
val a = Output(Bool())
}) vs. val io = IO(new Bundle {
val a = Output(Bool())
val z = Output(Bool())
}) |
|
I mean (correct me if something has changed) the FIRRTL emitter and FIRRTL's Verilog emitter both seem to be respecting order in at least Bundles right now, no? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Order is preserved through to the emitted Verilog so I really think we should preserve it here
So it appears there is not a Scala collection type that preserves ordering (ListMap stores things in reversed order). SeqMap/VectorMap is apparently slated for Scala 2.13, so that might be a future migration path. But for now, do we want this to be a Seq or a Map? |
We could provide the map as an additional function e.g. |
Ok, I'm going to change the API to a Seq return, and since this is experimental we can change the API to VectorMap/SeqMap in the future. Or move this into like DriverUtils. Both of which I'll write into the comments so we don't forget about it. |
And with a Seq API, if users want a map they can always do |
Changed the interface to be Seq[(String, Data)]. Added TODOs for possibly moving from DataMirror to Driver or something, and for changing the return type to SeqMap when it becomes available. Reverses the BlackBox ports order, to make them consistent with the declared order, since ListMaps store elements in reverse. |
This looks good. I should note, in MIDAS we call UserModule.getPorts to get a firrtl port list, from which we reconstruct the module's IO. There's a comment above that member :
+1 For order preserving. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would argue that ListMap does preserve order, reversed is still ordered :)
Anyway, I'm down with Seq
.
Adds
modulePorts(module: BaseModule): Map[String, Data]
toexperimental.DataMirror
. This provides the necessary interfaces to split out Testers2 development (#866) into its own repo.Points which may or may not warrant discussion:
io
contents flattened out in the return here, consistent with the generated component. Note that usingio
directly on a BlackBox can be illegal in some cases, because the top-level object actually does not get emitted (as an artifact of dropping theio_
prefix in the pre-ExtModule/MultiIOModule dats). The only alternative would be to error out if a BlackBox is passed in.Related issue: N/A
Type of change: other enhancement
Impact: API addition (no impact on existing code)
Development Phase: implementation
Release Notes
Add chisel3.experimental.DataMirror.modulePorts(module: BaseModule): Map[String, Data]