Skip to content

Commit 1a9bcf0

Browse files
committed
Merge branch '3.1.x' into release
Bump version
2 parents 8ece5e0 + 680b2bf commit 1a9bcf0

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ val defaultVersions = Map("firrtl" -> "1.1.7")
3434

3535
lazy val commonSettings = Seq (
3636
organization := "edu.berkeley.cs",
37-
version := "3.1.7",
37+
version := "3.1.8",
3838
git.remoteRepo := "git@github.com:freechipsproject/chisel3.git",
3939
autoAPIMappings := true,
4040
scalaVersion := "2.11.12",

chiselFrontend/src/main/scala/chisel3/core/Bits.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ private[chisel3] sealed trait ToBoolable extends Element {
5555
final def toBool(): Bool = macro SourceInfoWhiteboxTransform.noArg
5656

5757
def do_toBool(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool
58+
59+
/** Casts this object to a [[Bool]]
60+
*
61+
* @note Width must be known and equal to 1
62+
*/
63+
final def asBool(): Bool = macro SourceInfoWhiteboxTransform.noArg
64+
65+
def do_asBool(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool
5866
}
5967

6068
/** A data type for values represented by a single bitvector. Provides basic
@@ -307,6 +315,13 @@ sealed abstract class Bits(width: Width, override val litArg: Option[LitArg])
307315
}
308316
}
309317

318+
final def do_asBool(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = {
319+
width match {
320+
case KnownWidth(1) => this(0)
321+
case _ => throwException(s"can't covert UInt<$width> to Bool")
322+
}
323+
}
324+
310325
/** Returns this wire concatenated with `other`, where this wire forms the
311326
* most significant part and `other` forms the least significant part.
312327
*

src/main/scala/chisel3/util/ImplicitConversions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ object ImplicitConversions {
1313
// The explicit fromIntToLiteral resolves an ambiguous conversion between fromIntToLiteral and
1414
// UInt.asUInt.
1515
implicit def intToUInt(x: Int): UInt = chisel3.core.fromIntToLiteral(x).asUInt
16-
implicit def booleanToBool(x: Boolean): Bool = x.asBool
16+
implicit def booleanToBool(x: Boolean): Bool = x.B
1717
}

0 commit comments

Comments
 (0)