scala - 使用 MixedVec 在凿子中使用动态参数创建 IO 包
问题描述
我的代码如下
class HWBLOCK(dummy_val : Int)(p : Parameters) extends Bundle{
private val temp = Reg(Vec(dummy_val, UInt(4.W)))
def set_temp(Index : Int, my_val : Int){ temp(Index) := my_val.U}
def get_temp(Index : Int) : UInt = { return temp(Index) }
override def cloneType : this.type = (new HWBLOCK(stageNumber)(p)).asInstanceOf[this.type]
}
class MyMath(p : Parameters) extends Module{
val para = p(MyBlockKey).para
val io = IO(new Bundle{
val myval = Input(MixedVec((1 until para) map {i => new HWBLOCK(i)(p)}))
})
}
现在,每当我尝试这个时,来自 peekpoketester
poke(dut.io.myval(1).set_temp(1,1))
我收到这个错误
overloaded method value poke with alternatives:
[error] (signal: chisel3.Aggregate,value: IndexedSeq[BigInt])Unit <and>
[error] (signal: chisel3.Bundle,map: Map[String,BigInt])Unit <and>
[error] [T <: chisel3.Element](signal: T, value: Long)(implicit evidence$10: chisel3.iotesters.Pokeable[T])Unit <and>
[error] [T <: chisel3.Element](signal: T, value: Int)(implicit evidence$9: chisel3.iotesters.Pokeable[T])Unit <and>
[error] [T <: chisel3.Element](signal: T, value: BigInt)(implicit evidence$8: chisel3.iotesters.Pokeable[T])Unit <and>
[error] (path: String,value: Long)Unit <and>
[error] (path: String,value: Int)Unit <and>
[error] (path: String,value: BigInt)Unit
[error] cannot be applied to (Unit)
[error] poke(dut.io.myval(1).set_temp(1,1))
现在我有两个问题:
- 我能否以某种方式避免在 HWBLOCK 中使用私有 val,这样我就不必使用函数来设置和获取值?我使用私人的原因是因为这个
唯一需要注意的是,如果您将数据类型的东西作为“生成器”参数传递,在这种情况下,您应该将其设为私有 val。github.com/freechipsproject/chisel3/wiki/Bundles-and-Vecs
- 如果我必须使用 private 有没有办法可以使用 peekpoketesters 访问 HWBLOCK 类中的方法。
解决方案
chisel-testers 和 chiseltest 中的 peek/poke 测试器都将模块视为黑匣子,并且获取数据的唯一方法是通过顶级 IO。在我看来,您正试图绕过该限制。我不认为有一种方法会奏效。如果您需要在内部硬件块中设置一些寄存器,则需要提供 IO 来设置和获取它。如果这是出于一次性诊断目的,您可以考虑使用BoringUtils授予访问权限。
您是否正在尝试通过在捆绑包中添加寄存器来解决特定的用例?您应该考虑将 HWBLOCK 重构为一个模块,并使用 scala 的强大功能以方便的方式连接每个 HWBLOCK 的 IO。
推荐阅读
- javascript - 是否可以使 Window.Print() 方法使用其背景颜色打印突出显示的文本?
- python - python 和 conda 路径不相同,并出现 ModuleNotFoundError: No module named 'torch' 错误
- r - 从稀疏矩阵转换为密集矩阵而不丢失暗名?
- graphql - GraphQL 查询 DynamoDB 表的问题
- rabbitmq - Clickhouse 和 RabbitMQ 的连接问题
- r - 如何将矩阵数据输入brms公式?
- events - 是否可以从 U 盘查看事件
- python - 如何将 python 文件中的(数据)列表导出到单独的外部文件中?
- bigbluebutton - 在 BigBlueButton 中禁用结束会议选项
- multithreading - 如何使用线程在 rust 中同时运行此代码?