Skip to content

Commit

Permalink
Revert "Deprecate auto-application of empty argument lists to paramet…
Browse files Browse the repository at this point in the history
…erless functions (#2124)"

This reverts commit 110705e.
  • Loading branch information
sequencer committed Oct 7, 2021
1 parent 9a65a9e commit 3952ced
Show file tree
Hide file tree
Showing 20 changed files with 95 additions and 210 deletions.
2 changes: 1 addition & 1 deletion core/src/main/scala/chisel3/Aggregate.scala
Expand Up @@ -54,7 +54,7 @@ sealed abstract class Aggregate extends Data {
override def litOption: Option[BigInt] = {
// Shift the accumulated value by our width and add in our component, masked by our width.
def shiftAdd(accumulator: Option[BigInt], elt: Data): Option[BigInt] = {
(accumulator, elt.litOption) match {
(accumulator, elt.litOption()) match {
case (Some(accumulator), Some(eltLit)) =>
val width = elt.width.get
val masked = ((BigInt(1) << width) - 1) & eltLit // also handles the negative case with two's complement
Expand Down
115 changes: 27 additions & 88 deletions core/src/main/scala/chisel3/Bits.scala
Expand Up @@ -25,10 +25,7 @@ private[chisel3] sealed trait ToBoolable extends Element {
*
* @note The width must be known and equal to 1
*/
final def asBool: Bool = macro SourceInfoWhiteboxTransform.noArg

@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "Chisel 3.5")
final def asBool(dummy: Int*): Bool = macro SourceInfoWhiteboxTransform.noArgDummy
final def asBool(): Bool = macro SourceInfoWhiteboxTransform.noArg

/** @group SourceInfoTransformMacro */
def do_asBool(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool
Expand Down Expand Up @@ -225,10 +222,7 @@ sealed abstract class Bits(private[chisel3] val width: Width) extends Element wi
* @return this $coll with each bit inverted
* @group Bitwise
*/
final def unary_~ : Bits = macro SourceInfoWhiteboxTransform.noArg

@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "Chisel 3.5")
final def unary_~(dummy: Int*): Bits = macro SourceInfoWhiteboxTransform.noArgDummy
final def unary_~ (): Bits = macro SourceInfoWhiteboxTransform.noArg

/** @group SourceInfoTransformMacro */
def do_unary_~ (implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bits
Expand Down Expand Up @@ -310,16 +304,10 @@ sealed abstract class Bits(private[chisel3] val width: Width) extends Element wi
def do_>> (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bits

/** Returns the contents of this wire as a [[scala.collection.Seq]] of [[Bool]]. */
final def toBools: Seq[Bool] = macro SourceInfoTransform.noArg

@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "Chisel 3.5")
final def toBools(dummy: Int*): Seq[Bool] = macro SourceInfoWhiteboxTransform.noArgDummy
final def toBools(): Seq[Bool] = macro SourceInfoTransform.noArg

/** Returns the contents of this wire as a [[scala.collection.Seq]] of [[Bool]]. */
final def asBools: Seq[Bool] = macro SourceInfoTransform.noArg

@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "Chisel 3.5")
final def asBools(dummy: Int*): Seq[Bool] = macro SourceInfoWhiteboxTransform.noArgDummy
final def asBools(): Seq[Bool] = macro SourceInfoTransform.noArg

/** @group SourceInfoTransformMacro */
def do_asBools(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Seq[Bool] =
Expand All @@ -330,10 +318,7 @@ sealed abstract class Bits(private[chisel3] val width: Width) extends Element wi
* @note The arithmetic value is not preserved if the most-significant bit is set. For example, a [[UInt]] of
* width 3 and value 7 (0b111) would become an [[SInt]] of width 3 and value -1.
*/
final def asSInt: SInt = macro SourceInfoTransform.noArg

@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "Chisel 3.5")
final def asSInt(dummy: Int*): SInt = macro SourceInfoWhiteboxTransform.noArgDummy
final def asSInt(): SInt = macro SourceInfoTransform.noArg

/** @group SourceInfoTransformMacro */
def do_asSInt(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt
Expand Down Expand Up @@ -425,21 +410,15 @@ sealed class UInt private[chisel3] (width: Width) extends Bits(width) with Num[U
* $constantWidth
* @group Arithmetic
*/
final def unary_- : UInt = macro SourceInfoTransform.noArg

@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "Chisel 3.5")
final def unary_-(dummy: Int*): UInt = macro SourceInfoTransform.noArgDummy
final def unary_- (): UInt = macro SourceInfoTransform.noArg

/** Unary negation (constant width)
*
* @return a $coll equal to zero minus this $coll shifted right by one.
* $constantWidth
* @group Arithmetic
*/
final def unary_-% : UInt = macro SourceInfoTransform.noArg

@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "Chisel 3.5")
final def unary_%(dummy: Int*): UInt = macro SourceInfoTransform.noArgDummy
final def unary_-% (): UInt = macro SourceInfoTransform.noArg

/** @group SourceInfoTransformMacro */
def do_unary_- (implicit sourceInfo: SourceInfo, compileOptions: CompileOptions) : UInt = 0.U - this
Expand Down Expand Up @@ -543,7 +522,7 @@ sealed class UInt private[chisel3] (width: Width) extends Bits(width) with Num[U
*/
final def ^ (that: UInt): UInt = macro SourceInfoTransform.thatArg

// override def abs: UInt = macro SourceInfoTransform.noArgDummy
// override def abs: UInt = macro SourceInfoTransform.noArg
def do_abs(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = this

/** @group SourceInfoTransformMacro */
Expand All @@ -566,30 +545,21 @@ sealed class UInt private[chisel3] (width: Width) extends Bits(width) with Num[U
* @return a hardware [[Bool]] resulting from every bit of this $coll or'd together
* @group Bitwise
*/
final def orR: Bool = macro SourceInfoTransform.noArg

@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "Chisel 3.5")
final def orR(dummy: Int*): Bool = macro SourceInfoTransform.noArgDummy
final def orR(): Bool = macro SourceInfoTransform.noArg

/** And reduction operator
*
* @return a hardware [[Bool]] resulting from every bit of this $coll and'd together
* @group Bitwise
*/
final def andR: Bool = macro SourceInfoTransform.noArg

@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "Chisel 3.5")
final def andR(dummy: Int*): Bool = macro SourceInfoTransform.noArgDummy
final def andR(): Bool = macro SourceInfoTransform.noArg

/** Exclusive or (xor) reduction operator
*
* @return a hardware [[Bool]] resulting from every bit of this $coll xor'd together
* @group Bitwise
*/
final def xorR: Bool = macro SourceInfoTransform.noArg

@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "Chisel 3.5")
final def xorR(dummy: Int*): Bool = macro SourceInfoTransform.noArgDummy
final def xorR(): Bool = macro SourceInfoTransform.noArg

/** @group SourceInfoTransformMacro */
def do_orR(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = redop(sourceInfo, OrReduceOp)
Expand Down Expand Up @@ -629,10 +599,7 @@ sealed class UInt private[chisel3] (width: Width) extends Bits(width) with Num[U
* @return a hardware [[Bool]] asserted if this $coll equals zero
* @group Bitwise
*/
final def unary_! : Bool = macro SourceInfoTransform.noArg

@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "Chisel 3.5")
final def unary_! (dummy: Int*): Bool = macro SourceInfoTransform.noArgDummy
final def unary_! () : Bool = macro SourceInfoTransform.noArg

/** @group SourceInfoTransformMacro */
def do_unary_! (implicit sourceInfo: SourceInfo, compileOptions: CompileOptions) : Bool = this === 0.U(1.W)
Expand Down Expand Up @@ -717,11 +684,7 @@ sealed class UInt private[chisel3] (width: Width) extends Bits(width) with Num[U
* @return an [[SInt]] equal to this $coll with an additional zero in its most significant bit
* @note The width of the returned [[SInt]] is `width of this` + `1`.
*/
final def zext: SInt = macro SourceInfoTransform.noArg

@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "Chisel 3.5")
final def zext(dummy: Int*): SInt = macro SourceInfoTransform.noArgDummy

final def zext(): SInt = macro SourceInfoTransform.noArg
/** @group SourceInfoTransformMacro */
def do_zext(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt =
pushOp(DefPrim(sourceInfo, SInt(width + 1), ConvertOp, ref))
Expand Down Expand Up @@ -798,26 +761,20 @@ sealed class SInt private[chisel3] (width: Width) extends Bits(width) with Num[S
* $constantWidth
* @group Arithmetic
*/
final def unary_- : SInt = macro SourceInfoTransform.noArg

@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "Chisel 3.5")
final def unary_-(dummy: Int*): SInt = macro SourceInfoTransform.noArgDummy
final def unary_- (): SInt = macro SourceInfoTransform.noArg

/** Unary negation (constant width)
*
* @return a hardware $coll equal to zero minus `this` shifted right by one
* $constantWidth
* @group Arithmetic
*/
final def unary_-% : SInt = macro SourceInfoTransform.noArg

@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "Chisel 3.5")
final def unary_-%(dummy: Int*): SInt = macro SourceInfoTransform.noArgDummy
final def unary_-% (): SInt = macro SourceInfoTransform.noArg

/** @group SourceInfoTransformMacro */
def do_unary_- (implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = 0.S - this
def unary_- (implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = 0.S - this
/** @group SourceInfoTransformMacro */
def do_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, compileOptions: CompileOptions): SInt =
Expand All @@ -843,7 +800,7 @@ sealed class SInt private[chisel3] (width: Width) extends Bits(width) with Num[S
final def * (that: UInt): SInt = macro SourceInfoTransform.thatArg
/** @group SourceInfoTransformMacro */
def do_* (that: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = {
val thatToSInt = that.zext
val thatToSInt = that.zext()
val result = binop(sourceInfo, SInt(this.width + thatToSInt.width), TimesOp, thatToSInt)
result.tail(1).asSInt
}
Expand Down Expand Up @@ -964,10 +921,10 @@ sealed class SInt private[chisel3] (width: Width) extends Bits(width) with Num[S
/** @group SourceInfoTransformMacro */
def do_=== (that: SInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = compop(sourceInfo, EqualOp, that)

// final def abs(): UInt = macro SourceInfoTransform.noArgDummy
// final def abs(): UInt = macro SourceInfoTransform.noArg

def do_abs(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = {
Mux(this < 0.S, -this, this)
Mux(this < 0.S, (-this), this)
}

override def do_<< (that: Int)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt =
Expand Down Expand Up @@ -1026,10 +983,7 @@ sealed class SInt private[chisel3] (width: Width) extends Bits(width) with Num[S

sealed trait Reset extends Element with ToBoolable {
/** Casts this $coll to an [[AsyncReset]] */
final def asAsyncReset: AsyncReset = macro SourceInfoWhiteboxTransform.noArg

@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "Chisel 3.5")
final def asAsyncReset(dummy: Int*): AsyncReset = macro SourceInfoTransform.noArgDummy
final def asAsyncReset(): AsyncReset = macro SourceInfoWhiteboxTransform.noArg

/** @group SourceInfoTransformMacro */
def do_asAsyncReset(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): AsyncReset
Expand Down Expand Up @@ -1215,10 +1169,7 @@ sealed class Bool() extends UInt(1.W) with Reset {
def do_&& (that: Bool)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = this & that

/** Reinterprets this $coll as a clock */
def asClock: Clock = macro SourceInfoTransform.noArg

@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "Chisel 3.5")
def asClock(dummy: Int*): Clock = macro SourceInfoTransform.noArgDummy
def asClock(): Clock = macro SourceInfoTransform.noArg

/** @group SourceInfoTransformMacro */
def do_asClock(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Clock = pushOp(DefPrim(sourceInfo, Clock(), AsClockOp, ref))
Expand Down Expand Up @@ -1314,20 +1265,15 @@ package experimental {
* $expandingWidth
* @group Arithmetic
*/
final def unary_- : FixedPoint = macro SourceInfoTransform.noArg

@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "Chisel 3.5")
final def unary_-(dummy: Int*): FixedPoint = macro SourceInfoTransform.noArgDummy
final def unary_- (): FixedPoint = macro SourceInfoTransform.noArg

/** Unary negation (constant width)
*
* @return a hardware $coll equal to zero minus `this` shifted right by one
* $constantWidth
* @group Arithmetic
*/
final def unary_-% : FixedPoint = macro SourceInfoTransform.noArg
@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "Chisel 3.5")
final def unary_-%(dummy: Int*): FixedPoint = macro SourceInfoTransform.noArgDummy
final def unary_-% (): FixedPoint = macro SourceInfoTransform.noArg

/** @group SourceInfoTransformMacro */
def unary_- (implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint = FixedPoint.fromBigInt(0) - this
Expand Down Expand Up @@ -1762,15 +1708,8 @@ package experimental {
}
}

final def unary_- : Interval = macro SourceInfoTransform.noArg

@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "Chisel 3.5")
final def unary_-(dummy: Int*): Interval = macro SourceInfoTransform.noArgDummy

final def unary_-% : Interval = macro SourceInfoTransform.noArg

@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "Chisel 3.5")
final def unary_-%(dummy: Int*): Interval = macro SourceInfoTransform.noArgDummy
final def unary_-(): Interval = macro SourceInfoTransform.noArg
final def unary_-%(): Interval = macro SourceInfoTransform.noArg

def unary_-(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Interval = {
Interval.Zero - this
Expand Down Expand Up @@ -1885,7 +1824,7 @@ package experimental {
def do_=/= (that: Interval)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = compop(sourceInfo, NotEqualOp, that)
def do_=== (that: Interval)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = compop(sourceInfo, EqualOp, that)

// final def abs(): UInt = macro SourceInfoTransform.noArgDummy
// final def abs(): UInt = macro SourceInfoTransform.noArg

def do_abs(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Interval = {
Mux(this < Interval.Zero, (Interval.Zero - this), this)
Expand Down
8 changes: 2 additions & 6 deletions core/src/main/scala/chisel3/Clock.scala
Expand Up @@ -32,12 +32,8 @@ sealed class Clock(private[chisel3] val width: Width = Width(1)) extends Element
def toPrintable: Printable = PString("CLOCK")

/** Returns the contents of the clock wire as a [[Bool]]. */
final def asBool: Bool = macro SourceInfoTransform.noArg

@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "Chisel 3.5")
final def asBool(dummy: Int*): Bool = macro SourceInfoTransform.noArgDummy

def do_asBool(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = this.asUInt.asBool
final def asBool(): Bool = macro SourceInfoTransform.noArg
def do_asBool(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = this.asUInt().asBool()

override def do_asUInt(implicit sourceInfo: SourceInfo, connectCompileOptions: CompileOptions): UInt = pushOp(DefPrim(sourceInfo, UInt(this.width), AsUIntOp, ref))
private[chisel3] override def connectFromBits(that: Bits)(implicit sourceInfo: SourceInfo,
Expand Down
25 changes: 6 additions & 19 deletions core/src/main/scala/chisel3/Data.scala
Expand Up @@ -645,28 +645,18 @@ abstract class Data extends HasId with NamedComponent with SourceInfoDoc {
}
}

def isLit: Boolean = litOption.isDefined

@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "Chisel 3.5")
def isLit(dummy: Int*): Boolean = isLit

def isLit(): Boolean = litOption.isDefined

/**
* If this is a literal that is representable as bits, returns the value as a BigInt.
* If not a literal, or not representable as bits (for example, is or contains Analog), returns None.
*/
def litOption: Option[BigInt]

@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "Chisel 3.5")
def litOption(dummy: Int*): Option[BigInt] = litOption
def litOption(): Option[BigInt]

/**
* Returns the literal value if this is a literal that is representable as bits, otherwise crashes.
*/
def litValue: BigInt = litOption.get

@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "Chisel 3.5")
def litValue(dummy: Int*): BigInt = litValue
def litValue(): BigInt = litOption.get

/** Returns the width, in bits, if currently known. */
final def getWidth: Int =
Expand All @@ -689,7 +679,7 @@ abstract class Data extends HasId with NamedComponent with SourceInfoDoc {
/** @group SourceInfoTransformMacro */
def do_asTypeOf[T <: Data](that: T)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T = {
val thatCloned = Wire(that.cloneTypeFull)
thatCloned.connectFromBits(this.asUInt)
thatCloned.connectFromBits(this.asUInt())
thatCloned
}

Expand All @@ -705,10 +695,7 @@ abstract class Data extends HasId with NamedComponent with SourceInfoDoc {
* @note Aggregates are recursively packed with the first element appearing
* in the least-significant bits of the result.
*/
final def asUInt: UInt = macro SourceInfoTransform.noArg

@deprecated("Calling this function with an empty argument list is invalid in Scala 3. Use the form without parentheses instead", "Chisel 3.5")
final def asUInt(dummy: Int*): UInt = macro SourceInfoTransform.noArgDummy
final def asUInt(): UInt = macro SourceInfoTransform.noArg

/** @group SourceInfoTransformMacro */
def do_asUInt(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt
Expand All @@ -728,7 +715,7 @@ trait WireFactory {
val x = t.cloneTypeFull

// Bind each element of x to being a Wire
x.bind(WireBinding(Builder.forcedUserModule, Builder.currentWhen))
x.bind(WireBinding(Builder.forcedUserModule, Builder.currentWhen()))

pushCommand(DefWire(sourceInfo, x))
if (!compileOptions.explicitInvalidate) {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/chisel3/Mem.scala
Expand Up @@ -130,7 +130,7 @@ sealed abstract class MemBase[T <: Data](val t: T, val length: BigInt) extends H
t.cloneTypeFull, Node(this), dir, i.ref, Builder.forcedClock.ref)
).id
// Bind each element of port to being a MemoryPort
port.bind(MemoryPortBinding(Builder.forcedUserModule, Builder.currentWhen))
port.bind(MemoryPortBinding(Builder.forcedUserModule, Builder.currentWhen()))
port
}
}
Expand Down

0 comments on commit 3952ced

Please sign in to comment.