diff options
| author | chick | 2019-12-18 16:38:07 -0800 |
|---|---|---|
| committer | chick | 2019-12-18 16:38:07 -0800 |
| commit | ee71c54ffa48162b3d0a451e37016374bd9a7239 (patch) | |
| tree | 4be9f65f5945d86447afe72501faecc344b56ad8 /chiselFrontend/src | |
| parent | 954cc41e1349d0df6d2250d6270590340cd36e82 (diff) | |
Add method asBool to Clock.
Shortcut for .asUInt.asBool
Added test to show it works
Diffstat (limited to 'chiselFrontend/src')
| -rw-r--r-- | chiselFrontend/src/main/scala/chisel3/Clock.scala | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/Clock.scala b/chiselFrontend/src/main/scala/chisel3/Clock.scala index 87674e7b..1aadf167 100644 --- a/chiselFrontend/src/main/scala/chisel3/Clock.scala +++ b/chiselFrontend/src/main/scala/chisel3/Clock.scala @@ -2,7 +2,8 @@ package chisel3 -import chisel3.internal.Builder.{pushOp} +import scala.language.experimental.macros +import chisel3.internal.Builder.pushOp import chisel3.internal.firrtl._ import chisel3.internal.sourceinfo._ import chisel3.internal.firrtl.PrimOp.AsUIntOp @@ -30,9 +31,13 @@ sealed class Clock(private[chisel3] val width: Width = Width(1)) extends Element /** Not really supported */ def toPrintable: Printable = PString("CLOCK") + /** Returns the contents of this wire as a [[scala.collection.Seq]] of [[Bool]]. */ + 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)) // scalastyle:ignore line.size.limit private[chisel3] override def connectFromBits(that: Bits)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Unit = { - this := that.asBool.asClock + this := that.asBool().asClock } } |
