Consider this code:
import chisel3.experimental.ChiselEnum
object MyEnum extends ChiselEnum {
val A, B = Value
}
class UseEnumIO extends Module {
val io = IO(new Bundle {
val in = Input(UInt(1.W))
val out = Output(Bool())
})
io.out := MuxLookup(io.in, false.B, Array(
MyEnum.A -> true.B,
MyEnum.B -> true.B
))
}
I need to use an IO port which is supposed to be a ChiselEnum
object in a MuxLookup
.
This is the error message I got from SBT:
[error] found : scala.collection.mutable.WrappedArray[(MyEnum.Type, chisel3.core.Bool)]
while Scala inferred that [S <: chisel3.UInt,T <: chisel3.Data]
I also tried val in = Input(MyEnum.Type)
which gave me a more serious error.
val defaultVersions = Map(
"chisel3" -> "3.2-SNAPSHOT
)
I'm not quite sure why this doesn't work, but the following work-around might help. Try
io.out := MuxLookup(io.in, false.B, Seq(
MyEnum.A.asUInt -> true.B,
MyEnum.B.asUInt -> true.B
))
it seems to work to me. I'll keep looking for a reason that the more obvious simple syntax does not work.