aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/firrtl/annotations
diff options
context:
space:
mode:
authorAdam Izraelevitz2019-10-18 19:01:19 -0700
committerGitHub2019-10-18 19:01:19 -0700
commitfd981848c7d2a800a15f9acfbf33b57dd1c6225b (patch)
tree3609a301cb0ec867deefea4a0d08425810b00418 /src/main/scala/firrtl/annotations
parent973ecf516c0ef2b222f2eb68dc8b514767db59af (diff)
Upstream intervals (#870)
Major features: - Added Interval type, as well as PrimOps asInterval, clip, wrap, and sqz. - Changed PrimOp names: bpset -> setp, bpshl -> incp, bpshr -> decp - Refactored width/bound inferencer into a separate constraint solver - Added transforms to infer, trim, and remove interval bounds - Tests for said features Plan to be released with 1.3
Diffstat (limited to 'src/main/scala/firrtl/annotations')
-rw-r--r--src/main/scala/firrtl/annotations/Target.scala19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/main/scala/firrtl/annotations/Target.scala b/src/main/scala/firrtl/annotations/Target.scala
index 313f1dc2..1571f98e 100644
--- a/src/main/scala/firrtl/annotations/Target.scala
+++ b/src/main/scala/firrtl/annotations/Target.scala
@@ -3,7 +3,7 @@
package firrtl
package annotations
-import firrtl.ir.{Expression, Type}
+import firrtl.ir.{Field => _, _}
import firrtl.Utils.{sub_type, field_type}
import AnnotationUtils.{toExp, validComponentName, validModuleName}
import TargetToken._
@@ -41,7 +41,7 @@ sealed trait Target extends Named {
case Ref(r) => s">$r"
case Instance(i) => s"/$i"
case OfModule(o) => s":$o"
- case Field(f) => s".$f"
+ case TargetToken.Field(f) => s".$f"
case Index(v) => s"[$v]"
case Clock => s"@clock"
case Reset => s"@reset"
@@ -103,6 +103,21 @@ sealed trait Target extends Named {
}
object Target {
+ def asTarget(m: ModuleTarget)(e: Expression): ReferenceTarget = e match {
+ case w: WRef => m.ref(w.name)
+ case r: ir.Reference => m.ref(r.name)
+ case w: WSubIndex => asTarget(m)(w.expr).index(w.value)
+ case s: ir.SubIndex => asTarget(m)(s.expr).index(s.value)
+ case w: WSubField => asTarget(m)(w.expr).field(w.name)
+ case s: ir.SubField => asTarget(m)(s.expr).field(s.name)
+ case w: WSubAccess => asTarget(m)(w.expr).field("@" + w.index.serialize)
+ case s: ir.SubAccess => asTarget(m)(s.expr).field("@" + s.index.serialize)
+ case d: DoPrim => m.ref("@" + d.serialize)
+ case d: Mux => m.ref("@" + d.serialize)
+ case d: ValidIf => m.ref("@" + d.serialize)
+ case d: Literal => m.ref("@" + d.serialize)
+ case other => sys.error(s"Unsupported: $other")
+ }
def apply(circuitOpt: Option[String], moduleOpt: Option[String], reference: Seq[TargetToken]): GenericTarget =
GenericTarget(circuitOpt, moduleOpt, reference.toVector)