I am trying to make a demuxer using Chisel but the code fails to compile and throw this error shown in the imgur link
[1] https://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{
}
}
I read the wiki about unconnected element https://www.chisel-lang.org/chisel3/docs/wiki-deprecated/unconnected-wires.html
If I use use io.outs <> DontCare on my IO, the code compiles but the generated verilog shorts my inputs to all the outputs, which is not the desired behaviour I want from this module. Can any one suggest I fix to this problem?
Thanks in advance