Chisel3: Vec indexWhere expected Bool, actual Any
Chisel3: Vec indexWhere expected Bool, actual Any
在 Chisel 中,我有一个 Bools 的 Vec 进入一个模块。我想知道第一个出现的 False 的索引。
为了获得这个,我尝试使用以下方法:
val faultIndex = Wire(UInt)
faultIndex := comparison.indexWhere(x:Bool => x === false.B)
当我输入这个时,突出显示了一个错误:
Unspecified value parameters: from: Int
Type mismatch, expected Bool => Bool, actual: Bool => Any
Type mismatch, expected Bool => Boolean, actual: Bool => Any
Cannot resolve symbol x
Cannot resolve symbol x
该功能的正确使用方法是什么?
这里有 2 个小语法问题:
val faultIndex = Wire(UInt())
注意 UInt
之后的 ()
。您可以将此视为构造一个新类型对象,而不是指向名为 UInt
.
的静态对象
有几种表达方式 indexWhere
:
faultIndex := comparison.indexWhere((x: Bool) => x === false.B) // Note parentheses
// or
faultIndex := comparison.indexWhere(x => x === false.B) // Type is inferred
// or
faultIndex := comparison.indexWhere(_ === false.B) // underscore shorthand
// alternatively
faultIndex := comparison.indexWhere(x => !x) // !x is equivalent to x === false.B
// or
faultIndex := comparison.indexWhere(!_) // More underscore shorthand
在 Chisel 中,我有一个 Bools 的 Vec 进入一个模块。我想知道第一个出现的 False 的索引。
为了获得这个,我尝试使用以下方法:
val faultIndex = Wire(UInt)
faultIndex := comparison.indexWhere(x:Bool => x === false.B)
当我输入这个时,突出显示了一个错误:
Unspecified value parameters: from: Int
Type mismatch, expected Bool => Bool, actual: Bool => Any
Type mismatch, expected Bool => Boolean, actual: Bool => Any
Cannot resolve symbol x
Cannot resolve symbol x
该功能的正确使用方法是什么?
这里有 2 个小语法问题:
val faultIndex = Wire(UInt())
注意 UInt
之后的 ()
。您可以将此视为构造一个新类型对象,而不是指向名为 UInt
.
有几种表达方式 indexWhere
:
faultIndex := comparison.indexWhere((x: Bool) => x === false.B) // Note parentheses
// or
faultIndex := comparison.indexWhere(x => x === false.B) // Type is inferred
// or
faultIndex := comparison.indexWhere(_ === false.B) // underscore shorthand
// alternatively
faultIndex := comparison.indexWhere(x => !x) // !x is equivalent to x === false.B
// or
faultIndex := comparison.indexWhere(!_) // More underscore shorthand