-
Notifications
You must be signed in to change notification settings - Fork 2
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
Register Widths #10
Comments
I'm hit by something which seems related without doing anything fancy and find it seriously annoying. In my case val s = RegNext(~y & z)
val t = x ^ s
(t).asBools() // <--- results in While this works: val s = Reg(UInt(5.W))
s:= ~y & z
val t = x ^ s
(t).asBools() and removing the Reg works too: ( x ^ (~y & z)).asBools() |
Propagating the width from the RegNext is harder than it seems, because later assignments can increase the width. For example,
is legal, and |
This could get into the realm of "Chisel philosophy :)" and beyond my understanding, but as a designer I'd really like the second assignment to error out if the width is larger than what's explicitly set at instantiation. |
I think the real issue here is that the For I think this is more an example of there being two different, desirable behaviors with In the short term, |
The automatic width extension of Chisel tricked me also sometimes (e.g., had a 64-bit register file for some time in my 32-bit processor). So I personal am not super happy about it and lean slightly also towards getting an error. But I assume many people like it, so it is not a candidate for chisel3.strict.
Martin
|
Dev meeting result: this is a complicated issue that touches on identifying the correct behavior of widths. E.g, when are widths set, when are widths inferred. Also, any change to this will result in a lot of code silently breaking. Therefore, this is better handled via an RFC on the full discussion of widths. I will transfer this to the RFCs repo and close this there once an RFC is written. |
The asymmetry of how
Reg
,RegNext
, andRegInit
set their widths can lead to unexpected behavior.h/t @antonblanchard
Type of issue: bug report | feature request | other enhancement
Impact: API modification
Development Phase: request
Other information
There's an old PR referencing and documenting some of this behavior: chipsalliance/chisel#455
If the current behavior is a bug, please provide the steps to reproduce the problem:
Consider the following example. While
foo
,bar
, andbaz
have almost identical construction,foo
has an unset width,bar
was a width of 8, andbaz
is a bundle with an internal signal of width8
.This results in the following FIRRTL:
To be very concrete, I have implicit classes for doing automatic conversion to bits, words, etc. (i.e.,
(Bits) => Vec[UInt]
). These rely on having widths known. Using these methods onfoo
will cause the implicit class methods to error out complaining that they can't be used on something that has an unknown width. However, they work withbar
. This is unintuitive behavior as it would seem thatfoo
andbar
are identical constructions.I do realize that
RegNext(0.U)
is probably the reason why this exists the way it does.What is the current behavior?
The width of a
RegNext
is always unset when given a subtype ofBits
.What is the expected behavior?
The width of a
RegNext
should be set to the type of whatever is next.Please tell us about your environment:
What is the use case for changing the behavior?
This clarifies unintuitive behavior and unifies behavior for
RegNext
when given different types.The text was updated successfully, but these errors were encountered: