summaryrefslogtreecommitdiff
path: root/src/test/scala
diff options
context:
space:
mode:
authorPaul Rigge2016-11-09 16:57:26 -0800
committerducky2016-11-21 12:48:10 -0800
commit87144822597c51fc010ab4aaca2db48904dce029 (patch)
tree658a56f2a8fdac9dbe02b4c28b622f5b0ee3d073 /src/test/scala
parentb39b08b6d489ab6d2dc9bb8a40a87c4ac5834828 (diff)
Add some more tests.
Diffstat (limited to 'src/test/scala')
-rw-r--r--src/test/scala/chiselTests/RangeSpec.scala58
1 files changed, 56 insertions, 2 deletions
diff --git a/src/test/scala/chiselTests/RangeSpec.scala b/src/test/scala/chiselTests/RangeSpec.scala
index edaff8aa..b18e9d2a 100644
--- a/src/test/scala/chiselTests/RangeSpec.scala
+++ b/src/test/scala/chiselTests/RangeSpec.scala
@@ -8,10 +8,64 @@ import org.scalatest.{Matchers, FreeSpec}
class RangeSpec extends FreeSpec with Matchers {
"Ranges can be specified for UInt, SInt, and FixedPoint" - {
"to specify a UInt" in {
- val x = UInt(range"[0, 7)")
+ val x = UInt(range"[0, 8)")
x.getWidth should be (3)
println(range"[4,32)")
+
+ UInt(range"[0, 8]").getWidth should be (4)
+ }
+
+ "to specify an SInt" in {
+ SInt(range"[0, 8)").getWidth should be (4)
+
+ SInt(range"[0, 8]").getWidth should be (5)
+
+ SInt(range"[-4, 4)").getWidth should be (3)
+ }
+
+ "it should check that the range is valid for UInt" in {
+ an [IllegalArgumentException] should be thrownBy {
+ UInt(range"[1, 0]")
+ }
+
+ an [IllegalArgumentException] should be thrownBy {
+ UInt(range"[-1, 1]")
+ }
+
+ an [IllegalArgumentException] should be thrownBy {
+ UInt(range"(0,0]")
+ }
+
+ an [IllegalArgumentException] should be thrownBy {
+ UInt(range"[0,0)")
+ }
+
+ an [IllegalArgumentException] should be thrownBy {
+ UInt(range"(0,0)")
+ }
+
+ UInt(range"[0, 0]").getWidth should be (1)
+ }
+
+ "it should check that the range is valid for SInt" in {
+ an [IllegalArgumentException] should be thrownBy {
+ SInt(range"[1, 0]")
+ }
+
+ an [IllegalArgumentException] should be thrownBy {
+ SInt(range"(0,0]")
+ }
+
+ an [IllegalArgumentException] should be thrownBy {
+ SInt(range"[0,0)")
+ }
+
+ an [IllegalArgumentException] should be thrownBy {
+ SInt(range"(0,0)")
+ }
+
+ SInt(range"[0, 0]").getWidth should be (1)
}
- }
+ }
}