scala - 如何将一些捆绑包作为模块参数传递?
问题描述
我正在编写一个叉骨管道包来为我的设计生成 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 的两个模块位于两个不同的包中,分别名为spi2wb和mdio。两者都包含带有 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
我确定解决方案非常简单,但可以找到方法!
解决方案
好的,这是一个 publishLocal 错误。在我的设计开始时,我在这里各自的包中声明了 WbSlave 和 WbMaster Bundle。然后我发布了它。
然后我写了 WbPlumbing 包来把它放在一起。而且我忘记“重新”发布这两个模块。
有时,提出问题可以解决问题;)
推荐阅读
- java - JOOQ动态条件查询
- r - ggplot 显示所有 Y 轴值而不是校准
- java - 用交替字符串替换单个字符串
- javascript - Javascript 或 Jquery 事件触发器 - 如何在 javascript 将值传递到输入框时触发事件
- mysql - 在 EC2 上停止 MySql - CentOS
- lstm - batch_first 会影响 Pytorch LSTM 中的隐藏张量吗?
- flutter - 处理儿童水龙头
- javascript - 使用 Ajax 获取页面加载进度
- sql - 我需要我的查询返回它将返回超过 3 个客户购买商品的位置。但是,我的查询一直返回 Null
- java - 如何检查元素的功能是否包含在集合中?