如何将一些 Bundle 作为 Module 参数传递?
How to pass some Bundles as Module parameters?
我正在编写 wishbone plumbing package 来为我的设计生成互连模块。
在这个名为 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 模块将这两个 Bundle 作为参数:
// 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 的两个模块位于两个名为 spi2wb and mdio 的不同包中。两者都包含带有捆绑包的 wbplumbing 包:
- 高手:
import wbplumbing.WbMaster
- 对于奴隶:
import wbplumbing.WbSlave
然后在我的 "top" 模块上导入了这个:
// 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
我确定解决方案非常简单,但可以找到解决方法!
好的,这是一个 publishLocal 错误。
在我的设计开始时,我在此处各自的包中声明了 WbSlave 和 WbMaster Bundle。然后我发表了。
然后我写了WbPlumbing 包把它们放在一起。而且我忘记 "re"publishlocal 这两个模块。
有时候,问问题解决问题;)
我正在编写 wishbone plumbing package 来为我的设计生成互连模块。
在这个名为 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 模块将这两个 Bundle 作为参数:
// 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 的两个模块位于两个名为 spi2wb and mdio 的不同包中。两者都包含带有捆绑包的 wbplumbing 包:
- 高手:
import wbplumbing.WbMaster
- 对于奴隶:
import wbplumbing.WbSlave
然后在我的 "top" 模块上导入了这个:
// 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
我确定解决方案非常简单,但可以找到解决方法!
好的,这是一个 publishLocal 错误。 在我的设计开始时,我在此处各自的包中声明了 WbSlave 和 WbMaster Bundle。然后我发表了。
然后我写了WbPlumbing 包把它们放在一起。而且我忘记 "re"publishlocal 这两个模块。
有时候,问问题解决问题;)