aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/firrtl/annotations/Target.scala
diff options
context:
space:
mode:
authorSchuyler Eldridge2020-02-10 14:14:43 -0500
committerGitHub2020-02-10 14:14:43 -0500
commit1b475c42ebfeb279c0fba013cadbb00545ecaa8f (patch)
tree78f40aed32968ec2c26f2c58bcfb7b8bd5fec7c4 /src/main/scala/firrtl/annotations/Target.scala
parentdc9709c55bfa9f2dc7ee9a400e141ce5deb7269c (diff)
parentbcbe60dec0c92b22f7aa98669cdec21c3111acd4 (diff)
Merge pull request #1370 from freechipsproject/issue-1309
Rename Modules Duplicated by EliminateTargetPaths
Diffstat (limited to 'src/main/scala/firrtl/annotations/Target.scala')
-rw-r--r--src/main/scala/firrtl/annotations/Target.scala13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main/scala/firrtl/annotations/Target.scala b/src/main/scala/firrtl/annotations/Target.scala
index 1571f98e..c7cb98d2 100644
--- a/src/main/scala/firrtl/annotations/Target.scala
+++ b/src/main/scala/firrtl/annotations/Target.scala
@@ -185,6 +185,19 @@ object Target {
}
}.tryToComplete
}
+
+ /** Returns the module that a [[Target]] "refers" to.
+ *
+ * For a [[ModuleTarget]] or a [[ReferenceTarget]], this is simply the deepest module. For an [[InstanceTarget]] this
+ * is *the module of the instance*.
+ *
+ * @note This differs from [[InstanceTarget.pathlessTarget]] which refers to the module instantiating the instance.
+ */
+ def referringModule(a: IsMember): ModuleTarget = a match {
+ case b: ModuleTarget => b
+ case b: InstanceTarget => b.ofModuleTarget
+ case b: ReferenceTarget => b.pathlessTarget.moduleTarget
+ }
}
/** Represents incomplete or non-standard [[Target]]s