summaryrefslogtreecommitdiff
path: root/chiselFrontend/src/main/scala/chisel3/internal
diff options
context:
space:
mode:
authorJack2016-11-11 14:37:03 -0800
committerJack Koenig2016-11-14 11:11:02 -0800
commit815b1c3cb311b7f4dfb7a2f00e0e2d62795bdc6b (patch)
treec9cb68e6cbb844a0da9af23afce1b470a2d3481e /chiselFrontend/src/main/scala/chisel3/internal
parente60761cf72ba572da0bb8387a4506f5c3e211ac9 (diff)
Add checks for misuse or omission of Module()
Implemented by adding a Boolean to check for alternating invocations of object Module.apply and the constructor of abstract class Module. Fixes #192
Diffstat (limited to 'chiselFrontend/src/main/scala/chisel3/internal')
-rw-r--r--chiselFrontend/src/main/scala/chisel3/internal/Builder.scala7
1 files changed, 7 insertions, 0 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/internal/Builder.scala b/chiselFrontend/src/main/scala/chisel3/internal/Builder.scala
index b4b0e028..028ce628 100644
--- a/chiselFrontend/src/main/scala/chisel3/internal/Builder.scala
+++ b/chiselFrontend/src/main/scala/chisel3/internal/Builder.scala
@@ -146,6 +146,9 @@ private[chisel3] class DynamicContext() {
val globalNamespace = new Namespace(None, Set())
val components = ArrayBuffer[Component]()
var currentModule: Option[Module] = None
+ // Set by object Module.apply before calling class Module constructor
+ // Used to distinguish between no Module() wrapping, multiple wrappings, and rewrapping
+ var readyForModuleConstr: Boolean = false
val errors = new ErrorLog
}
@@ -170,6 +173,10 @@ private[chisel3] object Builder {
// A bare api call is, e.g. calling Wire() from the scala console).
)
}
+ def readyForModuleConstr: Boolean = dynamicContext.readyForModuleConstr
+ def readyForModuleConstr_=(target: Boolean): Unit = {
+ dynamicContext.readyForModuleConstr = target
+ }
// TODO(twigg): Ideally, binding checks and new bindings would all occur here
// However, rest of frontend can't support this yet.