aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/firrtl/annotations
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/firrtl/annotations')
-rw-r--r--src/main/scala/firrtl/annotations/TargetToken.scala30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/main/scala/firrtl/annotations/TargetToken.scala b/src/main/scala/firrtl/annotations/TargetToken.scala
index 587f30eb..70b64271 100644
--- a/src/main/scala/firrtl/annotations/TargetToken.scala
+++ b/src/main/scala/firrtl/annotations/TargetToken.scala
@@ -2,6 +2,9 @@
package firrtl.annotations
+import firrtl._
+import ir.{DefModule, DefInstance}
+
/** Building block to represent a [[Target]] of a FIRRTL component */
sealed trait TargetToken {
def keyword: String
@@ -32,6 +35,33 @@ case object TargetToken {
case object Init extends TargetToken { override def keyword: String = "init"; val value = "" }
case object Reset extends TargetToken { override def keyword: String = "reset"; val value = "" }
+ implicit class fromStringToTargetToken(s: String) {
+ def Instance: Instance = new TargetToken.Instance(s)
+ def OfModule: OfModule = new TargetToken.OfModule(s)
+ def Ref: Ref = new TargetToken.Ref(s)
+ def Field: Field = new TargetToken.Field(s)
+ }
+
+ implicit class fromIntToTargetToken(i: Int) {
+ def Index: Index = new TargetToken.Index(i)
+ }
+
+ implicit class fromDefModuleToTargetToken(m: DefModule) {
+ def OfModule: OfModule = new TargetToken.OfModule(m.name)
+ }
+
+ implicit class fromDefInstanceToTargetToken(i: DefInstance) {
+ def Instance: Instance = new TargetToken.Instance(i.name)
+ def OfModule: OfModule = new TargetToken.OfModule(i.module)
+ def toTokens: (Instance, OfModule) = (new TargetToken.Instance(i.name), new TargetToken.OfModule(i.module))
+ }
+
+ implicit class fromWDefInstanceToTargetToken(wi: WDefInstance) {
+ def Instance: Instance = new TargetToken.Instance(wi.name)
+ def OfModule: OfModule = new TargetToken.OfModule(wi.module)
+ def toTokens: (Instance, OfModule) = (new TargetToken.Instance(wi.name), new TargetToken.OfModule(wi.module))
+ }
+
val keyword2targettoken = Map(
"inst" -> ((value: String) => Instance(value)),
"of" -> ((value: String) => OfModule(value)),