-
Notifications
You must be signed in to change notification settings - Fork 573
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
Enum deficiencies #373
Comments
Re: point 2: I'd favor creating Enum(n) which implicitly does the same thing as Enum(UInt(log2Ceil(n)), n) currently does. You could then deprecate Enum(nodeType, n) in new-chisel3. I agree, it's not really obvious what an SInt enum would do, since there's no facility to start at anything besides 0. (In C, having signed enums is occasionally useful, because you're allowed to set the start number to something negative. I don't see a compelling reason to follow their lead in this case, though.) |
Re: the other points: despite its downsides, it's still useful. |
Yes, we definitely do need to keep the current Enum (perhaps with nodeType deprecated, and assertion-checked to be a UInt so we can remove Bits.fromInt), but it would be interesting to think of what a more featured enum system would look like. |
So in the attempt to deprecate old style enums I came across some more issues:
Thoughts? |
Get rid of some cruft exposed in #373 This also allows Bits.fromtInt(...) to be removed. Yay! All old APIs (with some new restrictions, rocket still works fine) are preserved without deprecation in Chisel._, aside from the non-compile-time-checkable Map[] enum constructor which probably should have been deprecated during chisel2. The Map[] enums have been removed from chisel3._ without deprecation. The new restriction is that nodeType (legacy API) may only be of UInt type with unspecified width. Note that Bits() creates a UInt, and if you can't control the enum values, it makes little sense to specify a bitwidth.
I have to say that as a new Chisel user, the first point, Actually I'm still not sure what the point is vs using a non-Chisel Scala Enum (however you like doing that) since the Enum-ness is not reflected in the actual emitted Verilog. If you're going to go through the trouble of creating a special Chisel Enum, why not emit the Verilog equivalent so that the Verilog would have meaningful names/values in them (something which most Waveform viewers can pick up on). I wish that there was a way to not throw this Verilog feature away. |
So right now even Chisel doesn't know the names you've given to the enum variables, this is because of the way it's structured. It seems Scala Enumerations are written completely in Scala (though using some fancy reflection method) and it should be possible to get names from those, so a more full-featured version of Chisel enums can be written like that. There's also another style of doing enums in Scala which involves defining the type as a trait and the values as case objects extending that trait. Macros or reflection can then be used to get all the enumeration values. This style allows greater flexibility at the expense of more lines of code (it's typical to define one case object per line). One of those two above patterns could be adapted to support Chisel-specific functionality like enum type bitwidth, UInt literal conversion, and maybe name propagation. |
Adding the names to the output seems really cool/useful, but I think that FIRRTL would most likely not preserve this. (constant-prop and whatnot) |
In the ideal world enums should preserve their names down to HDL code. At least in VHDL you can have symbolic names and let the synthesize tool decide which encoding is most efficient (e.g., simple binary or one-hot).
Cheers,
Martin
… On 29 Nov, 2016, at 21:22, Colin Schmidt ***@***.***> wrote:
Adding the names to the output seems really cool/useful, but I think that FIRRTL would most likely not preserve this. (constant-prop and whatnot)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#373 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAntmK_tZy4fKrlXTaqLwXoVqGBpKMsIks5rDIlpgaJpZM4K16ku>.
|
One old issue with this, the current Chisel |
A minor issue with the current |
Resolved by Strong Enums |
Bumps [chisel3](https://github.com/freechipsproject/chisel3) from `41d0d4c` to `8fe8764`. - [Release notes](https://github.com/freechipsproject/chisel3/releases) - [Commits](41d0d4c...8fe8764) --- updated-dependencies: - dependency-name: chisel3 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Bits.fromInt
method which isn't exposed or used elsewhere.Thoughts?
The text was updated successfully, but these errors were encountered: