aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Magyar2020-03-03 23:28:12 -0800
committerAlbert Magyar2020-03-04 12:00:19 -0800
commit6a8ea559697002cee3737949af63916b0d8262ae (patch)
tree91595ca7a75372c9e673c579b959e9b8d3febe4e
parentb4aebc1a5625978c154ad3879a39be549e659d91 (diff)
Incorporate new AddNot formal regression test
* Feedback from @jackkoening * Merge into same stage as Ops to avoid Travis delays
-rw-r--r--.travis.yml3
-rw-r--r--regress/AddNot.fir6
-rw-r--r--src/main/scala/firrtl/transforms/ConstantPropagation.scala2
3 files changed, 10 insertions, 1 deletions
diff --git a/.travis.yml b/.travis.yml
index 2065cb56..9e552319 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -77,11 +77,12 @@ jobs:
- "travis_wait 30 sleep 1800 &"
- ./.run_formal_checks.sh ICache
- stage: test
- name: "Formal equivalence: Ops"
+ name: "Formal equivalence: small expression-tree stress tests"
script:
- yosys -V
- "travis_wait 30 sleep 1800 &"
- ./.run_formal_checks.sh Ops
+ - ./.run_formal_checks.sh AddNot
- stage: test
script:
- benchmark/scripts/benchmark_cold_compile.py -N 2 --designs regress/ICache.fir --versions HEAD
diff --git a/regress/AddNot.fir b/regress/AddNot.fir
new file mode 100644
index 00000000..38c72a16
--- /dev/null
+++ b/regress/AddNot.fir
@@ -0,0 +1,6 @@
+circuit AddNot:
+ module AddNot:
+ input a: UInt<8>
+ input b: UInt<8>
+ output o: UInt<9>
+ o <= add(a, not(b))
diff --git a/src/main/scala/firrtl/transforms/ConstantPropagation.scala b/src/main/scala/firrtl/transforms/ConstantPropagation.scala
index af1a2b26..201c3325 100644
--- a/src/main/scala/firrtl/transforms/ConstantPropagation.scala
+++ b/src/main/scala/firrtl/transforms/ConstantPropagation.scala
@@ -185,6 +185,7 @@ class ConstantPropagation extends Transform with ResolvedAnnotationPaths {
def fold(c1: Literal, c2: Literal) = UIntLiteral(if (c1.value == c2.value) 1 else 0, IntWidth(1))
def simplify(e: Expression, lhs: Literal, rhs: Expression) = lhs match {
case UIntLiteral(v, IntWidth(w)) if v == BigInt(1) && w == BigInt(1) && bitWidth(rhs.tpe) == BigInt(1) => rhs
+ case UIntLiteral(v, IntWidth(w)) if v == BigInt(0) && w == BigInt(1) && bitWidth(rhs.tpe) == BigInt(1) => DoPrim(Not, Seq(rhs), Nil, e.tpe)
case _ => e
}
def matchingArgsValue(e: DoPrim, arg: Expression) = UIntLiteral(1)
@@ -194,6 +195,7 @@ class ConstantPropagation extends Transform with ResolvedAnnotationPaths {
def fold(c1: Literal, c2: Literal) = UIntLiteral(if (c1.value != c2.value) 1 else 0, IntWidth(1))
def simplify(e: Expression, lhs: Literal, rhs: Expression) = lhs match {
case UIntLiteral(v, IntWidth(w)) if v == BigInt(0) && w == BigInt(1) && bitWidth(rhs.tpe) == BigInt(1) => rhs
+ case UIntLiteral(v, IntWidth(w)) if v == BigInt(1) && w == BigInt(1) && bitWidth(rhs.tpe) == BigInt(1) => DoPrim(Not, Seq(rhs), Nil, e.tpe)
case _ => e
}
def matchingArgsValue(e: DoPrim, arg: Expression) = UIntLiteral(0)