3

CHISEL 是否只允许更新位向量的一位?我想做类似的事情:

val x = 12
val slot = UInt(0,width=80)
slot(x) := UInt(1)

但编译器给出以下错误:

ambiguous reference to overloaded definition,
[error] both method := in class Bool of type (src: Chisel.Bits)Unit
[error] and  method := in class UInt of type (src: Chisel.UInt)Unit
[error] match argument types (Chisel.UInt)
[error]     slot(x) := UInt(1)
[error]             ^

在 CHISEL 中是否有更好或更合适的方法来做到这一点?

4

1 回答 1

0

我认为目前没有办法在 Chisel 中更新一点。


已编辑:截至 2014 年 6 月,Chisel 现在允许您访问 a 的各个位Reg(UInt()),但不能访问UInt()电线。


我处理位向量的方法是将它们转换为 Bools/UInts 的 Vec() 并以这种方式单独更新它们。

val x = 12 val slot = Vec(80).fill{Bool(false)} slot(x) := Bool(true) val slot_in_bits = slot.toBits

然后,您可以使用 .toBits 和 .fromBits 在将其视为 Vec() 和将其视为 Bits() 之间移动。

在硬件方面,将位向量视为 bool 的 Vec() 是等效的(不幸的是,就 C++ 中的仿真而言,它并不是超级高效,因为突然每个元素都是它自己的变量)。

于 2014-03-06T01:11:00.910 回答