0

I have a module with a vector of Enq/Deq interfaces as IO. Internally, I instantiate a module with a single Enq/Deq interface. I want to be able to input an index that will select Enq/Deq input interfaces and connect it to my internal module.

The code:

class TopModule(busWidth: Int = 4, numberOfBuffers: Int = 4) extends Module {
    val io = IO(new Bundle {
        val enq = Vec(numberOfBuffers, Flipped(Decoupled(UInt(busWidth.W))))
        val deq = Vec(numberOfBuffers, Decoupled(UInt(busWidth.W)))
        val command = Input(UInt(2.W))
        val bufferSelect = Output(UInt(log2Ceil(numberOfBuffers).W))
    })

    val myModule = Module(new MyModule(busWidth, numberOfBuffers))

    myModule.io.bufferSelect <> io.bufferSelect
    myModule.io.command <> io.command

    for (i <- 0 until numberOfBuffers - 1) {
         when(myModule.io.bufferSelect === i.U) {
             myModule.io.enq <> io.enq(i)
             myModule.io.deq <> io.deq(i)
         }.otherwise {
            kvTransfer.io.enq <> io.enq(0)
            kvTransfer.io.deq <> io.deq(0)
         }
    }
}

When I try to run tests, it fails with the following error message:

firrtl.passes.PassExceptions: firrtl.passes.CheckInitialization$RefNotInitializedException:  : [module TopModule]  Reference io is not fully initialized.
[info]    : io.deq[0].bits <= mux(_T, myModule.io.deq.bits, VOID)

I have spent a couple of hours trying to switch/is, adding .otherwise to when, etc. but it didn't work.

When I add .otherwise with io.enq(0) and io.deq(0) I don't get error for zero index but still get the same errors for indexes 1 to 3.

Could you please help with the issue? Thank you.

Chisel version 3.5.4

7
  • Have you tried specifying a default connection for io.enq(i) and io.deq(i)? You could modify the when statement in your for loop by adding a .otherwise clause in which case the pins will be assigned a DontCare value. Commented Jul 26, 2023 at 15:21
  • Yes (I think). I added io.enq(0) and io.deq(0) in .otherwise inside the loop. But then it will complain about connections from 1 to 3. Commented Jul 26, 2023 at 17:15
  • 1
    My suggestion was more like: ``` when(myModule.io.bufferSelect === i.U) { myModule.io.enq <> io.enq(i) myModule.io.deq <> io.deq(i) }.otherwise { io.enq(i) := DontCare io.deq(i) := DontCare } ``` Commented Jul 26, 2023 at 18:52
  • I see. That reduced errors to only three. This is a good progress. The error I am getting now: ``` Reference not initialized myModule.io.enq.bits <= mux(_T_3, io.enq[3].bits, mux(_T_2, io.enq[2].bits, mux(_T_1, io.enq[1].bits, mux(_T, io.enq[0].bits, VOID)))) myModule.io.enq.valid <= mux(_T_3, io.enq[3].valid, mux(_T_2, io.enq[2].valid, mux(_T_1, io.enq[1].valid, mux(_T, io.enq[0].valid, VOID)))) myModule.io.deq.ready <= mux(_T_3, io.deq[3].ready, mux(_T_2, io.deq[2].ready, mux(_T_1, io.deq[1].ready, mux(_T, io.deq[0].ready, VOID)))) ``` Commented Jul 26, 2023 at 22:54
  • 1
    Chisel cannot always prove that all cases where covered. Thus you could just assign a default value to these ports at the top of your module. Like: myModule.io.deq := DontCare ; myModule.io.enq := DontCare Commented Jul 27, 2023 at 13:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.