首页 > 解决方案 > 如何将一些捆绑包作为模块参数传递?

问题描述

我正在编写一个叉骨管道包来为我的设计生成 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 模块将这两个捆绑包作为参数:

// 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。两者都包含带有 bundle 的 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

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

标签: scalahdlchisel

解决方案


好的,这是一个 publishLocal 错误。在我的设计开始时,我在这里各自的包中声明了 WbSlave 和 WbMaster Bundle。然后我发布了它。

然后我写了 WbPlumbing 包来把它放在一起。而且我忘记“重新”发布这两个模块。

有时,提出问题可以解决问题;)


推荐阅读