summaryrefslogtreecommitdiff
path: root/chiselFrontend/src/main/scala/chisel3/core/Bits.scala
diff options
context:
space:
mode:
authorJack Koenig2018-12-04 13:53:36 -0800
committerGitHub2018-12-04 13:53:36 -0800
commit83f2a65a3ab1d21258883c0b113406ef9900a57f (patch)
treec21edf9bc9c5f2f42ec5716a829145024bb82862 /chiselFrontend/src/main/scala/chisel3/core/Bits.scala
parentab951049c2c60402e2318ba863520d4a16c8288d (diff)
parent3db21bd8e5a32c29efa55494d180dac4d22589e5 (diff)
Merge pull request #950 from freechipsproject/as-bools
asBools, asBool, and chained apply on asBools
Diffstat (limited to 'chiselFrontend/src/main/scala/chisel3/core/Bits.scala')
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/Bits.scala27
1 files changed, 24 insertions, 3 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Bits.scala b/chiselFrontend/src/main/scala/chisel3/core/Bits.scala
index 9356a91c..7e98cf04 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/Bits.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/Bits.scala
@@ -82,6 +82,15 @@ private[chisel3] sealed trait ToBoolable extends Element {
*
* @note The width must be known and equal to 1
*/
+ final def asBool(): Bool = macro SourceInfoWhiteboxTransform.noArg
+
+ /** @group SourceInfoTransformMacro */
+ def do_asBool(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool
+
+ /** Casts this $coll to a [[Bool]]
+ *
+ * @note The width must be known and equal to 1
+ */
final def toBool(): Bool = macro SourceInfoWhiteboxTransform.noArg
/** @group SourceInfoTransformMacro */
@@ -364,7 +373,15 @@ sealed abstract class Bits(private[chisel3] val width: Width) extends Element wi
final def toBools(): Seq[Bool] = macro SourceInfoTransform.noArg
/** @group SourceInfoTransformMacro */
- def toBools(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Seq[Bool] =
+ @chiselRuntimeDeprecated
+ @deprecated("Use asBools instead", "3.2")
+ def do_toBools(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Seq[Bool] = do_asBools
+
+ /** Returns the contents of this wire as a [[scala.collection.Seq]] of [[Bool]]. */
+ final def asBools(): Seq[Bool] = macro SourceInfoTransform.noArg
+
+ /** @group SourceInfoTransformMacro */
+ def do_asBools(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Seq[Bool] =
Seq.tabulate(this.getWidth)(i => this(i))
/** Reinterpret this $coll as a [[SInt]]
@@ -412,13 +429,17 @@ sealed abstract class Bits(private[chisel3] val width: Width) extends Element wi
do_asUInt
}
- final def do_toBool(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = {
+ final def do_asBool(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = {
width match {
case KnownWidth(1) => this(0)
- case _ => throwException(s"can't covert UInt<$width> to Bool")
+ case _ => throwException(s"can't covert ${this.getClass.getSimpleName}$width to Bool")
}
}
+ @chiselRuntimeDeprecated
+ @deprecated("Use asBool instead", "3.2")
+ final def do_toBool(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = do_asBool
+
/** Concatenation operator
*
* @param that a hardware component