aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJack Koenig2016-10-30 14:31:22 -0700
committerDonggyu2016-10-30 14:31:22 -0700
commit77f55128e55c0f5511c609d2cb4f7fa2cd0aa427 (patch)
tree5339026f7ce45796d45b9df2e4fd58188ebbcbf9 /src
parentbe87c1e2481d14a2e0b68668fbfd901d3416dddd (diff)
Cleanup fixed point tests (#339)
Change FixedPointMathSpec tests to use FlatSpec style instead of println Remove other printlns Remove vim comments at end of files
Diffstat (limited to 'src')
-rw-r--r--src/test/scala/firrtlTests/fixed/FixedPointMathSpec.scala50
-rw-r--r--src/test/scala/firrtlTests/fixed/FixedTypeInferenceSpec.scala4
-rw-r--r--src/test/scala/firrtlTests/fixed/RemoveFixedTypeSpec.scala4
3 files changed, 22 insertions, 36 deletions
diff --git a/src/test/scala/firrtlTests/fixed/FixedPointMathSpec.scala b/src/test/scala/firrtlTests/fixed/FixedPointMathSpec.scala
index 85f34606..a9a1bb47 100644
--- a/src/test/scala/firrtlTests/fixed/FixedPointMathSpec.scala
+++ b/src/test/scala/firrtlTests/fixed/FixedPointMathSpec.scala
@@ -10,23 +10,24 @@ import firrtl.Parser.IgnoreInfo
import firrtlTests.FirrtlFlatSpec
class FixedPointMathSpec extends FirrtlFlatSpec {
- def parse (input:String) = Parser.parse(input.split("\n").toIterator, IgnoreInfo)
-
- "Fixed types" should "parse" in {
- val SumPattern = """.*output sum.*<(\d+)>.*.*""".r
- val ProductPattern = """.*output product.*<(\d+)>.*""".r
- val DifferencePattern = """.*output difference.*<(\d+)>.*""".r
-
- val AssignPattern = """\s*(\w+) <= (\w+)\((.*)\)\s*""".r
-
- for {
- bits1 <- 1 to 4
-// binaryPoint1 <- -4 to 4
- binaryPoint1 <- 1 to 4
- bits2 <- 1 to 4
-// binaryPoint2 <- -4 to 4
- binaryPoint2 <- 1 to 4
- } {
+ def parse(input: String) = Parser.parse(input.split("\n").toIterator, IgnoreInfo)
+
+ val SumPattern = """.*output sum.*<(\d+)>.*.*""".r
+ val ProductPattern = """.*output product.*<(\d+)>.*""".r
+ val DifferencePattern = """.*output difference.*<(\d+)>.*""".r
+
+ val AssignPattern = """\s*(\w+) <= (\w+)\((.*)\)\s*""".r
+
+ for {
+ bits1 <- 1 to 4
+ binaryPoint1 <- 1 to 4
+ bits2 <- 1 to 4
+ binaryPoint2 <- 1 to 4
+ } {
+ def config = s"($bits1,$binaryPoint1)($bits2,$binaryPoint2)"
+
+ s"Configuration $config" should "pass" in {
+
val input =
s"""circuit Unit :
| module Unit :
@@ -38,8 +39,7 @@ class FixedPointMathSpec extends FirrtlFlatSpec {
| sum <= add(a, b)
| product <= mul(a, b)
| difference <= sub(a, b)
- | """.
- stripMargin
+ | """.stripMargin
val lowerer = new LowFirrtlCompiler
@@ -49,8 +49,6 @@ class FixedPointMathSpec extends FirrtlFlatSpec {
val output = writer.toString.split("\n")
- def config = s"($bits1,$binaryPoint1)($bits2,$binaryPoint2)"
-
def inferredAddWidth: Int = {
val binaryDifference = binaryPoint1 - binaryPoint2
val (newW1, newW2) = if(binaryDifference > 0) {
@@ -61,10 +59,8 @@ class FixedPointMathSpec extends FirrtlFlatSpec {
newW1.max(newW2) + 1
}
- println(s"Test for configuratio $config")
-
- for(line <- output) {
- line match {
+ for (line <- output) {
+ line match {
case SumPattern(varWidth) =>
assert(varWidth.toInt === inferredAddWidth, s"$config sum sint bits wrong for $line")
case ProductPattern(varWidth) =>
@@ -108,11 +104,9 @@ class FixedPointMathSpec extends FirrtlFlatSpec {
case _ =>
}
case _ =>
-// println(s"No pattern found for ${line}")
}
}
-
- println(writer.toString)
}
}
}
+
diff --git a/src/test/scala/firrtlTests/fixed/FixedTypeInferenceSpec.scala b/src/test/scala/firrtlTests/fixed/FixedTypeInferenceSpec.scala
index 7144f98a..53b4f4c0 100644
--- a/src/test/scala/firrtlTests/fixed/FixedTypeInferenceSpec.scala
+++ b/src/test/scala/firrtlTests/fixed/FixedTypeInferenceSpec.scala
@@ -41,9 +41,6 @@ class FixedTypeInferenceSpec extends FirrtlFlatSpec {
}
val lines = c.serialize.split("\n") map normalized
- for(l <- lines) {
- println(l)
- }
expected foreach { e =>
lines should contain(e)
}
@@ -318,4 +315,3 @@ class FixedTypeInferenceSpec extends FirrtlFlatSpec {
}
}
-// vim: set ts=4 sw=4 et:
diff --git a/src/test/scala/firrtlTests/fixed/RemoveFixedTypeSpec.scala b/src/test/scala/firrtlTests/fixed/RemoveFixedTypeSpec.scala
index d9d6dd27..6799a367 100644
--- a/src/test/scala/firrtlTests/fixed/RemoveFixedTypeSpec.scala
+++ b/src/test/scala/firrtlTests/fixed/RemoveFixedTypeSpec.scala
@@ -42,9 +42,6 @@ class RemoveFixedTypeSpec extends FirrtlFlatSpec {
}
val lines = c.serialize.split("\n") map normalized
- for(l <- lines) {
- println(l)
- }
expected foreach { e =>
lines should contain(e)
}
@@ -218,4 +215,3 @@ class RemoveFixedTypeSpec extends FirrtlFlatSpec {
}
}
-// vim: set ts=4 sw=4 et: