我正在尝试使用Chisel制作demuxer,但代码无法编译并抛出imgur链接中显示的这个错误
1https://i.stack.imgur.com/oW0Rv.png
class Demuxer extends Module {
val io = IO(new Bundle {
val datain = Input(UInt(8.W))
val dataout1 = Output(UInt(8.W))
val dataout2 = Output(UInt(8.W))
val dataout3 = Output(UInt(8.W))
val dataout4 = Output(UInt(8.W))
val dataout5 = Output(UInt(8.W))
val selector = Input((UInt(3.W)))
})
when(io.selector === 1.U){
io.dataout1 := io.datain
}.elsewhen(io.selector === 2.U){
io.dataout2 := io.datain
}.elsewhen(io.selector === 3.U){
io.dataout3 := io.datain
}.elsewhen(io.selector === 4.U){
io.dataout4 := io.datain
}.elsewhen(io.selector === 5.U){
io.dataout5 := io.datain
}.otherwise{
}
}我看了维基上关于无连接元素的文章https://www.chisel-lang.org/chisel3/docs/wiki-deprecated/unconnected-wires.html如果我在IO上使用use io.outs <> DontCare,代码会编译,但生成的verilog会将我的输入缩短到所有输出,这不是我想要的这个模块的行为。有人能建议我解决这个问题吗?
提前感谢
发布于 2021-02-25 08:01:15
Chisel和Scala FIRRTL编译器要求所有输出在所有情况下都是驱动的。这有助于避免设计人员忘记驱动某些port/wire/reg的bug。问题是代码需要设置一些默认值(或使用DontCare)用于所有模块输出。
当您将所有输出设置为DontCare通常会发生以下两种情况之一:
0.U..。(2)这里正在发生的事情。当你写的时候io.dataout1 := DontCare,则表示编译器可以将其设置为任何值。然后,编译器选择将其设置为io.dataout1 := io.datain(将输入短路到输出)。
而不是使用DontCare你可以使用显性的东西,例如,0.U将为每个输出创建一个mux。使用一行代码完成此操作如下所示:
Seq(io.dataout1, io.dataout2, io.dataout3, io.dataout4, io.dataout5).foreach(
_ := 0.U
)https://stackoverflow.com/questions/66347114
复制相似问题