summaryrefslogtreecommitdiff
path: root/core/src/main/scala/chisel3/Module.scala
diff options
context:
space:
mode:
authorAlbert Magyar2020-07-31 11:05:13 -0700
committerGitHub2020-07-31 18:05:13 +0000
commit5ecde24d390248722f8ab6ac790fbd1d453e898e (patch)
treee92d337431500ea06392acd0731f7c021662f6e6 /core/src/main/scala/chisel3/Module.scala
parent8990ca3d8d8434a6c979b0c5fc06b05a39fd31d4 (diff)
Check whether signals escape their when scopes (#1518)
* Include and check when scoping as part of reg/mem/wire/node bindings * Allow outdated 'when' behavior of CHIRRTL memory ports with enables * Extend cross-module / when-visibility checks to all data refs * Fixes #1512 * Cannot be checked if outside a module context * E.g. delayed evaluation of printf / assert args * Add basic test cases for cross-module refs / signals escaping when scopes * Remove illegal cross-module references from existing tests
Diffstat (limited to 'core/src/main/scala/chisel3/Module.scala')
-rw-r--r--core/src/main/scala/chisel3/Module.scala10
1 files changed, 5 insertions, 5 deletions
diff --git a/core/src/main/scala/chisel3/Module.scala b/core/src/main/scala/chisel3/Module.scala
index 25037b00..194c546c 100644
--- a/core/src/main/scala/chisel3/Module.scala
+++ b/core/src/main/scala/chisel3/Module.scala
@@ -37,7 +37,7 @@ object Module extends SourceInfoDoc {
Builder.readyForModuleConstr = true
val parent = Builder.currentModule
- val whenDepth: Int = Builder.whenDepth
+ val parentWhenStack = Builder.whenStack
// Save then clear clock and reset to prevent leaking scope, must be set again in the Module
val (saveClock, saveReset) = (Builder.currentClock, Builder.currentReset)
@@ -49,7 +49,7 @@ object Module extends SourceInfoDoc {
// Execute the module, this has the following side effects:
// - set currentModule
// - unset readyForModuleConstr
- // - reset whenDepth to 0
+ // - reset whenStack to be empty
// - set currentClockAndReset
val module: T = bc // bc is actually evaluated here
@@ -62,7 +62,7 @@ object Module extends SourceInfoDoc {
sourceInfo.makeMessage(" See " + _))
}
Builder.currentModule = parent // Back to parent!
- Builder.whenDepth = whenDepth
+ Builder.whenStack = parentWhenStack
Builder.currentClock = saveClock // Back to clock and reset scope
Builder.currentReset = saveReset
@@ -137,7 +137,7 @@ package internal {
private[chisel3] def cloneIORecord(proto: BaseModule)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): ClonePorts = {
require(proto.isClosed, "Can't clone a module before module close")
val clonePorts = new ClonePorts(proto.getModulePorts: _*)
- clonePorts.bind(WireBinding(Builder.forcedUserModule))
+ clonePorts.bind(WireBinding(Builder.forcedUserModule, Builder.currentWhen()))
val cloneInstance = new DefInstance(sourceInfo, proto, proto._component.get.ports) {
override def name = clonePorts.getRef.name
}
@@ -169,7 +169,7 @@ package experimental {
readyForModuleConstr = false
Builder.currentModule = Some(this)
- Builder.whenDepth = 0
+ Builder.whenStack = Nil
//
// Module Construction Internals