diff options
| author | Jim Lawson | 2017-04-25 08:44:35 -0700 |
|---|---|---|
| committer | GitHub | 2017-04-25 08:44:35 -0700 |
| commit | 4a6396ca5ff9dfba9019552012bce459ef3c3b1e (patch) | |
| tree | 940018ca04febec6f3e18b1f03700fa3f203708e /chiselFrontend/src/main | |
| parent | d439ac0144826bb170c43ae71df9782cdd0d5749 (diff) | |
Remove explicit import of NotStrict - fixes #492 (#494)
* Remove explicit import of NotStrict - fixes #492
* Provide macro for MemBase.apply().
* Provide macro for MemBase.apply().
Since a macro cannot override an abstract method, provide a concrete
apply method n VecLike() that we can override with a macro.
* Remove concrete apply() in VecLike.
Since MemBase no longer extends the trait VecLike, we do not require a concrete method to which we can apply a macro to extract the appropriate CompileOptions.
Diffstat (limited to 'chiselFrontend/src/main')
11 files changed, 207 insertions, 206 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala b/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala index 8143d4db..97028995 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala @@ -23,7 +23,7 @@ sealed abstract class Aggregate extends Data { private[core] def legacyConnect(that: Data)(implicit sourceInfo: SourceInfo): Unit = pushCommand(BulkConnect(sourceInfo, this.lref, that.lref)) - override def do_asUInt(implicit sourceInfo: SourceInfo): UInt = { + override def do_asUInt(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = { SeqUtils.do_asUInt(flatten.map(_.asUInt())) } private[core] override def connectFromBits(that: Bits)(implicit sourceInfo: SourceInfo, @@ -132,7 +132,7 @@ object Vec { apply(Seq.fill(n)(gen)) /** Truncate an index to implement modulo-power-of-2 addressing. */ - private[core] def truncateIndex(idx: UInt, n: Int)(implicit sourceInfo: SourceInfo): UInt = { + private[core] def truncateIndex(idx: UInt, n: Int)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = { val w = BigInt(n-1).bitLength if (n <= 1) 0.U else if (idx.width.known && idx.width.get <= w) idx @@ -223,10 +223,10 @@ sealed class Vec[T <: Data] private (gen: => T, val length: Int) /** Creates a dynamically indexed read or write accessor into the array. */ - def apply(idx: UInt): T = { + def apply(idx: UInt)(implicit compileOptions: CompileOptions): T = { Binding.checkSynthesizable(idx ,s"'idx' ($idx)") val port = gen - val i = Vec.truncateIndex(idx, length)(UnlocatableSourceInfo) + val i = Vec.truncateIndex(idx, length)(UnlocatableSourceInfo, compileOptions) port.setRef(this, i) // Bind each element of port to being whatever the base type is @@ -243,11 +243,11 @@ sealed class Vec[T <: Data] private (gen: => T, val length: Int) def apply(idx: Int): T = self(idx) @deprecated("Use Vec.apply instead", "chisel3") - def read(idx: UInt): T = apply(idx) + def read(idx: UInt)(implicit compileOptions: CompileOptions): T = apply(idx) @deprecated("Use Vec.apply instead", "chisel3") - def write(idx: UInt, data: T): Unit = { - apply(idx).:=(data)(DeprecatedSourceInfo, chisel3.core.ExplicitCompileOptions.NotStrict) + def write(idx: UInt, data: T)(implicit compileOptions: CompileOptions): Unit = { + apply(idx)(compileOptions).:=(data)(DeprecatedSourceInfo, compileOptions) } override def cloneType: this.type = { @@ -277,30 +277,30 @@ sealed class Vec[T <: Data] private (gen: => T, val length: Int) * operations. */ trait VecLike[T <: Data] extends collection.IndexedSeq[T] with HasId { - def apply(idx: UInt): T + def apply(idx: UInt)(implicit compileOptions: CompileOptions): T // IndexedSeq has its own hashCode/equals that we must not use override def hashCode: Int = super[HasId].hashCode override def equals(that: Any): Boolean = super[HasId].equals(that) @deprecated("Use Vec.apply instead", "chisel3") - def read(idx: UInt): T + def read(idx: UInt)(implicit compileOptions: CompileOptions): T @deprecated("Use Vec.apply instead", "chisel3") - def write(idx: UInt, data: T): Unit + def write(idx: UInt, data: T)(implicit compileOptions: CompileOptions): Unit /** Outputs true if p outputs true for every element. */ def forall(p: T => Bool): Bool = macro SourceInfoTransform.pArg - def do_forall(p: T => Bool)(implicit sourceInfo: SourceInfo): Bool = + def do_forall(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 - def do_exists(p: T => Bool)(implicit sourceInfo: SourceInfo): Bool = + def do_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 @@ -308,14 +308,14 @@ trait VecLike[T <: Data] extends collection.IndexedSeq[T] with HasId { */ def contains(x: T)(implicit ev: T <:< UInt): Bool = macro VecTransform.contains - def do_contains(x: T)(implicit sourceInfo: SourceInfo, ev: T <:< UInt): Bool = + def do_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 - def do_count(p: T => Bool)(implicit sourceInfo: SourceInfo): UInt = + def do_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, diff --git a/chiselFrontend/src/main/scala/chisel3/core/Assert.scala b/chiselFrontend/src/main/scala/chisel3/core/Assert.scala index e3fef5f9..8616154b 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/Assert.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/Assert.scala @@ -31,26 +31,26 @@ object assert { // scalastyle:ignore object.name * that */ // Macros currently can't take default arguments, so we need two functions to emulate defaults. - def apply(cond: Bool, message: String, data: Bits*)(implicit sourceInfo: SourceInfo): Unit = macro apply_impl_msg_data - def apply(cond: Bool)(implicit sourceInfo: SourceInfo): Unit = macro apply_impl + def apply(cond: Bool, message: String, data: Bits*)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Unit = macro apply_impl_msg_data + def apply(cond: Bool)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Unit = macro apply_impl - def apply_impl_msg_data(c: Context)(cond: c.Tree, message: c.Tree, data: c.Tree*)(sourceInfo: c.Tree): c.Tree = { + def apply_impl_msg_data(c: Context)(cond: c.Tree, message: c.Tree, data: c.Tree*)(sourceInfo: c.Tree, compileOptions: c.Tree): c.Tree = { import c.universe._ val p = c.enclosingPosition val condStr = s"${p.source.file.name}:${p.line} ${p.lineContent.trim}" val apply_impl_do = symbolOf[this.type].asClass.module.info.member(TermName("apply_impl_do")) - q"$apply_impl_do($cond, $condStr, _root_.scala.Some($message), ..$data)($sourceInfo)" + q"$apply_impl_do($cond, $condStr, _root_.scala.Some($message), ..$data)($sourceInfo, $compileOptions)" } - def apply_impl(c: Context)(cond: c.Tree)(sourceInfo: c.Tree): c.Tree = { + def apply_impl(c: Context)(cond: c.Tree)(sourceInfo: c.Tree, compileOptions: c.Tree): c.Tree = { import c.universe._ val p = c.enclosingPosition val condStr = s"${p.source.file.name}:${p.line} ${p.lineContent.trim}" val apply_impl_do = symbolOf[this.type].asClass.module.info.member(TermName("apply_impl_do")) - q"$apply_impl_do($cond, $condStr, _root_.scala.None)($sourceInfo)" + q"$apply_impl_do($cond, $condStr, _root_.scala.None)($sourceInfo, $compileOptions)" } - def apply_impl_do(cond: Bool, line: String, message: Option[String], data: Bits*)(implicit sourceInfo: SourceInfo) { + def apply_impl_do(cond: Bool, line: String, message: Option[String], data: Bits*)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions) { when (!(cond || Builder.forcedReset)) { val fmt = message match { case Some(str) => s"Assertion failed: $str\n at $line\n" @@ -76,14 +76,14 @@ object assert { // scalastyle:ignore object.name object stop { // scalastyle:ignore object.name /** Terminate execution with a failure code. */ - def apply(code: Int)(implicit sourceInfo: SourceInfo): Unit = { + def apply(code: Int)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Unit = { when (!Builder.forcedReset) { pushCommand(Stop(sourceInfo, Node(Builder.forcedClock), code)) } } /** Terminate execution, indicating success. */ - def apply()(implicit sourceInfo: SourceInfo): Unit = { + def apply()(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Unit = { stop(0) } } diff --git a/chiselFrontend/src/main/scala/chisel3/core/BiConnect.scala b/chiselFrontend/src/main/scala/chisel3/core/BiConnect.scala index 95ad95ef..4240a945 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/BiConnect.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/BiConnect.scala @@ -73,6 +73,7 @@ object BiConnect { if(left_v.length != right_v.length) { throw MismatchedVecException } for(idx <- 0 until left_v.length) { try { + implicit val compileOptions = connectCompileOptions connect(sourceInfo, connectCompileOptions, left_v(idx), right_v(idx), context_mod) } catch { case BiConnectException(message) => throw BiConnectException(s"($idx)$message") diff --git a/chiselFrontend/src/main/scala/chisel3/core/Bits.scala b/chiselFrontend/src/main/scala/chisel3/core/Bits.scala index a8a96946..f18fb541 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/Bits.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/Bits.scala @@ -11,8 +11,6 @@ import chisel3.internal.firrtl._ import chisel3.internal.sourceinfo.{SourceInfo, DeprecatedSourceInfo, SourceInfoTransform, SourceInfoWhiteboxTransform, UIntTransform} import chisel3.internal.firrtl.PrimOp._ -// TODO: remove this once we have CompileOptions threaded through the macro system. -import chisel3.core.ExplicitCompileOptions.NotStrict //scalastyle:off method.name @@ -66,7 +64,7 @@ sealed abstract class Bits(width: Width, override val litArg: Option[LitArg]) final def tail(n: Int): UInt = macro SourceInfoTransform.nArg final def head(n: Int): UInt = macro SourceInfoTransform.nArg - def do_tail(n: Int)(implicit sourceInfo: SourceInfo): UInt = { + def do_tail(n: Int)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = { val w = width match { case KnownWidth(x) => require(x >= n, s"Can't tail($n) for width $x < $n") @@ -77,7 +75,7 @@ sealed abstract class Bits(width: Width, override val litArg: Option[LitArg]) } - def do_head(n: Int)(implicit sourceInfo: SourceInfo): UInt = { + def do_head(n: Int)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = { width match { case KnownWidth(x) => require(x >= n, s"Can't head($n) for width $x < $n") case UnknownWidth() => @@ -90,7 +88,7 @@ sealed abstract class Bits(width: Width, override val litArg: Option[LitArg]) */ final def apply(x: BigInt): Bool = macro SourceInfoTransform.xArg - final def do_apply(x: BigInt)(implicit sourceInfo: SourceInfo): Bool = { + final def do_apply(x: BigInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = { if (x < 0) { Builder.error(s"Negative bit indices are illegal (got $x)") } @@ -109,15 +107,16 @@ sealed abstract class Bits(width: Width, override val litArg: Option[LitArg]) */ final def apply(x: Int): Bool = macro SourceInfoTransform.xArg - final def do_apply(x: Int)(implicit sourceInfo: SourceInfo): Bool = apply(BigInt(x)) + final def do_apply(x: Int)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = apply(BigInt(x)) /** Returns the specified bit on this wire as a [[Bool]], dynamically * addressed. */ final def apply(x: UInt): Bool = macro SourceInfoTransform.xArg - final def do_apply(x: UInt)(implicit sourceInfo: SourceInfo): Bool = { - (this >> x)(0) + final def do_apply(x: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = { + val theBits = this >> x + theBits(0) } /** Returns a subset of bits on this wire from `hi` to `lo` (inclusive), @@ -131,7 +130,7 @@ sealed abstract class Bits(width: Width, override val litArg: Option[LitArg]) */ final def apply(x: Int, y: Int): UInt = macro SourceInfoTransform.xyArg - final def do_apply(x: Int, y: Int)(implicit sourceInfo: SourceInfo): UInt = { + final def do_apply(x: Int, y: Int)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = { if (x < y || y < 0) { Builder.error(s"Invalid bit range ($x,$y)") } @@ -147,7 +146,7 @@ sealed abstract class Bits(width: Width, override val litArg: Option[LitArg]) // REVIEW TODO: again, is this necessary? Or just have this and use implicits? final def apply(x: BigInt, y: BigInt): UInt = macro SourceInfoTransform.xyArg - final def do_apply(x: BigInt, y: BigInt)(implicit sourceInfo: SourceInfo): UInt = + final def do_apply(x: BigInt, y: BigInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = apply(x.toInt, y.toInt) private[core] def unop[T <: Data](sourceInfo: SourceInfo, dest: T, op: PrimOp): T = { @@ -185,7 +184,7 @@ sealed abstract class Bits(width: Width, override val litArg: Option[LitArg]) /** Returns this wire bitwise-inverted. */ final def unary_~ (): Bits = macro SourceInfoWhiteboxTransform.noArg - def do_unary_~ (implicit sourceInfo: SourceInfo): Bits + def do_unary_~ (implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bits /** Shift left operation */ @@ -193,7 +192,7 @@ sealed abstract class Bits(width: Width, override val litArg: Option[LitArg]) // REVIEW TODO: should these return this.type or Bits? final def << (that: BigInt): Bits = macro SourceInfoWhiteboxTransform.thatArg - def do_<< (that: BigInt)(implicit sourceInfo: SourceInfo): Bits + def do_<< (that: BigInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bits /** Returns this wire statically left shifted by the specified amount, * inserting zeros into the least significant bits. @@ -202,7 +201,7 @@ sealed abstract class Bits(width: Width, override val litArg: Option[LitArg]) */ final def << (that: Int): Bits = macro SourceInfoWhiteboxTransform.thatArg - def do_<< (that: Int)(implicit sourceInfo: SourceInfo): Bits + def do_<< (that: Int)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bits /** Returns this wire dynamically left shifted by the specified amount, * inserting zeros into the least significant bits. @@ -211,13 +210,13 @@ sealed abstract class Bits(width: Width, override val litArg: Option[LitArg]) */ final def << (that: UInt): Bits = macro SourceInfoWhiteboxTransform.thatArg - def do_<< (that: UInt)(implicit sourceInfo: SourceInfo): Bits + def do_<< (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bits /** Shift right operation */ // REVIEW TODO: redundant final def >> (that: BigInt): Bits = macro SourceInfoWhiteboxTransform.thatArg - def do_>> (that: BigInt)(implicit sourceInfo: SourceInfo): Bits + def do_>> (that: BigInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bits /** Returns this wire statically right shifted by the specified amount, * inserting zeros into the most significant bits. @@ -226,7 +225,7 @@ sealed abstract class Bits(width: Width, override val litArg: Option[LitArg]) */ final def >> (that: Int): Bits = macro SourceInfoWhiteboxTransform.thatArg - def do_>> (that: Int)(implicit sourceInfo: SourceInfo): Bits + def do_>> (that: Int)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bits /** Returns this wire dynamically right shifted by the specified amount, * inserting zeros into the most significant bits. @@ -235,13 +234,13 @@ sealed abstract class Bits(width: Width, override val litArg: Option[LitArg]) */ final def >> (that: UInt): Bits = macro SourceInfoWhiteboxTransform.thatArg - def do_>> (that: UInt)(implicit sourceInfo: SourceInfo): Bits + def do_>> (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bits /** Returns the contents of this wire as a [[Vec]] of [[Bool]]s. */ final def toBools(): Seq[Bool] = macro SourceInfoTransform.noArg - def toBools(implicit sourceInfo: SourceInfo): Seq[Bool] = + def toBools(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Seq[Bool] = Seq.tabulate(this.getWidth)(i => this(i)) /** Reinterpret cast to a SInt. @@ -251,7 +250,7 @@ sealed abstract class Bits(width: Width, override val litArg: Option[LitArg]) */ final def asSInt(): SInt = macro SourceInfoTransform.noArg - def do_asSInt(implicit sourceInfo: SourceInfo): SInt + def do_asSInt(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt /** Reinterpret cast as a FixedPoint. * @@ -261,7 +260,7 @@ sealed abstract class Bits(width: Width, override val litArg: Option[LitArg]) */ final def asFixedPoint(that: BinaryPoint): FixedPoint = macro SourceInfoTransform.thatArg - def do_asFixedPoint(that: BinaryPoint)(implicit sourceInfo: SourceInfo): FixedPoint = { + def do_asFixedPoint(that: BinaryPoint)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = { throwException(s"Cannot call .asFixedPoint on $this") } @@ -269,16 +268,16 @@ sealed abstract class Bits(width: Width, override val litArg: Option[LitArg]) @deprecated("Use asUInt, which does the same thing but returns a more concrete type", "chisel3") final def asBits(): Bits = macro SourceInfoTransform.noArg - def do_asBits(implicit sourceInfo: SourceInfo): Bits = asUInt() + def do_asBits(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bits = asUInt() @deprecated("Use asSInt, which makes the reinterpret cast more explicit", "chisel3") - final def toSInt(): SInt = do_asSInt(DeprecatedSourceInfo) + final def toSInt(implicit compileOptions: CompileOptions): SInt = do_asSInt(DeprecatedSourceInfo, compileOptions) @deprecated("Use asUInt, which makes the reinterpret cast more explicit", "chisel3") - final def toUInt(): UInt = do_asUInt(DeprecatedSourceInfo) + final def toUInt(implicit compileOptions: CompileOptions): UInt = do_asUInt(DeprecatedSourceInfo, compileOptions) final def toBool(): Bool = macro SourceInfoTransform.noArg - def do_toBool(implicit sourceInfo: SourceInfo): Bool = { + def do_toBool(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = { width match { case KnownWidth(1) => this(0) case _ => throwException(s"can't covert UInt<$width> to Bool") @@ -292,7 +291,7 @@ sealed abstract class Bits(width: Width, override val litArg: Option[LitArg]) */ final def ## (that: Bits): UInt = macro SourceInfoTransform.thatArg - def do_## (that: Bits)(implicit sourceInfo: SourceInfo): UInt = { + def do_## (that: Bits)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = { val w = this.width + that.width pushOp(DefPrim(sourceInfo, UInt(w), ConcatOp, this.ref, that.ref)) } @@ -318,7 +317,7 @@ abstract trait Num[T <: Data] { */ final def + (that: T): T = macro SourceInfoTransform.thatArg - def do_+ (that: T)(implicit sourceInfo: SourceInfo): T + def do_+ (that: T)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T /** Outputs the product of `this` and `b`. The resulting width is the sum of * the operands. @@ -328,7 +327,7 @@ abstract trait Num[T <: Data] { */ final def * (that: T): T = macro SourceInfoTransform.thatArg - def do_* (that: T)(implicit sourceInfo: SourceInfo): T + def do_* (that: T)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T /** Outputs the quotient of `this` and `b`. * @@ -336,53 +335,53 @@ abstract trait Num[T <: Data] { */ final def / (that: T): T = macro SourceInfoTransform.thatArg - def do_/ (that: T)(implicit sourceInfo: SourceInfo): T + def do_/ (that: T)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T final def % (that: T): T = macro SourceInfoTransform.thatArg - def do_% (that: T)(implicit sourceInfo: SourceInfo): T + def do_% (that: T)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T /** Outputs the difference of `this` and `b`. The resulting width is the max * of the operands plus 1 (should not overflow). */ final def - (that: T): T = macro SourceInfoTransform.thatArg - def do_- (that: T)(implicit sourceInfo: SourceInfo): T + def do_- (that: T)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T /** Outputs true if `this` < `b`. */ final def < (that: T): Bool = macro SourceInfoTransform.thatArg - def do_< (that: T)(implicit sourceInfo: SourceInfo): Bool + def do_< (that: T)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool /** Outputs true if `this` <= `b`. */ final def <= (that: T): Bool = macro SourceInfoTransform.thatArg - def do_<= (that: T)(implicit sourceInfo: SourceInfo): Bool + def do_<= (that: T)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool /** Outputs true if `this` > `b`. */ final def > (that: T): Bool = macro SourceInfoTransform.thatArg - def do_> (that: T)(implicit sourceInfo: SourceInfo): Bool + def do_> (that: T)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool /** Outputs true if `this` >= `b`. */ final def >= (that: T): Bool = macro SourceInfoTransform.thatArg - def do_>= (that: T)(implicit sourceInfo: SourceInfo): Bool + def do_>= (that: T)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool /** Outputs the absolute value of `this`. The resulting width is the unchanged */ final def abs(): T = macro SourceInfoTransform.noArg - def do_abs(implicit sourceInfo: SourceInfo): T + def do_abs(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T /** Outputs the minimum of `this` and `b`. The resulting width is the max of * the operands. */ final def min(that: T): T = macro SourceInfoTransform.thatArg - def do_min(that: T)(implicit sourceInfo: SourceInfo): T = + def do_min(that: T)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T = Mux(this < that, this.asInstanceOf[T], that) /** Outputs the maximum of `this` and `b`. The resulting width is the max of @@ -390,7 +389,7 @@ abstract trait Num[T <: Data] { */ final def max(that: T): T = macro SourceInfoTransform.thatArg - def do_max(that: T)(implicit sourceInfo: SourceInfo): T = + def do_max(that: T)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T = Mux(this < that, that, this.asInstanceOf[T]) } @@ -411,33 +410,33 @@ sealed class UInt private[core] (width: Width, lit: Option[ULit] = None) final def unary_- (): UInt = macro SourceInfoTransform.noArg final def unary_-% (): UInt = macro SourceInfoTransform.noArg - def do_unary_- (implicit sourceInfo: SourceInfo) : UInt = 0.U - this - def do_unary_-% (implicit sourceInfo: SourceInfo): UInt = 0.U -% this + def do_unary_- (implicit sourceInfo: SourceInfo, compileOptions: CompileOptions) : UInt = 0.U - this + def do_unary_-% (implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = 0.U -% this - override def do_+ (that: UInt)(implicit sourceInfo: SourceInfo): UInt = this +% that - override def do_- (that: UInt)(implicit sourceInfo: SourceInfo): UInt = this -% that - override def do_/ (that: UInt)(implicit sourceInfo: SourceInfo): UInt = + override def do_+ (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = this +% that + override def do_- (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = this -% that + override def do_/ (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = binop(sourceInfo, UInt(this.width), DivideOp, that) - override def do_% (that: UInt)(implicit sourceInfo: SourceInfo): UInt = + override def do_% (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = binop(sourceInfo, UInt(this.width), RemOp, that) - override def do_* (that: UInt)(implicit sourceInfo: SourceInfo): UInt = + override def do_* (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = binop(sourceInfo, UInt(this.width + that.width), TimesOp, that) final def * (that: SInt): SInt = macro SourceInfoTransform.thatArg - def do_* (that: SInt)(implicit sourceInfo: SourceInfo): SInt = that * this + def do_* (that: SInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = that * this final def +& (that: UInt): UInt = macro SourceInfoTransform.thatArg final def +% (that: UInt): UInt = macro SourceInfoTransform.thatArg final def -& (that: UInt): UInt = macro SourceInfoTransform.thatArg final def -% (that: UInt): UInt = macro SourceInfoTransform.thatArg - def do_+& (that: UInt)(implicit sourceInfo: SourceInfo): UInt = + def do_+& (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = binop(sourceInfo, UInt((this.width max that.width) + 1), AddOp, that) - def do_+% (that: UInt)(implicit sourceInfo: SourceInfo): UInt = + def do_+% (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = (this +& that).tail(1) - def do_-& (that: UInt)(implicit sourceInfo: SourceInfo): UInt = + def do_-& (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = binop(sourceInfo, SInt((this.width max that.width) + 1), SubOp, that).asUInt - def do_-% (that: UInt)(implicit sourceInfo: SourceInfo): UInt = + def do_-% (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = (this -& that).tail(1) final def & (that: UInt): UInt = macro SourceInfoTransform.thatArg @@ -445,17 +444,17 @@ sealed class UInt private[core] (width: Width, lit: Option[ULit] = None) final def ^ (that: UInt): UInt = macro SourceInfoTransform.thatArg // override def abs: UInt = macro SourceInfoTransform.noArg - def do_abs(implicit sourceInfo: SourceInfo): UInt = this + def do_abs(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = this - def do_& (that: UInt)(implicit sourceInfo: SourceInfo): UInt = + def do_& (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = binop(sourceInfo, UInt(this.width max that.width), BitAndOp, that) - def do_| (that: UInt)(implicit sourceInfo: SourceInfo): UInt = + def do_| (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = binop(sourceInfo, UInt(this.width max that.width), BitOrOp, that) - def do_^ (that: UInt)(implicit sourceInfo: SourceInfo): UInt = + def do_^ (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = binop(sourceInfo, UInt(this.width max that.width), BitXorOp, that) /** Returns this wire bitwise-inverted. */ - def do_unary_~ (implicit sourceInfo: SourceInfo): UInt = + def do_unary_~ (implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = unop(sourceInfo, UInt(width = width), BitNotOp) // REVIEW TODO: Can this be defined on Bits? @@ -463,44 +462,44 @@ sealed class UInt private[core] (width: Width, lit: Option[ULit] = None) final def andR(): Bool = macro SourceInfoTransform.noArg final def xorR(): Bool = macro SourceInfoTransform.noArg - def do_orR(implicit sourceInfo: SourceInfo): Bool = this != 0.U - def do_andR(implicit sourceInfo: SourceInfo): Bool = ~this === 0.U - def do_xorR(implicit sourceInfo: SourceInfo): Bool = redop(sourceInfo, XorReduceOp) + def do_orR(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = this != 0.U + def do_andR(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = ~this === 0.U + def do_xorR(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = redop(sourceInfo, XorReduceOp) - override def do_< (that: UInt)(implicit sourceInfo: SourceInfo): Bool = compop(sourceInfo, LessOp, that) - override def do_> (that: UInt)(implicit sourceInfo: SourceInfo): Bool = compop(sourceInfo, GreaterOp, that) - override def do_<= (that: UInt)(implicit sourceInfo: SourceInfo): Bool = compop(sourceInfo, LessEqOp, that) - override def do_>= (that: UInt)(implicit sourceInfo: SourceInfo): Bool = compop(sourceInfo, GreaterEqOp, that) + override def do_< (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = compop(sourceInfo, LessOp, that) + override def do_> (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = compop(sourceInfo, GreaterOp, that) + override def do_<= (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = compop(sourceInfo, LessEqOp, that) + override def do_>= (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = compop(sourceInfo, GreaterEqOp, that) @deprecated("Use '=/=', which avoids potential precedence problems", "chisel3") final def != (that: UInt): Bool = macro SourceInfoTransform.thatArg final def =/= (that: UInt): Bool = macro SourceInfoTransform.thatArg final def === (that: UInt): Bool = macro SourceInfoTransform.thatArg - def do_!= (that: UInt)(implicit sourceInfo: SourceInfo): Bool = compop(sourceInfo, NotEqualOp, that) - def do_=/= (that: UInt)(implicit sourceInfo: SourceInfo): Bool = compop(sourceInfo, NotEqualOp, that) - def do_=== (that: UInt)(implicit sourceInfo: SourceInfo): Bool = compop(sourceInfo, EqualOp, that) + def do_!= (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = compop(sourceInfo, NotEqualOp, that) + def do_=/= (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = compop(sourceInfo, NotEqualOp, that) + def do_=== (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = compop(sourceInfo, EqualOp, that) final def unary_! () : Bool = macro SourceInfoTransform.noArg - def do_unary_! (implicit sourceInfo: SourceInfo) : Bool = this === 0.U(1.W) + def do_unary_! (implicit sourceInfo: SourceInfo, compileOptions: CompileOptions) : Bool = this === 0.U(1.W) - override def do_<< (that: Int)(implicit sourceInfo: SourceInfo): UInt = + override def do_<< (that: Int)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = binop(sourceInfo, UInt(this.width + that), ShiftLeftOp, that) - override def do_<< (that: BigInt)(implicit sourceInfo: SourceInfo): UInt = + override def do_<< (that: BigInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = this << that.toInt - override def do_<< (that: UInt)(implicit sourceInfo: SourceInfo): UInt = + override def do_<< (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = binop(sourceInfo, UInt(this.width.dynamicShiftLeft(that.width)), DynamicShiftLeftOp, that) - override def do_>> (that: Int)(implicit sourceInfo: SourceInfo): UInt = + override def do_>> (that: Int)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = binop(sourceInfo, UInt(this.width.shiftRight(that)), ShiftRightOp, that) - override def do_>> (that: BigInt)(implicit sourceInfo: SourceInfo): UInt = + override def do_>> (that: BigInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = this >> that.toInt - override def do_>> (that: UInt)(implicit sourceInfo: SourceInfo): UInt = + override def do_>> (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = binop(sourceInfo, UInt(this.width), DynamicShiftRightOp, that) final def bitSet(off: UInt, dat: Bool): UInt = macro UIntTransform.bitset - def do_bitSet(off: UInt, dat: Bool)(implicit sourceInfo: SourceInfo): UInt = { + def do_bitSet(off: UInt, dat: Bool)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = { val bit = 1.U(1.W) << off Mux(dat, this | bit, ~(~this | bit)) } @@ -517,10 +516,10 @@ sealed class UInt private[core] (width: Width, lit: Option[ULit] = None) * SInt is not guaranteed to have the same value (for example, if the MSB is * high, it will be interpreted as a negative value). */ - override def do_asSInt(implicit sourceInfo: SourceInfo): SInt = + override def do_asSInt(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = pushOp(DefPrim(sourceInfo, SInt(width), AsSIntOp, ref)) - override def do_asUInt(implicit sourceInfo: SourceInfo): UInt = this - override def do_asFixedPoint(binaryPoint: BinaryPoint)(implicit sourceInfo: SourceInfo): FixedPoint = { + override def do_asUInt(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = this + override def do_asFixedPoint(binaryPoint: BinaryPoint)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = { binaryPoint match { case KnownBinaryPoint(value) => val iLit = ILit(value) @@ -578,24 +577,24 @@ sealed class SInt private[core] (width: Width, lit: Option[SLit] = None) final def unary_- (): SInt = macro SourceInfoTransform.noArg final def unary_-% (): SInt = macro SourceInfoTransform.noArg - def unary_- (implicit sourceInfo: SourceInfo): SInt = 0.S - this - def unary_-% (implicit sourceInfo: SourceInfo): SInt = 0.S -% this + def unary_- (implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = 0.S - this + def unary_-% (implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = 0.S -% this /** add (default - no growth) operator */ - override def do_+ (that: SInt)(implicit sourceInfo: SourceInfo): SInt = + override def do_+ (that: SInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = this +% that /** subtract (default - no growth) operator */ - override def do_- (that: SInt)(implicit sourceInfo: SourceInfo): SInt = + override def do_- (that: SInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = this -% that - override def do_* (that: SInt)(implicit sourceInfo: SourceInfo): SInt = + override def do_* (that: SInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = binop(sourceInfo, SInt(this.width + that.width), TimesOp, that) - override def do_/ (that: SInt)(implicit sourceInfo: SourceInfo): SInt = + override def do_/ (that: SInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = binop(sourceInfo, SInt(this.width), DivideOp, that) - override def do_% (that: SInt)(implicit sourceInfo: SourceInfo): SInt = + override def do_% (that: SInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = binop(sourceInfo, SInt(this.width), RemOp, that) final def * (that: UInt): SInt = macro SourceInfoTransform.thatArg - def do_* (that: UInt)(implicit sourceInfo: SourceInfo): SInt = + def do_* (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = binop(sourceInfo, SInt(this.width + that.width), TimesOp, that) /** add (width +1) operator */ @@ -607,64 +606,66 @@ sealed class SInt private[core] (width: Width, lit: Option[SLit] = None) /** subtract (no growth) operator */ final def -% (that: SInt): SInt = macro SourceInfoTransform.thatArg - def do_+& (that: SInt)(implicit sourceInfo: SourceInfo): SInt = + def do_+& (that: SInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = binop(sourceInfo, SInt((this.width max that.width) + 1), AddOp, that) - def do_+% (that: SInt)(implicit sourceInfo: SourceInfo): SInt = + def do_+% (that: SInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = (this +& that).tail(1).asSInt - def do_-& (that: SInt)(implicit sourceInfo: SourceInfo): SInt = + def do_-& (that: SInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = binop(sourceInfo, SInt((this.width max that.width) + 1), SubOp, that) - def do_-% (that: SInt)(implicit sourceInfo: SourceInfo): SInt = + def do_-% (that: SInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = (this -& that).tail(1).asSInt final def & (that: SInt): SInt = macro SourceInfoTransform.thatArg final def | (that: SInt): SInt = macro SourceInfoTransform.thatArg final def ^ (that: SInt): SInt = macro SourceInfoTransform.thatArg - def do_& (that: SInt)(implicit sourceInfo: SourceInfo): SInt = + def do_& (that: SInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = binop(sourceInfo, UInt(this.width max that.width), BitAndOp, that).asSInt - def do_| (that: SInt)(implicit sourceInfo: SourceInfo): SInt = + def do_| (that: SInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = binop(sourceInfo, UInt(this.width max that.width), BitOrOp, that).asSInt - def do_^ (that: SInt)(implicit sourceInfo: SourceInfo): SInt = + def do_^ (that: SInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = binop(sourceInfo, UInt(this.width max that.width), BitXorOp, that).asSInt /** Returns this wire bitwise-inverted. */ - def do_unary_~ (implicit sourceInfo: SourceInfo): SInt = + def do_unary_~ (implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = unop(sourceInfo, UInt(width = width), BitNotOp).asSInt - override def do_< (that: SInt)(implicit sourceInfo: SourceInfo): Bool = compop(sourceInfo, LessOp, that) - override def do_> (that: SInt)(implicit sourceInfo: SourceInfo): Bool = compop(sourceInfo, GreaterOp, that) - override def do_<= (that: SInt)(implicit sourceInfo: SourceInfo): Bool = compop(sourceInfo, LessEqOp, that) - override def do_>= (that: SInt)(implicit sourceInfo: SourceInfo): Bool = compop(sourceInfo, GreaterEqOp, that) + override def do_< (that: SInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = compop(sourceInfo, LessOp, that) + override def do_> (that: SInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = compop(sourceInfo, GreaterOp, that) + override def do_<= (that: SInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = compop(sourceInfo, LessEqOp, that) + override def do_>= (that: SInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = compop(sourceInfo, GreaterEqOp, that) @deprecated("Use '=/=', which avoids potential precedence problems", "chisel3") final def != (that: SInt): Bool = macro SourceInfoTransform.thatArg final def =/= (that: SInt): Bool = macro SourceInfoTransform.thatArg final def === (that: SInt): Bool = macro SourceInfoTransform.thatArg - def do_!= (that: SInt)(implicit sourceInfo: SourceInfo): Bool = compop(sourceInfo, NotEqualOp, that) - def do_=/= (that: SInt)(implicit sourceInfo: SourceInfo): Bool = compop(sourceInfo, NotEqualOp, that) - def do_=== (that: SInt)(implicit sourceInfo: SourceInfo): Bool = compop(sourceInfo, EqualOp, that) + def do_!= (that: SInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = compop(sourceInfo, NotEqualOp, that) + def do_=/= (that: SInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = compop(sourceInfo, NotEqualOp, that) + def do_=== (that: SInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = compop(sourceInfo, EqualOp, that) // final def abs(): UInt = macro SourceInfoTransform.noArg - def do_abs(implicit sourceInfo: SourceInfo): SInt = Mux(this < 0.S, (-this), this) + def do_abs(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = { + Mux(this < 0.S, (-this), this) + } - override def do_<< (that: Int)(implicit sourceInfo: SourceInfo): SInt = + override def do_<< (that: Int)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = binop(sourceInfo, SInt(this.width + that), ShiftLeftOp, that) - override def do_<< (that: BigInt)(implicit sourceInfo: SourceInfo): SInt = + override def do_<< (that: BigInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = this << that.toInt - override def do_<< (that: UInt)(implicit sourceInfo: SourceInfo): SInt = + override def do_<< (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = binop(sourceInfo, SInt(this.width.dynamicShiftLeft(that.width)), DynamicShiftLeftOp, that) - override def do_>> (that: Int)(implicit sourceInfo: SourceInfo): SInt = + override def do_>> (that: Int)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = binop(sourceInfo, SInt(this.width.shiftRight(that)), ShiftRightOp, that) - override def do_>> (that: BigInt)(implicit sourceInfo: SourceInfo): SInt = + override def do_>> (that: BigInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = this >> that.toInt - override def do_>> (that: UInt)(implicit sourceInfo: SourceInfo): SInt = + override def do_>> (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = binop(sourceInfo, SInt(this.width), DynamicShiftRightOp, that) - override def do_asUInt(implicit sourceInfo: SourceInfo): UInt = pushOp(DefPrim(sourceInfo, UInt(this.width), AsUIntOp, ref)) - override def do_asSInt(implicit sourceInfo: SourceInfo): SInt = this - override def do_asFixedPoint(binaryPoint: BinaryPoint)(implicit sourceInfo: SourceInfo): FixedPoint = { + override def do_asUInt(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = pushOp(DefPrim(sourceInfo, UInt(this.width), AsUIntOp, ref)) + override def do_asSInt(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = this + override def do_asFixedPoint(binaryPoint: BinaryPoint)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = { binaryPoint match { case KnownBinaryPoint(value) => val iLit = ILit(value) @@ -722,33 +723,33 @@ sealed class Bool(lit: Option[ULit] = None) extends UInt(1.W, lit) { final def | (that: Bool): Bool = macro SourceInfoTransform.thatArg final def ^ (that: Bool): Bool = macro SourceInfoTransform.thatArg - def do_& (that: Bool)(implicit sourceInfo: SourceInfo): Bool = + def do_& (that: Bool)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = binop(sourceInfo, Bool(), BitAndOp, that) - def do_| (that: Bool)(implicit sourceInfo: SourceInfo): Bool = + def do_| (that: Bool)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = binop(sourceInfo, Bool(), BitOrOp, that) - def do_^ (that: Bool)(implicit sourceInfo: SourceInfo): Bool = + def do_^ (that: Bool)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = binop(sourceInfo, Bool(), BitXorOp, that) /** Returns this wire bitwise-inverted. */ - override def do_unary_~ (implicit sourceInfo: SourceInfo): Bool = + override def do_unary_~ (implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = unop(sourceInfo, Bool(), BitNotOp) /** Outputs the logical OR of two Bools. */ def || (that: Bool): Bool = macro SourceInfoTransform.thatArg - def do_|| (that: Bool)(implicit sourceInfo: SourceInfo): Bool = this | that + def do_|| (that: Bool)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = this | that /** Outputs the logical AND of two Bools. */ def && (that: Bool): Bool = macro SourceInfoTransform.thatArg - def do_&& (that: Bool)(implicit sourceInfo: SourceInfo): Bool = this & that + def do_&& (that: Bool)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = this & that /** Reinterprets this Bool as a Clock. */ def asClock(): Clock = macro SourceInfoTransform.noArg - def do_asClock(implicit sourceInfo: SourceInfo): Clock = pushOp(DefPrim(sourceInfo, Clock(), AsClockOp, ref)) + def do_asClock(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Clock = pushOp(DefPrim(sourceInfo, Clock(), AsClockOp, ref)) } trait BoolFactory { @@ -800,28 +801,28 @@ sealed class FixedPoint private (width: Width, val binaryPoint: BinaryPoint, lit final def unary_- (): FixedPoint = macro SourceInfoTransform.noArg final def unary_-% (): FixedPoint = macro SourceInfoTransform.noArg - def unary_- (implicit sourceInfo: SourceInfo): FixedPoint = FixedPoint.fromBigInt(0) - this - def unary_-% (implicit sourceInfo: SourceInfo): FixedPoint = FixedPoint.fromBigInt(0) -% this + def unary_- (implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = FixedPoint.fromBigInt(0) - this + def unary_-% (implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = FixedPoint.fromBigInt(0) -% this /** add (default - no growth) operator */ - override def do_+ (that: FixedPoint)(implicit sourceInfo: SourceInfo): FixedPoint = + override def do_+ (that: FixedPoint)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = this +% that /** subtract (default - no growth) operator */ - override def do_- (that: FixedPoint)(implicit sourceInfo: SourceInfo): FixedPoint = + override def do_- (that: FixedPoint)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = this -% that - override def do_* (that: FixedPoint)(implicit sourceInfo: SourceInfo): FixedPoint = + override def do_* (that: FixedPoint)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = binop(sourceInfo, FixedPoint(this.width + that.width, this.binaryPoint + that.binaryPoint), TimesOp, that) - override def do_/ (that: FixedPoint)(implicit sourceInfo: SourceInfo): FixedPoint = + override def do_/ (that: FixedPoint)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = throwException(s"division is illegal on FixedPoint types") - override def do_% (that: FixedPoint)(implicit sourceInfo: SourceInfo): FixedPoint = + override def do_% (that: FixedPoint)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = throwException(s"mod is illegal on FixedPoint types") final def * (that: UInt): FixedPoint = macro SourceInfoTransform.thatArg - def do_* (that: UInt)(implicit sourceInfo: SourceInfo): FixedPoint = + def do_* (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = binop(sourceInfo, FixedPoint(this.width + that.width, binaryPoint), TimesOp, that) final def * (that: SInt): FixedPoint = macro SourceInfoTransform.thatArg - def do_* (that: SInt)(implicit sourceInfo: SourceInfo): FixedPoint = + def do_* (that: SInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = binop(sourceInfo, FixedPoint(this.width + that.width, binaryPoint), TimesOp, that) /** add (width +1) operator */ @@ -833,29 +834,29 @@ sealed class FixedPoint private (width: Width, val binaryPoint: BinaryPoint, lit /** subtract (no growth) operator */ final def -% (that: FixedPoint): FixedPoint = macro SourceInfoTransform.thatArg - def do_+& (that: FixedPoint)(implicit sourceInfo: SourceInfo): FixedPoint = + def do_+& (that: FixedPoint)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = binop(sourceInfo, FixedPoint((this.width max that.width) + 1, this.binaryPoint max that.binaryPoint), AddOp, that) - def do_+% (that: FixedPoint)(implicit sourceInfo: SourceInfo): FixedPoint = + def do_+% (that: FixedPoint)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = (this +& that).tail(1).asFixedPoint(this.binaryPoint max that.binaryPoint) - def do_-& (that: FixedPoint)(implicit sourceInfo: SourceInfo): FixedPoint = + def do_-& (that: FixedPoint)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = binop(sourceInfo, FixedPoint((this.width max that.width) + 1, this.binaryPoint max that.binaryPoint), SubOp, that) - def do_-% (that: FixedPoint)(implicit sourceInfo: SourceInfo): FixedPoint = + def do_-% (that: FixedPoint)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = (this -& that).tail(1).asFixedPoint(this.binaryPoint max that.binaryPoint) final def & (that: FixedPoint): FixedPoint = macro SourceInfoTransform.thatArg final def | (that: FixedPoint): FixedPoint = macro SourceInfoTransform.thatArg final def ^ (that: FixedPoint): FixedPoint = macro SourceInfoTransform.thatArg - def do_& (that: FixedPoint)(implicit sourceInfo: SourceInfo): FixedPoint = + def do_& (that: FixedPoint)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = throwException(s"And is illegal between $this and $that") - def do_| (that: FixedPoint)(implicit sourceInfo: SourceInfo): FixedPoint = + def do_| (that: FixedPoint)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = throwException(s"Or is illegal between $this and $that") - def do_^ (that: FixedPoint)(implicit sourceInfo: SourceInfo): FixedPoint = + def do_^ (that: FixedPoint)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = throwException(s"Xor is illegal between $this and $that") final def setBinaryPoint(that: Int): FixedPoint = macro SourceInfoTransform.thatArg - def do_setBinaryPoint(that: Int)(implicit sourceInfo: SourceInfo): FixedPoint = this.binaryPoint match { + def do_setBinaryPoint(that: Int)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = this.binaryPoint match { case KnownBinaryPoint(value) => binop(sourceInfo, FixedPoint(this.width + (that - value), KnownBinaryPoint(that)), SetBinaryPoint, that) case _ => @@ -863,44 +864,46 @@ sealed class FixedPoint private (width: Width, val binaryPoint: BinaryPoint, lit } /** Returns this wire bitwise-inverted. */ - def do_unary_~ (implicit sourceInfo: SourceInfo): FixedPoint = + def do_unary_~ (implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = throwException(s"Not is illegal on $this") // TODO(chick): Consider comparison with UInt and SInt - override def do_< (that: FixedPoint)(implicit sourceInfo: SourceInfo): Bool = compop(sourceInfo, LessOp, that) - override def do_> (that: FixedPoint)(implicit sourceInfo: SourceInfo): Bool = compop(sourceInfo, GreaterOp, that) - override def do_<= (that: FixedPoint)(implicit sourceInfo: SourceInfo): Bool = compop(sourceInfo, LessEqOp, that) - override def do_>= (that: FixedPoint)(implicit sourceInfo: SourceInfo): Bool = compop(sourceInfo, GreaterEqOp, that) + override def do_< (that: FixedPoint)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = compop(sourceInfo, LessOp, that) + override def do_> (that: FixedPoint)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = compop(sourceInfo, GreaterOp, that) + override def do_<= (that: FixedPoint)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = compop(sourceInfo, LessEqOp, that) + override def do_>= (that: FixedPoint)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = compop(sourceInfo, GreaterEqOp, that) final def != (that: FixedPoint): Bool = macro SourceInfoTransform.thatArg final def =/= (that: FixedPoint): Bool = macro SourceInfoTransform.thatArg final def === (that: FixedPoint): Bool = macro SourceInfoTransform.thatArg - def do_!= (that: FixedPoint)(implicit sourceInfo: SourceInfo): Bool = compop(sourceInfo, NotEqualOp, that) - def do_=/= (that: FixedPoint)(implicit sourceInfo: SourceInfo): Bool = compop(sourceInfo, NotEqualOp, that) - def do_=== (that: FixedPoint)(implicit sourceInfo: SourceInfo): Bool = compop(sourceInfo, EqualOp, that) + def do_!= (that: FixedPoint)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = compop(sourceInfo, NotEqualOp, that) + def do_=/= (that: FixedPoint)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = compop(sourceInfo, NotEqualOp, that) + def do_=== (that: FixedPoint)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = compop(sourceInfo, EqualOp, that) - def do_abs(implicit sourceInfo: SourceInfo): FixedPoint = { + def do_abs(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = { + // TODO: remove this once we have CompileOptions threaded through the macro system. + import chisel3.core.ExplicitCompileOptions.NotStrict Mux(this < 0.F(0.BP), 0.F(0.BP) - this, this) } - override def do_<< (that: Int)(implicit sourceInfo: SourceInfo): FixedPoint = + override def do_<< (that: Int)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = binop(sourceInfo, FixedPoint(this.width + that, this.binaryPoint), ShiftLeftOp, that) - override def do_<< (that: BigInt)(implicit sourceInfo: SourceInfo): FixedPoint = + override def do_<< (that: BigInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = (this << that.toInt).asFixedPoint(this.binaryPoint) - override def do_<< (that: UInt)(implicit sourceInfo: SourceInfo): FixedPoint = + override def do_<< (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = binop(sourceInfo, FixedPoint(this.width.dynamicShiftLeft(that.width), this.binaryPoint), DynamicShiftLeftOp, that) - override def do_>> (that: Int)(implicit sourceInfo: SourceInfo): FixedPoint = + override def do_>> (that: Int)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = binop(sourceInfo, FixedPoint(this.width.shiftRight(that), this.binaryPoint), ShiftRightOp, that) - override def do_>> (that: BigInt)(implicit sourceInfo: SourceInfo): FixedPoint = + override def do_>> (that: BigInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = (this >> that.toInt).asFixedPoint(this.binaryPoint) - override def do_>> (that: UInt)(implicit sourceInfo: SourceInfo): FixedPoint = + override def do_>> (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = binop(sourceInfo, FixedPoint(this.width, this.binaryPoint), DynamicShiftRightOp, that) - override def do_asUInt(implicit sourceInfo: SourceInfo): UInt = pushOp(DefPrim(sourceInfo, UInt(this.width), AsUIntOp, ref)) - override def do_asSInt(implicit sourceInfo: SourceInfo): SInt = pushOp(DefPrim(sourceInfo, SInt(this.width), AsSIntOp, ref)) + override def do_asUInt(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = pushOp(DefPrim(sourceInfo, UInt(this.width), AsUIntOp, ref)) + override def do_asSInt(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = pushOp(DefPrim(sourceInfo, SInt(this.width), AsSIntOp, ref)) - override def do_asFixedPoint(binaryPoint: BinaryPoint)(implicit sourceInfo: SourceInfo): FixedPoint = { + override def do_asFixedPoint(binaryPoint: BinaryPoint)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = { binaryPoint match { case KnownBinaryPoint(value) => val iLit = ILit(value) @@ -1056,7 +1059,7 @@ final class Analog private (width: Width) extends Element(width) { case _ => throwException("Only Wires and Ports can be of type Analog") } - override def do_asUInt(implicit sourceInfo: SourceInfo): UInt = + override def do_asUInt(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = throwException("Analog does not support asUInt") private[core] override def connectFromBits(that: Bits)(implicit sourceInfo: SourceInfo, diff --git a/chiselFrontend/src/main/scala/chisel3/core/BlackBox.scala b/chiselFrontend/src/main/scala/chisel3/core/BlackBox.scala index 7a1394bb..cd072ba9 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/BlackBox.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/BlackBox.scala @@ -6,8 +6,6 @@ import chisel3.internal.Builder.pushCommand import chisel3.internal.firrtl._ import chisel3.internal.throwException import chisel3.internal.sourceinfo.{SourceInfo, UnlocatableSourceInfo} -// TODO: remove this once we have CompileOptions threaded through the macro system. -import chisel3.core.ExplicitCompileOptions.NotStrict /** Parameters for BlackBoxes */ sealed abstract class Param @@ -132,7 +130,7 @@ abstract class ExtModule(val params: Map[String, Param] = Map.empty[String, Para * }}} * @note The parameters API is experimental and may change */ -abstract class BlackBox(val params: Map[String, Param] = Map.empty[String, Param]) extends BaseBlackBox { +abstract class BlackBox(val params: Map[String, Param] = Map.empty[String, Param])(implicit compileOptions: CompileOptions) extends BaseBlackBox { def io: Record // Allow access to bindings from the compatibility package diff --git a/chiselFrontend/src/main/scala/chisel3/core/Data.scala b/chiselFrontend/src/main/scala/chisel3/core/Data.scala index c17672ff..30e1bf97 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/Data.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/Data.scala @@ -304,7 +304,7 @@ abstract class Data extends HasId { * This performs the inverse operation of fromBits(Bits). */ @deprecated("Best alternative, .asUInt()", "chisel3") - def toBits(): UInt = do_asUInt(DeprecatedSourceInfo) + def toBits(implicit compileOptions: CompileOptions): UInt = do_asUInt(DeprecatedSourceInfo, compileOptions) /** Does a reinterpret cast of the bits in this node into the format that provides. * Returns a new Wire of that type. Does not modify existing nodes. @@ -336,7 +336,7 @@ abstract class Data extends HasId { */ final def asUInt(): UInt = macro SourceInfoTransform.noArg - def do_asUInt(implicit sourceInfo: SourceInfo): UInt + def do_asUInt(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt // firrtlDirection is the direction we report to firrtl. // It maintains the user-specified value (as opposed to the "actual" or applied/propagated value). @@ -411,7 +411,7 @@ sealed class Clock extends Element(Width(1)) { /** Not really supported */ def toPrintable: Printable = PString("CLOCK") - override def do_asUInt(implicit sourceInfo: SourceInfo): UInt = pushOp(DefPrim(sourceInfo, UInt(this.width), AsUIntOp, ref)) + override def do_asUInt(implicit sourceInfo: SourceInfo, connectCompileOptions: CompileOptions): UInt = pushOp(DefPrim(sourceInfo, UInt(this.width), AsUIntOp, ref)) private[core] override def connectFromBits(that: Bits)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Unit = { this := that diff --git a/chiselFrontend/src/main/scala/chisel3/core/Mem.scala b/chiselFrontend/src/main/scala/chisel3/core/Mem.scala index f935e4ee..03c484b0 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/Mem.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/Mem.scala @@ -7,13 +7,11 @@ import scala.language.experimental.macros import chisel3.internal._ import chisel3.internal.Builder.pushCommand import chisel3.internal.firrtl._ -import chisel3.internal.sourceinfo.{SourceInfo, DeprecatedSourceInfo, UnlocatableSourceInfo, MemTransform} -// TODO: remove this once we have CompileOptions threaded through the macro system. -import chisel3.core.ExplicitCompileOptions.NotStrict +import chisel3.internal.sourceinfo.{SourceInfo, SourceInfoTransform, UnlocatableSourceInfo, MemTransform} object Mem { @deprecated("Mem argument order should be size, t; this will be removed by the official release", "chisel3") - def apply[T <: Data](t: T, size: Int): Mem[T] = do_apply(size, t)(UnlocatableSourceInfo) + def apply[T <: Data](t: T, size: Int)(implicit compileOptions: CompileOptions): Mem[T] = do_apply(size, t)(UnlocatableSourceInfo, compileOptions) /** Creates a combinational/asynchronous-read, sequential/synchronous-write [[Mem]]. * @@ -21,7 +19,7 @@ object Mem { * @param t data type of memory element */ def apply[T <: Data](size: Int, t: T): Mem[T] = macro MemTransform.apply[T] - def do_apply[T <: Data](size: Int, t: T)(implicit sourceInfo: SourceInfo): Mem[T] = { + def do_apply[T <: Data](size: Int, t: T)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Mem[T] = { val mt = t.chiselCloneType Binding.bind(mt, NoDirectionBinder, "Error: fresh t") // TODO(twigg): Remove need for this Binding @@ -38,7 +36,9 @@ sealed abstract class MemBase[T <: Data](t: T, val length: Int) extends HasId { /** Creates a read accessor into the memory with static addressing. See the * class documentation of the memory for more detailed information. */ - def apply(idx: Int): T = { + def apply(x: Int): T = macro SourceInfoTransform.xArg + + def do_apply(idx: Int)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T = { require(idx >= 0 && idx < length) apply(idx.asUInt) } @@ -46,19 +46,19 @@ sealed abstract class MemBase[T <: Data](t: T, val length: Int) extends HasId { /** Creates a read/write accessor into the memory with dynamic addressing. * See the class documentation of the memory for more detailed information. */ - def apply(idx: UInt): T = makePort(UnlocatableSourceInfo, idx, MemPortDirection.INFER) + def apply(idx: UInt)(implicit compileOptions: CompileOptions): T = makePort(UnlocatableSourceInfo, idx, MemPortDirection.INFER) /** Creates a read accessor into the memory with dynamic addressing. See the * class documentation of the memory for more detailed information. */ - def read(idx: UInt): T = makePort(UnlocatableSourceInfo, idx, MemPortDirection.READ) + def read(idx: UInt)(implicit compileOptions: CompileOptions): T = makePort(UnlocatableSourceInfo, idx, MemPortDirection.READ) /** Creates a write accessor into the memory. * * @param idx memory element index to write into * @param data new data to write */ - def write(idx: UInt, data: T): Unit = { + def write(idx: UInt, data: T)(implicit compileOptions: CompileOptions): Unit = { implicit val sourceInfo = UnlocatableSourceInfo makePort(UnlocatableSourceInfo, idx, MemPortDirection.WRITE) := data } @@ -72,7 +72,7 @@ sealed abstract class MemBase[T <: Data](t: T, val length: Int) extends HasId { * * @note this is only allowed if the memory's element data type is a Vec */ - def write(idx: UInt, data: T, mask: Seq[Bool]) (implicit evidence: T <:< Vec[_]): Unit = { + def write(idx: UInt, data: T, mask: Seq[Bool]) (implicit evidence: T <:< Vec[_], compileOptions: CompileOptions): Unit = { implicit val sourceInfo = UnlocatableSourceInfo val accessor = makePort(sourceInfo, idx, MemPortDirection.WRITE).asInstanceOf[Vec[Data]] val dataVec = data.asInstanceOf[Vec[Data]] @@ -86,9 +86,9 @@ sealed abstract class MemBase[T <: Data](t: T, val length: Int) extends HasId { when (cond) { port := datum } } - private def makePort(sourceInfo: SourceInfo, idx: UInt, dir: MemPortDirection): T = { + private def makePort(sourceInfo: SourceInfo, idx: UInt, dir: MemPortDirection)(implicit compileOptions: CompileOptions): T = { Binding.checkSynthesizable(idx, s"'idx' ($idx)") - val i = Vec.truncateIndex(idx, length)(sourceInfo) + val i = Vec.truncateIndex(idx, length)(sourceInfo, compileOptions) val port = pushCommand( DefMemPort(sourceInfo, @@ -113,7 +113,7 @@ sealed class Mem[T <: Data](t: T, length: Int) extends MemBase(t, length) object SyncReadMem { @deprecated("SeqMem/SyncReadMem argument order should be size, t; this will be removed by the official release", "chisel3") - def apply[T <: Data](t: T, size: Int): SyncReadMem[T] = do_apply(size, t)(DeprecatedSourceInfo) + def apply[T <: Data](t: T, size: Int)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SyncReadMem[T] = do_apply(size, t) /** Creates a sequential/synchronous-read, sequential/synchronous-write [[SyncReadMem]]. * @@ -122,7 +122,7 @@ object SyncReadMem { */ def apply[T <: Data](size: Int, t: T): SyncReadMem[T] = macro MemTransform.apply[T] - def do_apply[T <: Data](size: Int, t: T)(implicit sourceInfo: SourceInfo): SyncReadMem[T] = { + def do_apply[T <: Data](size: Int, t: T)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SyncReadMem[T] = { val mt = t.chiselCloneType Binding.bind(mt, NoDirectionBinder, "Error: fresh t") // TODO(twigg): Remove need for this Binding @@ -144,8 +144,7 @@ object SyncReadMem { * result is undefined (unlike Vec, where the last assignment wins) */ sealed class SyncReadMem[T <: Data](t: T, n: Int) extends MemBase[T](t, n) { - def read(addr: UInt, enable: Bool): T = { - implicit val sourceInfo = UnlocatableSourceInfo + def read(addr: UInt, enable: Bool)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T = { val a = Wire(UInt()) var port: Option[T] = None when (enable) { diff --git a/chiselFrontend/src/main/scala/chisel3/core/MonoConnect.scala b/chiselFrontend/src/main/scala/chisel3/core/MonoConnect.scala index 60f500cd..0cf035f4 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/MonoConnect.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/MonoConnect.scala @@ -67,6 +67,7 @@ object MonoConnect { if(sink_v.length != source_v.length) { throw MismatchedVecException } for(idx <- 0 until sink_v.length) { try { + implicit val compileOptions = connectCompileOptions connect(sourceInfo, connectCompileOptions, sink_v(idx), source_v(idx), context_mod) } catch { case MonoConnectException(message) => throw MonoConnectException(s"($idx)$message") diff --git a/chiselFrontend/src/main/scala/chisel3/core/Printf.scala b/chiselFrontend/src/main/scala/chisel3/core/Printf.scala index 2052e95a..d6e2c8de 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/Printf.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/Printf.scala @@ -40,7 +40,7 @@ object printf { // scalastyle:ignore object.name * @param fmt printf format string * @param data format string varargs containing data to print */ - def apply(fmt: String, data: Bits*)(implicit sourceInfo: SourceInfo): Unit = + def apply(fmt: String, data: Bits*)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Unit = apply(Printable.pack(fmt, data:_*)) /** Prints a message in simulation. * @@ -54,17 +54,16 @@ object printf { // scalastyle:ignore object.name * * @param pable [[Printable]] to print */ - def apply(pable: Printable)(implicit sourceInfo: SourceInfo): Unit = { + def apply(pable: Printable)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Unit = { when (!Builder.forcedReset) { printfWithoutReset(pable) } } - private[chisel3] def printfWithoutReset(pable: Printable)(implicit sourceInfo: SourceInfo): Unit = { + private[chisel3] def printfWithoutReset(pable: Printable)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Unit = { val clock = Builder.forcedClock pushCommand(Printf(sourceInfo, Node(clock), pable)) } - - private[chisel3] def printfWithoutReset(fmt: String, data: Bits*)(implicit sourceInfo: SourceInfo): Unit = + private[chisel3] def printfWithoutReset(fmt: String, data: Bits*)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Unit = printfWithoutReset(Printable.pack(fmt, data:_*)) } diff --git a/chiselFrontend/src/main/scala/chisel3/core/SeqUtils.scala b/chiselFrontend/src/main/scala/chisel3/core/SeqUtils.scala index 02382e57..db3928e3 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/SeqUtils.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/SeqUtils.scala @@ -18,7 +18,7 @@ private[chisel3] object SeqUtils { */ def asUInt[T <: Bits](in: Seq[T]): UInt = macro SourceInfoTransform.inArg - def do_asUInt[T <: Bits](in: Seq[T])(implicit sourceInfo: SourceInfo): UInt = { + def do_asUInt[T <: Bits](in: Seq[T])(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = { if (in.tail.isEmpty) { in.head.asUInt } else { @@ -32,7 +32,7 @@ private[chisel3] object SeqUtils { */ def count(in: Seq[Bool]): UInt = macro SourceInfoTransform.inArg - def do_count(in: Seq[Bool])(implicit sourceInfo: SourceInfo): UInt = in.size match { + def do_count(in: Seq[Bool])(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = in.size match { case 0 => 0.U case 1 => in.head case n => count(in take n/2) +& count(in drop n/2) diff --git a/chiselFrontend/src/main/scala/chisel3/core/When.scala b/chiselFrontend/src/main/scala/chisel3/core/When.scala index 9b646855..26f939ba 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/When.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/When.scala @@ -27,7 +27,7 @@ object when { // scalastyle:ignore object.name * } * }}} */ - def apply(cond: Bool)(block: => Unit)(implicit sourceInfo: SourceInfo): WhenContext = { + def apply(cond: Bool)(block: => Unit)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): WhenContext = { new WhenContext(sourceInfo, cond, !cond, block) } } @@ -43,14 +43,14 @@ final class WhenContext(sourceInfo: SourceInfo, cond: Bool, prevCond: => Bool, b /** This block of logic gets executed if above conditions have been false * and this condition is true. */ - def elsewhen (elseCond: Bool)(block: => Unit)(implicit sourceInfo: SourceInfo): WhenContext = { + def elsewhen (elseCond: Bool)(block: => Unit)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): WhenContext = { new WhenContext(sourceInfo, prevCond && elseCond, prevCond && !elseCond, block) } /** This block of logic gets executed only if the above conditions were all * false. No additional logic blocks may be appended past the `otherwise`. */ - def otherwise(block: => Unit)(implicit sourceInfo: SourceInfo): Unit = + def otherwise(block: => Unit)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Unit = new WhenContext(sourceInfo, prevCond, null, block) pushCommand(WhenBegin(sourceInfo, cond.ref)) |
