问题描述
我的代码如下
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))
现在我有2个问题:
唯一的警告是如果您要传递数据类型为 “ generator”参数,在这种情况下,应将其设为私有val。 github.com/freechipsproject/chisel3/wiki/Bundles-and-Vecs
- 如果必须使用private,则可以使用peekpoketesters访问HWBLOCK类中的方法。
解决方法
凿子测试器和chiseltest中的peek / poke测试器都将模块视为黑匣子,获取和输入数据的唯一方法是通过顶级IO。在我看来,您似乎正在努力克服这一限制。我认为没有一种方法会奏效。如果需要在内部硬件模块中设置一些寄存器,则需要提供IO来进行设置和获取。如果这只是出于诊断目的,则可以考虑使用BoringUtils进行访问。
您是否正在尝试通过在捆绑软件中添加寄存器来解决特定的用例?您应该考虑将HWBLOCK重构为一个模块,并使用scala的功能以方便的方式连接每个HWBLOCK的IO。