summaryrefslogtreecommitdiff
path: root/core/src/main
diff options
context:
space:
mode:
authorAdam Izraelevitz2020-10-26 14:59:17 -0700
committerGitHub2020-10-26 21:59:17 +0000
commit1b6bd89dfafc774af1c926a982418294091f6346 (patch)
treec76739031286169fc04ab98936f9745f080fcdc6 /core/src/main
parent2d98132dfb849ef6c987ee5f49be596794887a08 (diff)
Bugfix - module name collision for injecting aspect (#1635)
* Bugfix - module name collision for injecting aspect * Fixed mechanism to avoid module name collisions * Added comments for reviewer feedback Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Diffstat (limited to 'core/src/main')
-rw-r--r--core/src/main/scala/chisel3/Module.scala4
-rw-r--r--core/src/main/scala/chisel3/internal/Builder.scala6
2 files changed, 8 insertions, 2 deletions
diff --git a/core/src/main/scala/chisel3/Module.scala b/core/src/main/scala/chisel3/Module.scala
index 82a1708e..236f528e 100644
--- a/core/src/main/scala/chisel3/Module.scala
+++ b/core/src/main/scala/chisel3/Module.scala
@@ -251,7 +251,9 @@ package experimental {
/** Legalized name of this module. */
final lazy val name = try {
- Builder.globalNamespace.name(desiredName)
+ // If this is a module aspect, it should share the same name as the original module
+ // Thus, the desired name should be returned without uniquification
+ if(this.isInstanceOf[ModuleAspect]) desiredName else Builder.globalNamespace.name(desiredName)
} catch {
case e: NullPointerException => throwException(
s"Error: desiredName of ${this.getClass.getName} is null. Did you evaluate 'name' before all values needed by desiredName were available?", e)
diff --git a/core/src/main/scala/chisel3/internal/Builder.scala b/core/src/main/scala/chisel3/internal/Builder.scala
index 3988ac68..30fa2db2 100644
--- a/core/src/main/scala/chisel3/internal/Builder.scala
+++ b/core/src/main/scala/chisel3/internal/Builder.scala
@@ -627,7 +627,11 @@ private[chisel3] object Builder {
def build[T <: RawModule](f: => T): (Circuit, T) = {
- dynamicContextVar.withValue(Some(new DynamicContext())) {
+ build(f, new DynamicContext())
+ }
+
+ private [chisel3] def build[T <: RawModule](f: => T, dynamicContext: DynamicContext): (Circuit, T) = {
+ dynamicContextVar.withValue(Some(dynamicContext)) {
checkScalaVersion()
errors.info("Elaborating design...")
val mod = f