aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/firrtl/constraint/IsKnown.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/firrtl/constraint/IsKnown.scala')
-rw-r--r--src/main/scala/firrtl/constraint/IsKnown.scala44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/main/scala/firrtl/constraint/IsKnown.scala b/src/main/scala/firrtl/constraint/IsKnown.scala
new file mode 100644
index 00000000..5bd25f92
--- /dev/null
+++ b/src/main/scala/firrtl/constraint/IsKnown.scala
@@ -0,0 +1,44 @@
+// See LICENSE for license details.
+
+package firrtl.constraint
+
+object IsKnown {
+ def unapply(b: Constraint): Option[BigDecimal] = b match {
+ case k: IsKnown => Some(k.value)
+ case _ => None
+ }
+}
+
+/** Constant values must extend this trait see [[firrtl.ir.Closed and firrtl.ir.Open]] */
+trait IsKnown extends Constraint {
+ val value: BigDecimal
+
+ /** Addition */
+ def +(that: IsKnown): IsKnown
+
+ /** Multiplication */
+ def *(that: IsKnown): IsKnown
+
+ /** Max */
+ def max(that: IsKnown): IsKnown
+
+ /** Min */
+ def min(that: IsKnown): IsKnown
+
+ /** Negate */
+ def neg: IsKnown
+
+ /** 2 << value */
+ def pow: IsKnown
+
+ /** Floor */
+ def floor: IsKnown
+
+ override def map(f: Constraint=>Constraint): Constraint = this
+
+ val children: Vector[Constraint] = Vector.empty[Constraint]
+
+ def reduce(): IsKnown = this
+}
+
+