summaryrefslogtreecommitdiff
path: root/chiselFrontend/src/main/scala/chisel3/core/Bits.scala
diff options
context:
space:
mode:
authorducky2016-11-17 11:33:20 -0800
committerducky2016-11-21 13:31:12 -0800
commitcd904da0aa0e96ba679906a3ee5dbdc068eace48 (patch)
tree120ab95b40a749a98b571ee862d950b443b652b5 /chiselFrontend/src/main/scala/chisel3/core/Bits.scala
parentb0cc0c93a80aec5bed54cfb11923636c09b7e180 (diff)
Restyle Bool constructors, move compatibility deprecations into compatibility package object
Diffstat (limited to 'chiselFrontend/src/main/scala/chisel3/core/Bits.scala')
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/Bits.scala20
1 files changed, 6 insertions, 14 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Bits.scala b/chiselFrontend/src/main/scala/chisel3/core/Bits.scala
index aa73abf5..b81679b6 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/Bits.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/Bits.scala
@@ -92,7 +92,7 @@ sealed abstract class Bits(width: Width, override val litArg: Option[LitArg])
Builder.error(s"Negative bit indices are illegal (got $x)")
}
if (isLit()) {
- Bool(((litValue() >> x.toInt) & 1) == 1)
+ (((litValue() >> x.toInt) & 1) == 1).asBool
} else {
Binding.checkSynthesizable(this, s"'this' ($this)")
pushOp(DefPrim(sourceInfo, Bool(), BitsExtractOp, this.ref, ILit(x), ILit(x)))
@@ -698,7 +698,7 @@ sealed class Bool(lit: Option[ULit] = None) extends UInt(Width(1), lit) {
override private[chisel3] def fromInt(value: BigInt, width: Int): this.type = {
require((value == 0 || value == 1) && width == 1)
- Bool(value == 1).asInstanceOf[this.type]
+ (value == 1).asBool.asInstanceOf[this.type]
}
// REVIEW TODO: Why does this need to exist and have different conventions
@@ -736,31 +736,23 @@ sealed class Bool(lit: Option[ULit] = None) extends UInt(Width(1), lit) {
def do_asClock(implicit sourceInfo: SourceInfo): Clock = pushOp(DefPrim(sourceInfo, Clock(), AsClockOp, ref))
}
-object Bool {
+trait BoolFactory {
/** Creates an empty Bool.
*/
def apply(): Bool = new Bool()
/** Creates Bool literal.
*/
- def apply(x: Boolean): Bool = Lit(x)
- def Lit(x: Boolean): Bool = {
+ protected[chisel3] def Lit(x: Boolean): Bool = {
val result = new Bool(Some(ULit(if (x) 1 else 0, Width(1))))
// Bind result to being an Literal
result.binding = LitBinding()
result
}
- /** Create a UInt with a specified direction and width - compatibility with Chisel2. */
- def apply(dir: Direction): Bool = {
- val result = apply()
- dir match {
- case Direction.Input => Input(result)
- case Direction.Output => Output(result)
- case Direction.Unspecified => result
- }
- }
}
+object Bool extends BoolFactory
+
object Mux {
/** Creates a mux, whose output is one of the inputs depending on the
* value of the condition.