What is the <> operator in Chisel?

Viewed 1581

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
}
2 Answers

<> 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.

In Scala, most symbols like /!<> etc. are valid method name. It is case by case what the operator/method is defined.

The method call can also have a different syntax which you can replace .() with spaces e.g.

a.foo(bar)

is the same as

a foo bar

So the operator call:

a <> b

is the same as

a.<>(b)
Related