diff options
Diffstat (limited to 'chiselFrontend/src/main/scala/chisel3/core/Clock.scala')
| -rw-r--r-- | chiselFrontend/src/main/scala/chisel3/core/Clock.scala | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Clock.scala b/chiselFrontend/src/main/scala/chisel3/core/Clock.scala new file mode 100644 index 00000000..f682310b --- /dev/null +++ b/chiselFrontend/src/main/scala/chisel3/core/Clock.scala @@ -0,0 +1,34 @@ +// See LICENSE for license details. + +package chisel3.core + +import chisel3.internal.Builder.{pushOp} +import chisel3.internal.firrtl._ +import chisel3.internal.sourceinfo._ +import chisel3.internal.firrtl.PrimOp.AsUIntOp + +object Clock { + def apply(): Clock = new Clock +} + +// TODO: Document this. +sealed class Clock extends Element(Width(1)) { + def cloneType: this.type = Clock().asInstanceOf[this.type] + + private[core] def typeEquivalent(that: Data): Boolean = + this.getClass == that.getClass + + override def connect(that: Data)(implicit sourceInfo: SourceInfo, connectCompileOptions: CompileOptions): Unit = that match { + case _: Clock => super.connect(that)(sourceInfo, connectCompileOptions) + case _ => super.badConnect(that)(sourceInfo) + } + + /** Not really supported */ + def toPrintable: Printable = PString("CLOCK") + + override def do_asUInt(implicit sourceInfo: SourceInfo, connectCompileOptions: CompileOptions): UInt = pushOp(DefPrim(sourceInfo, UInt(this.width), AsUIntOp, ref)) + private[core] override def connectFromBits(that: Bits)(implicit sourceInfo: SourceInfo, + compileOptions: CompileOptions): Unit = { + this := that + } +} |
