summaryrefslogtreecommitdiff
path: root/core/src/main/scala/chisel3/Aggregate.scala
diff options
context:
space:
mode:
authorAditya Naik2024-05-29 17:28:22 -0700
committerAditya Naik2024-05-29 17:28:22 -0700
commitbc92bb62f9f6a090e74392993e4fcfdd1f6b0676 (patch)
tree160eb4cc2770eaf0c189fab9442d04b2b00b7919 /core/src/main/scala/chisel3/Aggregate.scala
parent878d488a7c8e0d6973de58b3164022c6a102e449 (diff)
i got 99 errors but "firrtl not found" aint one
Diffstat (limited to 'core/src/main/scala/chisel3/Aggregate.scala')
-rw-r--r--core/src/main/scala/chisel3/Aggregate.scala134
1 files changed, 35 insertions, 99 deletions
diff --git a/core/src/main/scala/chisel3/Aggregate.scala b/core/src/main/scala/chisel3/Aggregate.scala
index 5d460c2d..52d96ce6 100644
--- a/core/src/main/scala/chisel3/Aggregate.scala
+++ b/core/src/main/scala/chisel3/Aggregate.scala
@@ -6,7 +6,6 @@ import chisel3.experimental.VecLiterals.AddVecLiteralConstructor
import scala.collection.immutable.{SeqMap, VectorMap}
import scala.collection.mutable.{HashSet, LinkedHashMap}
-import scala.language.experimental.macros
import chisel3.experimental.{BaseModule, BundleLiteralException, OpaqueType, VecLiteralException}
import chisel3.internal._
import chisel3.internal.Builder.pushCommand
@@ -68,8 +67,8 @@ sealed abstract class Aggregate extends Data {
}
}
- override def do_asUInt(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = {
- SeqUtils.do_asUInt(flatten.map(_.asUInt()))
+ override def asUInt(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = {
+ SeqUtils.asUInt(flatten.map(_.asUInt()))
}
private[chisel3] override def connectFromBits(
@@ -95,7 +94,7 @@ sealed abstract class Aggregate extends Data {
}
}
-trait VecFactory extends SourceInfoDoc {
+trait VecFactory {
/** Creates a new [[Vec]] with `n` entries of the specified data type.
*
@@ -112,9 +111,6 @@ trait VecFactory extends SourceInfoDoc {
private[chisel3] def truncateIndex(
idx: UInt,
n: BigInt
- )(
- implicit sourceInfo: SourceInfo,
- compileOptions: CompileOptions
): UInt = {
val w = (n - 1).bitLength
if (n <= 1) 0.U
@@ -167,7 +163,7 @@ sealed class Vec[T <: Data] private[chisel3] (gen: => T, val length: Int) extend
private[chisel3] override def typeEquivalent(that: Data): Boolean = that match {
case that: Vec[T] =>
this.length == that.length &&
- (this.sample_element.typeEquivalent(that.sample_element))
+ (this.sample_element.typeEquivalent(that.sample_element))
case _ => false
}
@@ -246,10 +242,7 @@ sealed class Vec[T <: Data] private[chisel3] (gen: => T, val length: Int) extend
/** Creates a dynamically indexed read or write accessor into the array.
*/
- override def apply(p: UInt): T = macro CompileOptionsTransform.pArg
-
- /** @group SourceInfoTransformMacro */
- def do_apply(p: UInt)(implicit compileOptions: CompileOptions): T = {
+ def apply(p: UInt)(implicit compileOptions: CompileOptions): T = {
requireIsHardware(this, "vec")
requireIsHardware(p, "vec index")
@@ -305,8 +298,6 @@ sealed class Vec[T <: Data] private[chisel3] (gen: => T, val length: Int) extend
* val sumOut = inputNums.reduceTree((a: T, b: T) => (a + b))
* }}}
*/
- def reduceTree(redOp: (T, T) => T): T = macro VecTransform.reduceTreeDefault
-
/** A reduce operation in a tree like structure instead of sequentially
* @example A pipelined adder tree
* {{{
@@ -316,9 +307,7 @@ sealed class Vec[T <: Data] private[chisel3] (gen: => T, val length: Int) extend
* )
* }}}
*/
- def reduceTree(redOp: (T, T) => T, layerOp: (T) => T): T = macro VecTransform.reduceTree
-
- def do_reduceTree(
+ def reduceTree(
redOp: (T, T) => T,
layerOp: (T) => T = (x: T) => x
)(
@@ -523,7 +512,7 @@ sealed class Vec[T <: Data] private[chisel3] (gen: => T, val length: Int) extend
}
}
-object VecInit extends SourceInfoDoc {
+object VecInit {
/** Gets the correct connect operation (directed hardware assign or bulk connect) for element in Vec.
*/
@@ -553,10 +542,7 @@ object VecInit extends SourceInfoDoc {
* element
* @note output elements are connected from the input elements
*/
- def apply[T <: Data](elts: Seq[T]): Vec[T] = macro VecTransform.apply_elts
-
- /** @group SourceInfoTransformMacro */
- def do_apply[T <: Data](elts: Seq[T])(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Vec[T] = {
+ def apply[T <: Data](elts: Seq[T])(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Vec[T] = {
// REVIEW TODO: this should be removed in favor of the apply(elts: T*)
// varargs constructor, which is more in line with the style of the Scala
// collection API. However, a deprecation phase isn't possible, since
@@ -585,10 +571,7 @@ object VecInit extends SourceInfoDoc {
* element
* @note output elements are connected from the input elements
*/
- def apply[T <: Data](elt0: T, elts: T*): Vec[T] = macro VecTransform.apply_elt0
-
- /** @group SourceInfoTransformMacro */
- def do_apply[T <: Data](elt0: T, elts: T*)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Vec[T] =
+ def apply[T <: Data](elt0: T, elts: T*)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Vec[T] =
apply(elt0 +: elts.toSeq)
/** Creates a new [[Vec]] of length `n` composed of the results of the given
@@ -599,10 +582,7 @@ object VecInit extends SourceInfoDoc {
* @param gen function that takes in an Int (the index) and returns a
* [[Data]] that becomes the output element
*/
- def tabulate[T <: Data](n: Int)(gen: (Int) => T): Vec[T] = macro VecTransform.tabulate
-
- /** @group SourceInfoTransformMacro */
- def do_tabulate[T <: Data](
+ def tabulate[T <: Data](
n: Int
)(gen: (Int) => T
)(
@@ -620,10 +600,7 @@ object VecInit extends SourceInfoDoc {
* @param gen function that takes in an Int (the index) and returns a
* [[Data]] that becomes the output element
*/
- def tabulate[T <: Data](n: Int, m: Int)(gen: (Int, Int) => T): Vec[Vec[T]] = macro VecTransform.tabulate2D
-
- /** @group SourceInfoTransformMacro */
- def do_tabulate[T <: Data](
+ def tabulate[T <: Data](
n: Int,
m: Int
)(gen: (Int, Int) => T
@@ -659,11 +636,7 @@ object VecInit extends SourceInfoDoc {
* @param gen function that takes in an Int (the index) and returns a
* [[Data]] that becomes the output element
*/
- def tabulate[T <: Data](n: Int, m: Int, p: Int)(gen: (Int, Int, Int) => T): Vec[Vec[Vec[T]]] =
- macro VecTransform.tabulate3D
-
- /** @group SourceInfoTransformMacro */
- def do_tabulate[T <: Data](
+ def tabulate[T <: Data](
n: Int,
m: Int,
p: Int
@@ -701,10 +674,7 @@ object VecInit extends SourceInfoDoc {
* @param gen function that takes in an element T and returns an output
* element of the same type
*/
- def fill[T <: Data](n: Int)(gen: => T): Vec[T] = macro VecTransform.fill
-
- /** @group SourceInfoTransformMacro */
- def do_fill[T <: Data](n: Int)(gen: => T)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Vec[T] =
+ def fill[T <: Data](n: Int)(gen: => T)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Vec[T] =
apply(Seq.fill(n)(gen))
/** Creates a new 2D [[Vec]] of length `n by m` composed of the result of the given
@@ -715,10 +685,7 @@ object VecInit extends SourceInfoDoc {
* @param gen function that takes in an element T and returns an output
* element of the same type
*/
- def fill[T <: Data](n: Int, m: Int)(gen: => T): Vec[Vec[T]] = macro VecTransform.fill2D
-
- /** @group SourceInfoTransformMacro */
- def do_fill[T <: Data](
+ def fill[T <: Data](
n: Int,
m: Int
)(gen: => T
@@ -726,7 +693,7 @@ object VecInit extends SourceInfoDoc {
implicit sourceInfo: SourceInfo,
compileOptions: CompileOptions
): Vec[Vec[T]] = {
- do_tabulate(n, m)((_, _) => gen)
+ tabulate(n, m)((_, _) => gen)
}
/** Creates a new 3D [[Vec]] of length `n by m by p` composed of the result of the given
@@ -738,10 +705,7 @@ object VecInit extends SourceInfoDoc {
* @param gen function that takes in an element T and returns an output
* element of the same type
*/
- def fill[T <: Data](n: Int, m: Int, p: Int)(gen: => T): Vec[Vec[Vec[T]]] = macro VecTransform.fill3D
-
- /** @group SourceInfoTransformMacro */
- def do_fill[T <: Data](
+ def fill[T <: Data](
n: Int,
m: Int,
p: Int
@@ -750,7 +714,7 @@ object VecInit extends SourceInfoDoc {
implicit sourceInfo: SourceInfo,
compileOptions: CompileOptions
): Vec[Vec[Vec[T]]] = {
- do_tabulate(n, m, p)((_, _, _) => gen)
+ tabulate(n, m, p)((_, _, _) => gen)
}
/** Creates a new [[Vec]] of length `n` composed of the result of the given
@@ -761,10 +725,7 @@ object VecInit extends SourceInfoDoc {
* @param f Function that applies the element T from previous index and returns the output
* element to the next index
*/
- def iterate[T <: Data](start: T, len: Int)(f: (T) => T): Vec[T] = macro VecTransform.iterate
-
- /** @group SourceInfoTransformMacro */
- def do_iterate[T <: Data](
+ def iterate[T <: Data](
start: T,
len: Int
)(f: (T) => T
@@ -773,16 +734,12 @@ object VecInit extends SourceInfoDoc {
compileOptions: CompileOptions
): Vec[T] =
apply(Seq.iterate(start, len)(f))
-}
-/** A trait for [[Vec]]s containing common hardware generators for collection
- * operations.
- */
-trait VecLike[T <: Data] extends IndexedSeq[T] with HasId with SourceInfoDoc {
- def apply(p: UInt): T = macro CompileOptionsTransform.pArg
- /** @group SourceInfoTransformMacro */
- def do_apply(p: UInt)(implicit compileOptions: CompileOptions): T
+ /** A trait for [[Vec]]s containing common hardware generators for collection
+ * operations.
+ */
+ def apply[T <: Data](p: UInt)(implicit compileOptions: CompileOptions): T
// IndexedSeq has its own hashCode/equals that we must not use
override def hashCode: Int = super[HasId].hashCode
@@ -790,35 +747,23 @@ trait VecLike[T <: Data] extends IndexedSeq[T] with HasId with SourceInfoDoc {
/** Outputs true if p outputs true for every element.
*/
- def forall(p: T => Bool): Bool = macro SourceInfoTransform.pArg
-
- /** @group SourceInfoTransformMacro */
- def do_forall(p: T => Bool)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool =
+ def forall[T <: Data](p: T => Bool)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool =
(this.map(p)).fold(true.B)(_ && _)
/** Outputs true if p outputs true for at least one element.
*/
- def exists(p: T => Bool): Bool = macro SourceInfoTransform.pArg
-
- /** @group SourceInfoTransformMacro */
- def do_exists(p: T => Bool)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool =
+ def exists(p: T => Bool)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool =
(this.map(p)).fold(false.B)(_ || _)
/** Outputs true if the vector contains at least one element equal to x (using
* the === operator).
*/
- def contains(x: T)(implicit ev: T <:< UInt): Bool = macro VecTransform.contains
-
- /** @group SourceInfoTransformMacro */
- def do_contains(x: T)(implicit sourceInfo: SourceInfo, ev: T <:< UInt, compileOptions: CompileOptions): Bool =
+ def contains(x: T)(implicit sourceInfo: SourceInfo, ev: T <:< UInt, compileOptions: CompileOptions): Bool =
this.exists(_ === x)
/** Outputs the number of elements for which p is true.
*/
- def count(p: T => Bool): UInt = macro SourceInfoTransform.pArg
-
- /** @group SourceInfoTransformMacro */
- def do_count(p: T => Bool)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt =
+ def count(p: T => Bool)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt =
SeqUtils.count(this.map(p))
/** Helper function that appends an index (literal value) to each element,
@@ -828,18 +773,12 @@ trait VecLike[T <: Data] extends IndexedSeq[T] with HasId with SourceInfoDoc {
/** Outputs the index of the first element for which p outputs true.
*/
- def indexWhere(p: T => Bool): UInt = macro SourceInfoTransform.pArg
-
- /** @group SourceInfoTransformMacro */
- def do_indexWhere(p: T => Bool)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt =
+ def indexWhere(p: T => Bool)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt =
SeqUtils.priorityMux(indexWhereHelper(p))
/** Outputs the index of the last element for which p outputs true.
*/
- def lastIndexWhere(p: T => Bool): UInt = macro SourceInfoTransform.pArg
-
- /** @group SourceInfoTransformMacro */
- def do_lastIndexWhere(p: T => Bool)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt =
+ def lastIndexWhere(p: T => Bool)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt =
SeqUtils.priorityMux(indexWhereHelper(p).reverse)
/** Outputs the index of the element for which p outputs true, assuming that
@@ -852,10 +791,7 @@ trait VecLike[T <: Data] extends IndexedSeq[T] with HasId with SourceInfoDoc {
* true is NOT checked (useful in cases where the condition doesn't always
* hold, but the results are not used in those cases)
*/
- def onlyIndexWhere(p: T => Bool): UInt = macro SourceInfoTransform.pArg
-
- /** @group SourceInfoTransformMacro */
- def do_onlyIndexWhere(p: T => Bool)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt =
+ def onlyIndexWhere(p: T => Bool)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt =
SeqUtils.oneHotMux(indexWhereHelper(p))
}
@@ -1110,12 +1046,12 @@ abstract class Record(private[chisel3] implicit val compileOptions: CompileOptio
private[chisel3] override def typeEquivalent(that: Data): Boolean = that match {
case that: Record =>
this.getClass == that.getClass &&
- this.elements.size == that.elements.size &&
- this.elements.forall {
- case (name, model) =>
- that.elements.contains(name) &&
- (that.elements(name).typeEquivalent(model))
- }
+ this.elements.size == that.elements.size &&
+ this.elements.forall {
+ case (name, model) =>
+ that.elements.contains(name) &&
+ (that.elements(name).typeEquivalent(model))
+ }
case _ => false
}