Bulk connect common sub-parts of Bundles/Records
See original GitHub issueConsider the following scenario where mix-ins are used to add fields to compose a Bundle:
trait Common extends Bundle {
val c0 = Bool()
val c1 = Bool()
}
trait A extends Bundle with Common {
val aa = UInt(10.W)
}
trait B extends Bundle with Common /* with Foo with Bar with ... */ {
val bb = UInt(10.W)
}
We can now use these as I/Os for Bundles, especially for BlackBoxes:
// A BlackBox that has the following I/Os
// c0, c1, aa
class MyBBoxA extends BlackBox {
val io = IO(Input(new A))
}
// A BlackBox that has the following I/Os
// c0, c1, bb
class MyBBoxB extends BlackBox {
val io = IO(Output(new B))
}
The problem is that with Chisel3 semantics there is no DRY way to connect the common elements:
class MyTest extends Module {
val io = IO(new Bundle {})
val mod1 = Module(new MyBBoxA)
val mod2 = Module(new MyBBoxB)
mod1.io <> mod2.io // <-- doesn't work in Chisel3 semantics
// Non-DRY code, want to avoid
mod1.io.c0 <> mod2.io.c0
mod1.io.c1 <> mod2.io.c1
}
Using composition doesn’t work since it changes the I/Os to c_c0, c_c1, bb:
class B_bad extends Bundle {
val c = new Common
val bb = UInt(10.W)
}
Option 1: Chisel2-style “unsafe bulk connect”. I think we want to avoid that if possible.
Option 2: some sort of “connect as parent” API. I think we can do this in a type-safe way especially if we know the common subtype:
a.asRecordView(Common) <> b.asRecordView(Common)
commonConnect(a, b, Common)
??a.commonConnect(b, Common)
??
Issue Analytics
- State:
- Created 6 years ago
- Comments:17 (14 by maintainers)
Top Results From Across the Web
Bulk connect common sub-parts of Bundles/Records #661
What I want is to search and connect the pairs only within the left side, eg. class ax extends Bundle { val a0...
Read more >Deleting data records in bulk - Pega Documentation
To remove data records more quickly, make your changes in bulk by importing a .csv file.
Read more >Packing a Records Center Storage Box
Boxes can be purchased from the State Records Center in bundles of 25. Contact the Records Center at (225) 922-1224 to verify the...
Read more >NetSuite Applications Suite - Installing a Bundle
Viewing the Stock Ledger · Inventory Level Assessments with Reports · How Kits and Kit Parts Affect Quantities Displayed in Reports · Physical...
Read more >FOLDS & DIMENSIONS
Finished Job Size. 3 11/16. 8 1/2. X. 3 11/16. 3 11/16. Fold. Fold. 8.5” x 11” Letter Fold (6 panel, C-fold). 3...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This isn’t necessarily fixed in the way everyone wanted, but
.viewAsSuperType
andDataView
(new in Chisel 3.5.0) more generally enables such connections in a much more elegant way than before. I’m closing this issue and suggest everyone look at the documentation: https://www.chisel-lang.org/chisel3/docs/cookbooks/dataview.html#how-do-i-connect-a-subset-of-bundle-fields.Looks like someone beat me to the punch. Here is a better formatted version of my post
The Wildcard Bundle Assignment
<*>
When using the Bundle Assignment, all elements must match between the two objects. What I would really enjoy is a wildcard assignment that allows for bundles to be split and joined, without needing to write out every signal. This helps a ton with managing a datapath where all of the signals can be wrapped in a bundle, then easily passed from one module to the next, similar to the Verilog
(.*)
. Additionally the.*
assignment could be done by a syntax like somoduel_i.io <*> _
which could assign the bundle to the variables in the current context.Currently when assigning two bundles that don’t match, you get the following
I think that it would be better to have an explicit operator to prevent users from accidentally missing signals, but it would be nice if people wanted to “live on the edge” and use wildcards to shorten laborious assignments.