summaryrefslogtreecommitdiff
path: root/src/test/scala/chiselTests/UIntOps.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/scala/chiselTests/UIntOps.scala')
-rw-r--r--src/test/scala/chiselTests/UIntOps.scala33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/test/scala/chiselTests/UIntOps.scala b/src/test/scala/chiselTests/UIntOps.scala
index bba06d11..62d00de2 100644
--- a/src/test/scala/chiselTests/UIntOps.scala
+++ b/src/test/scala/chiselTests/UIntOps.scala
@@ -153,4 +153,37 @@ class UIntOpsSpec extends ChiselPropSpec with Matchers with Utils {
io.out := io.in.asBools()(2)
})
}
+
+ // We use WireDefault with 2 arguments because of
+ // https://www.chisel-lang.org/api/3.4.1/chisel3/WireDefault$.html
+ // Single Argument case 2
+ property("modulo divide should give min width of arguments") {
+ assertKnownWidth(4) {
+ val x = WireDefault(UInt(8.W), DontCare)
+ val y = WireDefault(UInt(4.W), DontCare)
+ val op = x % y
+ WireDefault(chiselTypeOf(op), op)
+ }
+ assertKnownWidth(4) {
+ val x = WireDefault(UInt(4.W), DontCare)
+ val y = WireDefault(UInt(8.W), DontCare)
+ val op = x % y
+ WireDefault(chiselTypeOf(op), op)
+ }
+ }
+
+ property("division should give the width of the numerator") {
+ assertKnownWidth(8) {
+ val x = WireDefault(UInt(8.W), DontCare)
+ val y = WireDefault(UInt(4.W), DontCare)
+ val op = x / y
+ WireDefault(chiselTypeOf(op), op)
+ }
+ assertKnownWidth(4) {
+ val x = WireDefault(UInt(4.W), DontCare)
+ val y = WireDefault(UInt(8.W), DontCare)
+ val op = x / y
+ WireDefault(chiselTypeOf(op), op)
+ }
+ }
}