summaryrefslogtreecommitdiff
path: root/chiselFrontend/src/main/scala/chisel3/core/Module.scala
diff options
context:
space:
mode:
authorChick Markley2019-05-13 18:08:25 -0700
committerGitHub2019-05-13 18:08:25 -0700
commit89ef4d78e8f44f31df6530a6a4dee20d0ad0399f (patch)
treefb7948f90429b41af789252751d80e347e1142dd /chiselFrontend/src/main/scala/chisel3/core/Module.scala
parentdf0e0b1cc4b566fc098ac3a6d34ec6d9a551d21d (diff)
RawModule with no reset should be able to use withClock method. (#1065)
* RawModule with no reset should be able to use withClock method. - refactor ClockAndReset - now has `clockOpt: Option[Clock]` and `resetOpt: Option[Reset]` constructor params - convenience methods clock and reset tries to deref the option - ClockAndReset.empty is factory method for (None, None) - In Builder - forcedClock does not check resetOpt now - forcedReset does not check clockOpt now - withClock no longer looks at resetOpt - withReset no longer looks at clockOpt - Module starts with empty ClockAndReset * RawModule with no reset should be able to use withClock method. Refactor again based on @ducky64 comments - refactor away ClockAndReset, now builder just has a - currentClock - currentReset - withClock, withRest, withClockAndReset just use these fields directly * RawModule with no reset should be able to use withClock method. - Fixed typo in withReset handler, now picks up new reset
Diffstat (limited to 'chiselFrontend/src/main/scala/chisel3/core/Module.scala')
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/Module.scala10
1 files changed, 6 insertions, 4 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Module.scala b/chiselFrontend/src/main/scala/chisel3/core/Module.scala
index f97d51ac..5cd48a6a 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/Module.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/Module.scala
@@ -41,8 +41,9 @@ object Module extends SourceInfoDoc {
val whenDepth: Int = Builder.whenDepth
// Save then clear clock and reset to prevent leaking scope, must be set again in the Module
- val clockAndReset: Option[ClockAndReset] = Builder.currentClockAndReset
- Builder.currentClockAndReset = None
+ val (saveClock, saveReset) = (Builder.currentClock, Builder.currentReset)
+ Builder.currentClock = None
+ Builder.currentReset = None
// Execute the module, this has the following side effects:
// - set currentModule
@@ -59,9 +60,10 @@ object Module extends SourceInfoDoc {
"This is probably due to rewrapping a Module instance with Module()." +
sourceInfo.makeMessage(" See " + _))
}
- Builder.currentModule = parent // Back to parent!
+ Builder.currentModule = parent // Back to parent!
Builder.whenDepth = whenDepth
- Builder.currentClockAndReset = clockAndReset // Back to clock and reset scope
+ Builder.currentClock = saveClock // Back to clock and reset scope
+ Builder.currentReset = saveReset
val component = module.generateComponent()
Builder.components += component