diff options
| author | Jack Koenig | 2020-03-22 18:13:58 -0700 |
|---|---|---|
| committer | Jack Koenig | 2020-03-25 19:17:15 -0700 |
| commit | fbf5e6f1a0e8bf535d465b748ad554575fe62156 (patch) | |
| tree | 578858ab6d219ca6daf44cf87b73f75054989097 /core/src/main/scala/chisel3/MultiClock.scala | |
| parent | b2e004fb615a3c931d910a338b9faa99c1c975d7 (diff) | |
Rename subprojects to more canonical names
* Rename coreMacros to macros
* Rename chiselFrontend to core
Also make each subproject publish with "chisel3-" as a prefix
Diffstat (limited to 'core/src/main/scala/chisel3/MultiClock.scala')
| -rw-r--r-- | core/src/main/scala/chisel3/MultiClock.scala | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/core/src/main/scala/chisel3/MultiClock.scala b/core/src/main/scala/chisel3/MultiClock.scala new file mode 100644 index 00000000..239e745a --- /dev/null +++ b/core/src/main/scala/chisel3/MultiClock.scala @@ -0,0 +1,70 @@ +// See LICENSE for license details. + +package chisel3 + +import chisel3.internal._ + +import scala.language.experimental.macros + +object withClockAndReset { // scalastyle:ignore object.name + /** Creates a new Clock and Reset scope + * + * @param clock the new implicit Clock + * @param reset the new implicit Reset + * @param block the block of code to run with new implicit Clock and Reset + * @return the result of the block + */ + def apply[T](clock: Clock, reset: Reset)(block: => T): T = { + // Save parentScope + val parentClock = Builder.currentClock + val parentReset = Builder.currentReset + + Builder.currentClock = Some(clock) + Builder.currentReset = Some(reset) + + val res = block // execute block + + // Return to old scope + Builder.currentClock = parentClock + Builder.currentReset = parentReset + res + } +} + +object withClock { // scalastyle:ignore object.name + /** Creates a new Clock scope + * + * @param clock the new implicit Clock + * @param block the block of code to run with new implicit Clock + * @return the result of the block + */ + def apply[T](clock: Clock)(block: => T): T = { + // Save parentScope + val parentClock = Builder.currentClock + Builder.currentClock = Some(clock) + val res = block // execute block + // Return to old scope + Builder.currentClock = parentClock + res + } +} + +object withReset { // scalastyle:ignore object.name + /** Creates a new Reset scope + * + * @param reset the new implicit Reset + * @param block the block of code to run with new implicit Reset + * @return the result of the block + */ + def apply[T](reset: Reset)(block: => T): T = { + // Save parentScope + val parentReset = Builder.currentReset + Builder.currentReset = Some(reset) + val res = block // execute block + // Return to old scope + Builder.currentReset = parentReset + res + } + +} + |
