summaryrefslogtreecommitdiff
path: root/chiselFrontend/src/main/scala/chisel3/core
diff options
context:
space:
mode:
authorDonggyu Kim2016-08-15 18:03:12 -0700
committerDonggyu Kim2016-08-21 22:28:03 -0700
commit2d01fdf6f26f480cb7ed19c1365f181ea717ddc2 (patch)
tree75eecb6157ada9471d17bc9fb082d091b969da34 /chiselFrontend/src/main/scala/chisel3/core
parent0744b3e5f9c0648878b97d3375cd7d88e2d0ee08 (diff)
provides signal name methods for firrtl annotation and chisel testers
* signalName: returns the chirrtl name of the signal * pathName: returns the full path name of the signal from the top module * parentPathName: returns the full path of the signal's parent module instance from the top module * parentModName: returns the signal's parent **module(not instance)** name.
Diffstat (limited to 'chiselFrontend/src/main/scala/chisel3/core')
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala3
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/Module.scala22
2 files changed, 22 insertions, 3 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala b/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala
index de64cb3d..82c6097f 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala
@@ -374,4 +374,5 @@ class Bundle extends Aggregate(NO_DIR) {
private[core] object Bundle {
val keywords = List("flip", "asInput", "asOutput", "cloneType", "toBits",
- "widthOption", "signalName", "signalPathName", "signalParent", "signalComponent")
+ "widthOption", "signalName", "signalPathName", "signalParent", "signalComponent")
+}
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Module.scala b/chiselFrontend/src/main/scala/chisel3/core/Module.scala
index 4f25515b..eb48a14d 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/Module.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/Module.scala
@@ -31,7 +31,9 @@ object Module {
m._commands.prepend(DefInvalid(childSourceInfo, m.io.ref)) // init module outputs
dynamicContext.currentModule = parent
val ports = m.computePorts
- Builder.components += Component(m, m.name, ports, m._commands)
+ val component = Component(m, m.name, ports, m._commands)
+ m._component = Some(component)
+ Builder.components += component
pushCommand(DefInstance(sourceInfo, m, ports))
m.setupInParent(childSourceInfo)
}
@@ -63,8 +65,24 @@ extends HasId {
/** Legalized name of this module. */
final val name = Builder.globalNamespace.name(desiredName)
+ /** FIRRTL Module name */
+ private var _modName: Option[String] = None
+ private[chisel3] def setModName(name: String) = _modName = Some(name)
+ def modName = _modName match {
+ case Some(name) => name
+ case None => throwException("modName should be called after circuit elaboration")
+ }
+
+ /** Keep component for signal names */
+ private[chisel3] var _component: Option[Component] = None
+
+
/** Signal name (for simulation). */
- override def signalName(component: Component) = name
+ override def signalName =
+ if (_parent == None) name else _component match {
+ case None => getRef.name
+ case Some(c) => getRef fullName c
+ }
/** IO for this Module. At the Scala level (pre-FIRRTL transformations),
* connections in and out of a Module may only go through `io` elements.