不能戳MixedVec

时间:2019-10-14 10:28:59

标签: scala hdl chisel

我在模块接口中声明了MixedVec:

class WbInterconOneMaster(val awbm: WbMaster,
                          val awbs: Seq[WbSlave]) extends Module {
    val io = IO(new Bundle{
      val wbm = Flipped(new WbMaster(awbm.dwidth, awbm.awidth))
      val wbs = MixedVec(awbs.map{i => Flipped(new WbSlave(i.dwidth, i.awidth, i.iname))})
    })

该编译正确,并且Verilog正确生成。但是我不能像这样戳信号:

  for(wbs <- dut.io.wbs) {
    poke(wbs.ack_o, 0)
  }

在执行时(验证程序后端)收到此错误:

[info]   java.util.NoSuchElementException: head of empty list
[info]   at scala.collection.immutable.Nil$.head(List.scala:420)
[info]   at scala.collection.immutable.Nil$.head(List.scala:417)
[info]   at scala.collection.mutable.Stack.top(Stack.scala:132)
[info]   at chisel3.internal.naming.NamingStack.pop_return_context(Namer.scala:133)
[info]   at chisel3.util.MixedVec.length(MixedVec.scala:81)
[info]   at scala.collection.IndexedSeqLike$class.iterator(IndexedSeqLike.scala:90)
[info]   at chisel3.util.MixedVec.iterator(MixedVec.scala:81)
[info]   at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
[info]   at chisel3.util.MixedVec.foreach(MixedVec.scala:81)
[info]   at wbplumbing.TestWbInterconDualSlave.<init>(testwbplumbing.scala:61)

请注意,凿子版本3.1.6已在as_ref上提出了此问题,但已将其标记为已关闭。我正在使用3.1.8版本,但似乎已经坏了。

[编辑]

我用凿子3.2.0和iotester 1.3.0升级了项目:

libraryDependencies += "edu.berkeley.cs" %% "chisel3" % "3.2.0"
libraryDependencies += "edu.berkeley.cs" %% "chisel-iotesters" % "1.3.0"

当我取消注释该行时,我仍然有一个错误:

  for(wbs <- dut.io.wbs) {
    poke(wbs.ack_o, 0)
  }

(如果我将这些行保留为注释,那行得通)

但是堆栈跟踪是不同的:

[info] - should read and write wishbone value on two slaves *** FAILED ***
[info]   chisel3.internal.ChiselException: Error: Not in a RawModule. Likely cause: Missed Module() wrap, bare chisel API call, or attempting to construct hardware inside a BlackBox.
[info]   at chisel3.internal.throwException$.apply(Error.scala:42)
[info]   at chisel3.internal.Builder$.referenceUserModule(Builder.scala:287)
[info]   at chisel3.Data.connect(Data.scala:384)
[info]   at chisel3.Data.$colon$eq(Data.scala:475)
[info]   at wbplumbing.TestWbInterconDualSlave$$anonfun$15.apply(testwbplumbing.scala:63)
[info]   at wbplumbing.TestWbInterconDualSlave$$anonfun$15.apply(testwbplumbing.scala:62)
[info]   at scala.collection.Iterator$class.foreach(Iterator.scala:742)
[info]   at scala.collection.AbstractIterator.foreach(Iterator.scala:1194)
[info]   at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
[info]   at chisel3.util.MixedVec.foreach(MixedVec.scala:88)
[info]   ...

1 个答案:

答案 0 :(得分:1)

我不确定发生了什么,但是我能够在当前的chisel3版本中重现您的错误,但是相同的代码似乎可以在chisel 3.2版本的候选快照下正常运行。您可以在那里尝试代码吗? 希望它会更好。该问题似乎不是直接在Employee中出现,而是必须在基础代码中出现。

我必须说,使用Employee时要特别小心,它不能由硬件索引建立索引,因此,在详细说明时,必须从常量Scala int引用对其元素的所有引用。