diff options
| author | Adam Izraelevitz | 2020-10-26 14:59:17 -0700 |
|---|---|---|
| committer | GitHub | 2020-10-26 21:59:17 +0000 |
| commit | 1b6bd89dfafc774af1c926a982418294091f6346 (patch) | |
| tree | c76739031286169fc04ab98936f9745f080fcdc6 /core | |
| parent | 2d98132dfb849ef6c987ee5f49be596794887a08 (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')
| -rw-r--r-- | core/src/main/scala/chisel3/Module.scala | 4 | ||||
| -rw-r--r-- | core/src/main/scala/chisel3/internal/Builder.scala | 6 |
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 |
