如何将某些捆绑商品作为模块参数传递?

时间:2019-10-03 09:57:16

标签: scala hdl chisel

我正在编写wishbone plumbing package来为我的设计生成Intercon模块。 在名为wbplumbing的程序包中,我为Wishbone Master和Slave接口声明了两个Bundle:

class WbMaster (val dwidth: Int,
                val awidth: Int) extends Bundle {
    val adr_o = Output(UInt(awidth.W))
// ...
    val cyc_o = Output(Bool())
    override def cloneType = (new WbMaster(dwidth, awidth)).asInstanceOf[this.type]
}

// Wishbone slave interface
class WbSlave (val dwidth: Int,
               val awidth: Int) extends Bundle {
  val adr_i = Input(UInt(awidth.W))
// ...
  val cyc_i = Input(Bool())
  override def cloneType = (new WbSlave(dwidth, awidth)).asInstanceOf[this.type]
}

我的Intercon模块将这两个Bundles作为参数:

// Wishbone Intercon Pass Trought : one master, one slave
class WbInterconPT (val awbm: WbMaster,
                    val awbs: WbSlave) extends Module {
  val io = IO(new Bundle{
    val wbm = Flipped(new WbMaster(awbm.dwidth, awbm.awidth))
    val wbs = Flipped(new WbSlave(awbs.dwidth, awbs.awidth))
})
//...
}

我要插入此Intercon的两个模块位于名为spi2wbmdio的两个不同的程序包中。两者都包含带有捆绑包的wbplumbing软件包:

  • 对于大师:
import wbplumbing.WbMaster
  • 对于奴隶:
import wbplumbing.WbSlave

然后在我的“顶部”模块上导入:

// spi, mdio bus modules
import wbplumbing.WbInterconPT
import wbplumbing.{WbMaster, WbSlave} // <- not sure that usefull
import spi2wb.{Spi2Wb, SpiSlave}
import mdio.{MdioWb, MdioIf}

并实例化它:

  // Wishbone parameters
  val dwidth = 16
  val awidth = 2

  // module instantiation
  val spi2Wb = Module(new Spi2Wb(dwidth, awidth))
  val wbMdio = Module(new MdioWb(mainFreq, targetFreq))
  val wbIntercon = Module(new WbInterconPT(spi2Wb.io.wbm, wbMdio.io.wbs))

然后我得到一个类型错误:

[info] Set current project to spi2ksz (in build file:/pchpch/spi2ksz/)
[info] Compiling 1 Scala source to /pchpch/spi2ksz/target/scala-2.11/classes ...
[error] /pchpch/spi2ksz/src/main/scala/spi2ksz.scala:29:47: type mismatch;
[error]  found   : spi2wb.WbMaster
[error]  required: wbplumbing.WbMaster
[error]   val wbIntercon = new WbInterconPT(spi2Wb.io.wbm, wbMdio.io.wbs)
[error]                                               ^
[error] /pchpch/spi2ksz/src/main/scala/spi2ksz.scala:29:62: type mismatch;
[error]  found   : mdio.WbSlave
[error]  required: wbplumbing.WbSlave
[error]   val wbIntercon = new WbInterconPT(spi2Wb.io.wbm, wbMdio.io.wbs)
[error]                                                              ^
[error] two errors found
[error] (Compile / compileIncremental) Compilation failed

我确定解决方案非常简单,但是可以找到解决方法!

1 个答案:

答案 0 :(得分:2)

好吧,这是一个publishLocal错误。 在设计之初,我在此处分别声明了WbSlave和WbMaster Bundle。然后我出版了。

然后,我编写了WbPlumbing软件包以将其全部整合在一起。而且我忘了在本地“重新”发布两个模块。

有时候,问问题可以解决问题;)