-
Notifications
You must be signed in to change notification settings - Fork 602
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
Vec literals #849
Comments
I think unifying literal constructor and init is something that needs more thought. VecInit is a useful shorthand for packing elements into a Vec, but can't be used in Bundle literal constructors. Bundle literal constructors also can't take non-literal types (like VecInit results), but can be unpacked into Scala-land data (used for testers2). I think there are use case arguments for both, though what the API looks like should be up for debate. |
Re: API: Another option is to avoid introducing a new API and instead hide this improvement inside Chisel. This could be done when VecInit's args are all literals, and when the resulting wire is never assigned to. This might not be practical, for implementation reasons, but it's def. worth considering. |
Writing up discussion from chisel-dev two weeks back: Vector literals could have two APIs, one analogous to Vec.Lit(0.U, 1.U, 2.U, 3.U, …)
val w = Wire(Vec(n, UInt(3.W)))
w := Vec.Lit(0.U, 1.U, 2.U, 3.U, …)
(0 until n).map(_.U).toVecLit These might need to support some way to specify a base type, eg if you wanted a Vec of SInts. One proposal is, analogous to how we specify widths: (0 until n).map(_.U).toVecLit(SInt(3.W)) But the Vec(6, SInt(3.W)).Lit(0.U, 1.U, 2.U, 3.U, …) though this overspecifies the Vec since the length is specified both explicitly in the |
I prefer the last, and the over-specification sounds like an error check to me. |
I'd disagree. I can't think of any language off the top of my head which requires over-specification like that (both explicitly the number of elements, and implicitly as the size of the argument list). Even C allows something like |
Having to redundantly type the number of elements is hokey. The old Enums have that property, and it's not a feature. |
Any updates on this? |
As far as I know, no one is working on it. It would be nice though. |
Notes from Meeting:
If
How to “naturally” construct
Relationship of
Should
Need to materialize a concrete object of type T prevents us from materializing a concrete object without sample_element constructor!!!!
What if I call func with
What we like to support
|
It may make sense to add a notion of Vec Literals after the backend supports vector expressions. See FIRRTL#929 |
Are there any updates on this feature? Would be very nice to use BundleLiterals with bundles containing vectors in Chisel-Test |
There is a PR 🙂 : #1793 |
Implemented in #1834 |
Now that a new literal framework is in place after #820, would it make sense to create a mechanism (possibly by co-opting
VecInit
or by creating aVecLit
constructor) to create Vec literals? The current closest equivalent,VecInit,
still creates a wire and assigns the literals to it the old way we worked around lack of bundle literals.Type of issue: feature request
Impact: no functional change | API addition (no impact on existing code)
Development Phase: request | proposal
The text was updated successfully, but these errors were encountered: