chipsalliance / chipsalliance/chisel
Provide ChiselEnum Value for OneHot encoding
- Dominant language
- Scala
- Stars
- 4.8k
- Forks
- 658
- Avg merge
- 18h 59m
- Merged PRs (30d)
- 14
Description
**Type of issue**: Feature Request
**Is your feature request related to a problem? Please describe.**
When describing a normal enum it is relatitly easy to do so:
```scala
object MyEnum extends ChiselEnum {
val A, B, C, D, E, F, G = Value
}
```
but when trying to have it a one-hot encoding it gets complicated fast
```scala
object MyEnum1H extends ChiselEnum {
val A = Value(1.U)
val B = Value(2.U)
val C = Value(4.U)
// ...
}
```
It is very error prone and verbose. Moving or reordering the items is also a hell.
Maybe there's a clever scala trick to do this easly, but my scala knowlodge is limited.
**Describe the solution you'd like**
I want to see something like one of the two Solutions
```scala
object MyEnum1H_A extends ChiselEnum {
val A, B, C, D = Value1H
}
object MyEnum1H_B extends ChiselEnum {
val A, B, C, D = Value(flavor = OneHot)
}
```
**Describe alternatives you've considered**
Describing each and every value seperatly is possible, but error prone and very tedious.
**What is the use case for implementing this feature?**
Using it with a Mux1H is the obvious use-case for this feature.
Contributor guide
Assessment
This issue has not been assessed yet.