凿子内存写掩码

Chisel memory write mask

我正在尝试为 chisel 3 中的 Mem 使用写掩码,如下所示。

chipMem.write(data_idx, wdata, wmask)

我正在生成 wmask(写掩码)如下,

val wmask = write_mask.toBools

因为 write_mask 是一个 UInt 并且写入函数需要一个布尔序列作为写入掩码参数。但是,这会出现以下错误。

Cannot prove that chisel3.core.UInt <:< chisel3.core.Vec[_].
[error]              chipMem.write(data_idx, wdata, wmask)
[error]                           ^
[error] one error found

我真的不明白错误信息说的是什么。是不是我创建wmask的方式有问题?

编译器抱怨它无法证明 Chisel UInt 是 Chisel Vec 的子类型(因为它不是)。

查看 documentation for Mem.write,它注意到 "this is only allowed if the memory's element data type is a Vec." 这可能措辞更好一些,但基本上 Chisel 不假设写入掩码如何对应于数据。如果你想使用写掩码,你的 Mem 的数据类型必须 是一个 Vec。另请注意,写掩码 Vec 必须具有与数据类型 Vec 相同的条目数。