diff options
| author | Adam Izraelevitz | 2019-10-18 19:01:19 -0700 |
|---|---|---|
| committer | GitHub | 2019-10-18 19:01:19 -0700 |
| commit | fd981848c7d2a800a15f9acfbf33b57dd1c6225b (patch) | |
| tree | 3609a301cb0ec867deefea4a0d08425810b00418 /src/main/scala/firrtl/constraint/IsKnown.scala | |
| parent | 973ecf516c0ef2b222f2eb68dc8b514767db59af (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/constraint/IsKnown.scala')
| -rw-r--r-- | src/main/scala/firrtl/constraint/IsKnown.scala | 44 |
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 +} + + |
