-
Notifications
You must be signed in to change notification settings - Fork 603
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
[docs] Add Cookbook section on aliased Bundle fields #2444
Conversation
|
||
#### 4. Call `.cloneType` directly | ||
|
||
You can also just call `.cloneType` on your `gen` argument directly. |
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.
One thing I have always been wondering about: Why don't we allow calling chiselTypeOf
in this context?
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.
In Chisel2, the distinction between types and values was super blurry so users often ended up just peppering .cloneType
everywhere to make sure things worked correctly. The idea in Chisel3 was to have a stronger distinction here--binding operators only take types, and chiselTypeOf only converts from hardware values back to types.
That being said, my use of .cloneType
here is back to the Chisel2 style and is admittedly just avoiding this issue.
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.
At a high level, should we rename this article to "how to properly use gen args in your bundles". Also, should we pick one recipe to recommend? As this is a cookbook not exhaustive reference on all the options?
But thanks for writing this, it actually helped me understand why I never quite knew which pattern to use... they are all equivalent!
Probably, but I was trying to avoid taking a position at the moment. I think we should decide on a style to recommend, but it's tricky because the style that leads to this problem is really really common. I think I'd like to merge this example as is since it is useful, but we should think about what style we want to recommend and then go with it. To elaborate a little bit on why I'm avoiding taking a position, here's a little discussion: FieldNote that this is a long running option and there was an old proposal to add class MyBundle[T <: Data](gen: T) extends Bundle {
val foo = UInt(8.W)
val bar = UInt(32.W)
val fizz = gen
val buzz = Vec(2, UInt(8.W))
} If you want to add another field to class MyBundle2[T <: Data](gen: T) extends Bundle {
val foo = Field(UInt(8.W))
val bar = Field(UInt(32.W))
val fizz = Field(gen)
val buzz = Field(Vec(2, UInt(8.W)))
val other = Field(gen)
} People understandably find this a bit annoying. Also note that this same problem applies to the current legal approach of just using Thunkification
|
7332cdc
to
561a92c
Compare
(cherry picked from commit d4dd211)
* Add renamemap.MutableRenameMap which includes these methods without deprecation * Deprecate Stringly typed RenameMap APIs which were accidentally undeprecated a while ago Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
See post mdoc rendered markdown here.
Contributor Checklist
docs/src
?Type of Improvement
API Impact
No impact
Backend Code Generation Impact
No impact
Desired Merge Strategy
Release Notes
Reviewer Checklist (only modified by reviewer)
3.4.x
, [small] API extension:3.5.x
, API modification or big change:3.6.0
)?Please Merge
?