Reputation: 149
As title, I want to covert Vec(Bool()) into UInt value.
For example
class MyModule extends Module {
val io = IO(new Bundle {
val in_data = Input (Vec (3, Bool() )
val result = Output(UInt(5.W))
})
//how can I convert io.in_data to Uint and the assign to io.result
//I will get io.result = 7 when in_data(1, 1, 1)
}
Upvotes: 3
Views: 2404
Reputation: 6064
You can use .asUInt
to cast a Vec to Bools (or any Chisel Data) to UInt.
If you need to cast from UInt back to Vec or Bools you can use .asBools
Please see https://www.chisel-lang.org/chisel3/docs/cookbooks/cookbook.html
Upvotes: 8