gpt4 book ai didi

chisel - 更新位向量的单个位

转载 作者:行者123 更新时间:2023-12-05 07:59:13 29 4
gpt4 key购买 nike

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 中是否有更好或更合适的方法来做到这一点?

最佳答案

我认为目前在 Chisel 中没有更新任何位的方法。


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


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

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

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

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

关于chisel - 更新位向量的单个位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22175155/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com