diff options
Diffstat (limited to 'src/main/scala/Chisel/util')
| -rw-r--r-- | src/main/scala/Chisel/util/Cat.scala | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/main/scala/Chisel/util/Cat.scala b/src/main/scala/Chisel/util/Cat.scala new file mode 100644 index 00000000..088a208e --- /dev/null +++ b/src/main/scala/Chisel/util/Cat.scala @@ -0,0 +1,26 @@ +// See LICENSE for license details. + +package Chisel + +object Cat { + /** Combine data elements together + * @param a Data to combine with + * @param r any number of other Data elements to be combined in order + * @return A UInt which is all of the bits combined together + */ + def apply[T <: Bits](a: T, r: T*): UInt = apply(a :: r.toList) + + /** Combine data elements together + * @param r any number of other Data elements to be combined in order + * @return A UInt which is all of the bits combined together + */ + def apply[T <: Bits](r: Seq[T]): UInt = { + if (r.tail.isEmpty) { + r.head.asUInt + } else { + val left = apply(r.slice(0, r.length/2)) + val right = apply(r.slice(r.length/2, r.length)) + left ## right + } + } +} |
