Mrchacha Mrchacha - 26 days ago 4x
Scala Question

What does the expression ## mean in Chisel?

I've been looking all over the web to find out what the expression ## means in chisel, but can't find it anywhere.

For example in this code snippet:

val ways = Module(new BRAM(log2Up(conf.lines), conf.ways * line_size))
val din = Vec.fill(conf.ways) { Bits(width=line_size) }
if(conf.ways == 2) { := din(1) ## din(0)

What is the line in the if-statement doing using the ## expression?


Since you can't really google for symbolic characters such as #, the thing to find the documentation for the ## another way. The simplest way would be to just hover over ## and let it display the API doc. If this isn't possible because your IDE doesn't do that or you haven't downloaded the API docs, you can find the docs for whichever class the method is called on and look it up there.

In this case you're calling ## on din(1). Since din is a vector of Bits, din(1) is a Bits object. So we can look up the Bits class in the Chisel API docs and find the following on ##:

def ##(other: Bits): UInt

Returns this wire concatenated with other, where this wire forms the most significant part and other forms the least significant part.

The width of the output is sum of the inputs.