aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/firrtl/constraint/IsKnown.scala
blob: b11adc3a37b7f9dddd5883c4e37121346bf8013b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// SPDX-License-Identifier: Apache-2.0

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
}