Search code examples
scalachisel

What is the <> operator in Chisel?


The Chisel tutorials make use of what appears to be a <> operator, which is completely unfamiliar to me. What does it do?

Also, where does it come from? Is there a conventional meaning for this operator in other Scala libraries or even other languages?

Here is an example usage, from the the Chisel Generator Bootcamp exercises, section 3.2:

class MyQueue extends Module {
    // Example circuit using a Queue
    val io = IO(new Bundle {
        val in = Flipped(Decoupled(UInt(8.W)))
        val out = Decoupled(UInt(8.W))
    })
    val queue = Queue(io.in, 2)  // 2-element queue
    io.out <> queue
}

Solution

  • <> is used to bulk connect all of the identically named ports between two modules. So in the example above,

    io.out <> queue
    

    is a more concise way to write

    io.out.valid := queue.valid
    io.out.bits := queue.bits
    queue.ready := io.out.ready
    

    since they are both wrapped by the Decoupled interface, which defines ready, valid and bits ports (note that the ready connection flows in the opposite direction: bulk connect handles this correctly).

    I found the answer after reading the Chisel wiki more thoroughly.