如何在凿子中将 Seq bool 转换为 UInt 值?

How to convert Seq bool to UInt value in chisel?

我想将 Seq[Bool] 转换为 UInt 值。我尝试 asUInt 方法,但它报错 asUInt is not member of IndexedSeq.

例如:

val valid = Wire(Vec(4, Bool()))
val ready = Wire(Vec(4, Bool()))
val fire = (valid zip ready).map{case (vld, rdy) => vld && rdy}
val fire_mask = fire.asUInt()

您应该将 fire 转换为 Chisel Vec 而不是 Scala Vector:

val fire = VecInit((valid zip ready).map{case (vld, rdy) => vld && rdy})