From 3ef63639284b2b56f415e1540c58d85d88c360db Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 30 Jan 2017 22:42:57 -0800 Subject: Make Module and Bundle properly use empty namespaces Fix default suggested name of Module instances (now based on desired name rather than actual assigned name). Remove parent/child relationship from Namespace. Previously, Module and Bundle namespaces were "children" of the Module definition namespace. This could lead to collisions that would give unexpected names for module instances or Bundle elements. In particular, otherwise identical modules that instantiate other identical modules in such a way that the instance cannot be named via reflection would not be deduplicated because the names of the instances would collide with the names of the modules in the Builder.globalNamespace. --- chiselFrontend/src/main/scala/chisel3/core/Module.scala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'chiselFrontend/src/main/scala/chisel3/core/Module.scala') diff --git a/chiselFrontend/src/main/scala/chisel3/core/Module.scala b/chiselFrontend/src/main/scala/chisel3/core/Module.scala index ca7c8abd..de13c078 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/Module.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/Module.scala @@ -113,7 +113,8 @@ extends HasId { Port(iodef) } - private[core] val _namespace = Builder.globalNamespace.child + // Fresh Namespace because in Firrtl, Modules namespaces are disjoint with the global namespace + private[core] val _namespace = Namespace.empty private[chisel3] val _commands = ArrayBuffer[Command]() private[core] val _ids = ArrayBuffer[HasId]() Builder.currentModule = Some(this) @@ -210,7 +211,7 @@ extends HasId { // For Module instances we haven't named, suggest the name of the Module _ids foreach { - case m: Module => m.suggestName(m.name) + case m: Module => m.suggestName(m.desiredName) case _ => } -- cgit v1.2.3