我正在尝试将BlackBox连接到任意的Bundle,但是宽度推断似乎不适用于fromBits函数。下面的代码可以正常编译:
class testBundle extends Bundle {
val io1 = Bool(INPUT)
val io2 = UInt(INPUT,10)
}
class testBox extends BlackBox {
val io = new Bundle {
val in = Bits(INPUT) # Width inference works fine here
val out = Bits(OUTPUT,(new testBundle).getWidth) # But it doesn't work here!
}
}
class test extends Module {
val io = new Bundle {
val in = new testBundle
val out = (new testBundle).flip()
}
val testbox = Module(new testBox)
testbox.io.in := io.in.toBits
io.out := io.out.fromBits(testbox.io.out)
}但是如果我去掉(new testBundle).getWidth参数,Chisel就不能推断输出端口的宽度,就会出错。如何让testBox连接到任意捆绑包?
发布于 2015-05-30 00:26:05
现在,我通过将捆绑包作为参数传递给BlackBox来解决这个问题:
class testBox(b:Bundle) extends BlackBox {
val w = b.getWidth
val io = new Bundle {
val in = Bits(INPUT,w)
val out = Bits(OUTPUT,w)
}
}
class test extends Module {
val io = new Bundle {
val in = new testBundle
val out = (new testBundle).flip()
}
val testbox = Module(new testBox(io.in))
testbox.io.in := io.in.toBits
io.out := io.out.fromBits(testbox.io.out)
}不过,我会欢迎一种更干净的解决方案。
https://stackoverflow.com/questions/30519607
复制相似问题