aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/firrtlTests/WidthSpec.scala
diff options
context:
space:
mode:
authorAdam Izraelevitz2018-02-21 14:30:00 -0800
committerGitHub2018-02-21 14:30:00 -0800
commit65bbf155003a86cd836f7ff4a2def6af91794780 (patch)
tree49c968e051a36c323fd0a5839ea6e1432b2f56aa /src/test/scala/firrtlTests/WidthSpec.scala
parentedcb81a34dbf8a04d0b011aa1ca07c6e19598f23 (diff)
Change primop arg type (#587)
* Changed primops to not accept mixed-type args * Changed return type of sub of two uints to uint * Added negative tests * Removed rocket.fir. Manually changed RocketCore to not mix mul arg types. Added integration tests * Clarified test description and remove println * Fixed use of throwInternalError
Diffstat (limited to 'src/test/scala/firrtlTests/WidthSpec.scala')
-rw-r--r--src/test/scala/firrtlTests/WidthSpec.scala78
1 files changed, 42 insertions, 36 deletions
diff --git a/src/test/scala/firrtlTests/WidthSpec.scala b/src/test/scala/firrtlTests/WidthSpec.scala
index 770c2785..d1d02ee2 100644
--- a/src/test/scala/firrtlTests/WidthSpec.scala
+++ b/src/test/scala/firrtlTests/WidthSpec.scala
@@ -22,42 +22,6 @@ class WidthSpec extends FirrtlFlatSpec {
}
}
- "Add of UInt<2> and SInt<2>" should "return SInt<4>" in {
- val passes = Seq(
- ToWorkingIR,
- CheckHighForm,
- ResolveKinds,
- InferTypes,
- CheckTypes,
- InferWidths)
- val input =
- """circuit Unit :
- | module Unit :
- | input x: UInt<2>
- | input y: SInt<2>
- | output z: SInt
- | z <= add(x, y)""".stripMargin
- val check = Seq( "output z : SInt<4>")
- executeTest(input, check, passes)
- }
- "SInt<2> - UInt<3>" should "return SInt<5>" in {
- val passes = Seq(
- ToWorkingIR,
- CheckHighForm,
- ResolveKinds,
- InferTypes,
- CheckTypes,
- InferWidths)
- val input =
- """circuit Unit :
- | module Unit :
- | input x: UInt<3>
- | input y: SInt<2>
- | output z: SInt
- | z <= sub(y, x)""".stripMargin
- val check = Seq( "output z : SInt<5>")
- executeTest(input, check, passes)
- }
"Dshl by 20 bits" should "result in an error" in {
val passes = Seq(
ToWorkingIR,
@@ -121,4 +85,46 @@ class WidthSpec extends FirrtlFlatSpec {
executeTest(input, Nil, passes)
}
}
+
+ "Add of UInt<2> and SInt<2>" should "error" in {
+ val passes = Seq(
+ ToWorkingIR,
+ CheckHighForm,
+ ResolveKinds,
+ InferTypes,
+ CheckTypes,
+ InferWidths)
+ val input =
+ """circuit Unit :
+ | module Unit :
+ | input x: UInt<2>
+ | input y: SInt<2>
+ | output z: SInt
+ | z <= add(x, y)""".stripMargin
+ val check = Seq( "output z : SInt<4>")
+ intercept[PassExceptions] {
+ executeTest(input, check, passes)
+ }
+ }
+
+ "SInt<2> - UInt<3>" should "error" in {
+ val passes = Seq(
+ ToWorkingIR,
+ CheckHighForm,
+ ResolveKinds,
+ InferTypes,
+ CheckTypes,
+ InferWidths)
+ val input =
+ """circuit Unit :
+ | module Unit :
+ | input x: UInt<3>
+ | input y: SInt<2>
+ | output z: SInt
+ | z <= sub(y, x)""".stripMargin
+ val check = Seq( "output z : SInt<5>")
+ intercept[PassExceptions] {
+ executeTest(input, check, passes)
+ }
+ }
}