summaryrefslogtreecommitdiff
path: root/src/main/scala/chisel3/util/Cat.scala
blob: 535fdfa81c2070fd062ac653801da9e0668a7bce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// SPDX-License-Identifier: Apache-2.0

package chisel3.util

import chisel3._

/** Concatenates elements of the input, in order, together.
  *
  * @example {{{
  * Cat("b101".U, "b11".U)  // equivalent to "b101 11".U
  * Cat(myUIntWire0, myUIntWire1)
  *
  * Cat(Seq("b101".U, "b11".U))  // equivalent to "b101 11".U
  * Cat(mySeqOfBits)
  * }}}
  */
object Cat {

  /** Concatenates the argument data elements, in argument order, together. The first argument
    * forms the most significant bits, while the last argument forms the least significant bits.
    */
  def apply[T <: Bits](
    @deprecatedName(Symbol("a"), "Chisel 3.5") a: T,
    @deprecatedName(Symbol("r"), "Chisel 3.5") r: T*
  ): UInt = apply(
    a :: r.toList
  )

  /** Concatenates the data elements of the input sequence, in reverse sequence order, together.
    * The first element of the sequence forms the most significant bits, while the last element
    * in the sequence forms the least significant bits.
    *
    * Equivalent to r(0) ## r(1) ## ... ## r(n-1).
    * @note This returns a `0.U` if applied to a zero-element `Vec`.
    */
  def apply[T <: Bits](@deprecatedName(Symbol("r"), "Chisel 3.5") r: Seq[T]): UInt = SeqUtils.asUInt(r.reverse)
}