Skip to content

Commit

Permalink
Remove deprecated code from core (#2758)
Browse files Browse the repository at this point in the history
* Remove parenthesized forms of:
`.unary_-()`, `.unary_%()`, `.unary_~()`, `.unary_!()`,
`.orR()`, `.andR()`, `.xorR()`,  `.zext()`, 
`.asBool()`, `.asBools()`, `.asSInt()`, `.asAsyncReset()`,
`.asClock()`, `.isLit()`, `.litOption()`, `.litValue()`,
`.abs()`
* Remove protected `Data.bindingToString`
* Remove `RawModule.getPorts`
* Remove `._applyMacroWithMessage` in assert and assume
* Remove `stop` that accepts non-zero return code
* Remove public `WhenContext` constructor
* Remove parenthesized `WhenContext.active()`
* Remove `blacklistPackages`, `builderName`, and `chiselStackTrace` from `ChiselException`
* Remove `MultiIOModule` (`Module` can have multiple `IOs`)
* Remove `chisel3.getModulePorts`
* Undo deprecation of `Data.flatten` which is package private and useful
* Also remove all internal uses of these removed methods

Co-authored-by: Jack Koenig <[email protected]>
  • Loading branch information
chick and jackkoenig authored Dec 7, 2022
1 parent 9f080d5 commit 7372c9e
Show file tree
Hide file tree
Showing 41 changed files with 109 additions and 460 deletions.
2 changes: 1 addition & 1 deletion core/src/main/scala/chisel3/Aggregate.scala
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ sealed abstract class Aggregate extends Data {
}

override def do_asUInt(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = {
SeqUtils.do_asUInt(flatten.map(_.asUInt()))
SeqUtils.do_asUInt(flatten.map(_.asUInt))
}

private[chisel3] override def connectFromBits(
Expand Down
115 changes: 1 addition & 114 deletions core/src/main/scala/chisel3/Bits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ private[chisel3] sealed trait ToBoolable extends Element {
*/
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

/** @group SourceInfoTransformMacro */
def do_asBool(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool
}
Expand Down Expand Up @@ -269,12 +263,6 @@ sealed abstract class Bits(private[chisel3] val width: Width) extends Element wi
*/
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

/** @group SourceInfoTransformMacro */
def do_unary_~(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bits

Expand Down Expand Up @@ -357,12 +345,6 @@ sealed abstract class Bits(private[chisel3] val width: Width) extends Element wi
/** 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

/** @group SourceInfoTransformMacro */
def do_asBools(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Seq[Bool] =
Seq.tabulate(this.getWidth)(i => this(i))
Expand All @@ -374,12 +356,6 @@ sealed abstract class Bits(private[chisel3] val width: Width) extends Element wi
*/
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

/** @group SourceInfoTransformMacro */
def do_asSInt(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt

Expand Down Expand Up @@ -476,12 +452,6 @@ sealed class UInt private[chisel3] (width: Width) extends Bits(width) with Num[U
*/
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

/** Unary negation (constant width)
*
* @return a $coll equal to zero minus this $coll shifted right by one.
Expand All @@ -490,12 +460,6 @@ sealed class UInt private[chisel3] (width: Width) extends Bits(width) with Num[U
*/
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

/** @group SourceInfoTransformMacro */
def do_unary_-(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = 0.U - this

Expand Down Expand Up @@ -630,38 +594,20 @@ sealed class UInt private[chisel3] (width: Width) extends Bits(width) with Num[U
*/
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

/** 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

/** 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

/** @group SourceInfoTransformMacro */
def do_orR(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = redop(sourceInfo, OrReduceOp)

Expand Down Expand Up @@ -711,12 +657,6 @@ sealed class UInt private[chisel3] (width: Width) extends Bits(width) with Num[U
*/
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

/** @group SourceInfoTransformMacro */
def do_unary_!(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = this === 0.U(1.W)

Expand Down Expand Up @@ -771,7 +711,7 @@ sealed class UInt private[chisel3] (width: Width) extends Bits(width) with Num[U
implicit sourceInfo: SourceInfo,
compileOptions: CompileOptions
): UInt =
n.asBools().zipWithIndex.foldLeft(this) {
n.asBools.zipWithIndex.foldLeft(this) {
case (in, (en, sh)) => Mux(en, staticShift(in, 1 << sh), in)
}

Expand Down Expand Up @@ -807,12 +747,6 @@ sealed class UInt private[chisel3] (width: Width) extends Bits(width) with Num[U
*/
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

/** @group SourceInfoTransformMacro */
def do_zext(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt =
pushOp(DefPrim(sourceInfo, SInt(width + 1), ConvertOp, ref))
Expand Down Expand Up @@ -904,12 +838,6 @@ sealed class SInt private[chisel3] (width: Width) extends Bits(width) with Num[S
*/
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

/** Unary negation (constant width)
*
* @return a hardware $coll equal to zero minus `this` shifted right by one
Expand All @@ -918,12 +846,6 @@ sealed class SInt private[chisel3] (width: Width) extends Bits(width) with Num[S
*/
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

/** @group SourceInfoTransformMacro */
def do_unary_-(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): SInt = 0.S - this

Expand Down Expand Up @@ -1171,12 +1093,6 @@ 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

/** @group SourceInfoTransformMacro */
def do_asAsyncReset(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): AsyncReset
}
Expand Down Expand Up @@ -1376,12 +1292,6 @@ sealed class Bool() extends UInt(1.W) with Reset {
/** 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

/** @group SourceInfoTransformMacro */
def do_asClock(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Clock = pushOp(
DefPrim(sourceInfo, Clock(), AsClockOp, ref)
Expand Down Expand Up @@ -1484,24 +1394,13 @@ package experimental {
*/
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

/** 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

/** @group SourceInfoTransformMacro */
def do_unary_-(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): FixedPoint =
Expand Down Expand Up @@ -1991,20 +1890,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

/** @group SourceInfoTransformMacro */
def do_unary_-(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Interval = {
Interval.Zero - this
Expand Down
6 changes: 0 additions & 6 deletions core/src/main/scala/chisel3/Clock.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ sealed class Clock(private[chisel3] val width: Width = Width(1)) extends Element
/** 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

override def do_asUInt(implicit sourceInfo: SourceInfo, connectCompileOptions: CompileOptions): UInt = pushOp(
Expand Down
29 changes: 0 additions & 29 deletions core/src/main/scala/chisel3/Data.scala
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ object Flipped {
*/
abstract class Data extends HasId with NamedComponent with SourceInfoDoc {
// This is a bad API that punches through object boundaries.
@deprecated("pending removal once all instances replaced", "chisel3")
private[chisel3] def flatten: IndexedSeq[Element] = {
this match {
case elt: Aggregate => elt.elementsIterator.toIndexedSeq.flatMap { _.flatten }
Expand Down Expand Up @@ -491,10 +490,6 @@ abstract class Data extends HasId with NamedComponent with SourceInfoDoc {
// User-friendly representation of the binding as a helper function for toString.
// Provides a unhelpful fallback for literals, which should have custom rendering per
// Data-subtype.
// TODO Is this okay for sample_element? It *shouldn't* be visible to users
@deprecated("This was never intended to be visible to user-defined types", "Chisel 3.5.0")
protected def bindingToString: String = _bindingToString(topBinding)

private[chisel3] def _bindingToString(topBindingOpt: TopBinding): String =
topBindingOpt match {
case OpBinding(_, _) => "OpResult"
Expand Down Expand Up @@ -742,35 +737,17 @@ 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

/**
* 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

/**
* 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

/** Returns the width, in bits, if currently known. */
final def getWidth: Int =
if (isWidthKnown) width.get else throwException(s"Width of $this is unknown!")
Expand Down Expand Up @@ -816,12 +793,6 @@ abstract class Data extends HasId with NamedComponent with SourceInfoDoc {
*/
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

/** @group SourceInfoTransformMacro */
def do_asUInt(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt

Expand Down
8 changes: 1 addition & 7 deletions core/src/main/scala/chisel3/Num.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ trait Num[T <: Data] {
self: Num[T] =>
// def << (b: T): T
// def >> (b: T): T
//def unary_-(): T
//def unary_-: T

// REVIEW TODO: double check ops conventions against FIRRTL

Expand Down Expand Up @@ -149,12 +149,6 @@ trait Num[T <: Data] {
*/
final def abs: T = 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 abs(dummy: Int*): T = macro SourceInfoTransform.noArgDummy

/** @group SourceInfoTransformMacro */
def do_abs(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T

Expand Down
3 changes: 0 additions & 3 deletions core/src/main/scala/chisel3/RawModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ abstract class RawModule(implicit moduleCompileOptions: CompileOptions) extends
//
private var _firrtlPorts: Option[Seq[firrtl.Port]] = None

@deprecated("Use DataMirror.modulePorts instead. this API will be removed in Chisel 3.6", "Chisel 3.5")
lazy val getPorts: Seq[Port] = _firrtlPorts.get

val compileOptions = moduleCompileOptions

private[chisel3] def checkPorts(): Unit = {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/chisel3/StrongEnum.scala
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ abstract class EnumType(private[chisel3] val factory: EnumFactory, selfAnnotatin
* @return a hardware [[Bool]] that indicates if this value matches any of the given values
*/
final def isOneOf(s: Seq[EnumType])(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = {
VecInit(s.map(this === _)).asUInt().orR()
VecInit(s.map(this === _)).asUInt.orR
}

/** Test if this enumeration is equal to any of the values given as arguments
Expand Down
Loading

0 comments on commit 7372c9e

Please sign in to comment.