summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Rigge2019-05-01 19:55:21 -0700
committeredwardcwang2019-05-01 19:55:20 -0700
commit94d5b90493b42dd2c85d0d94ea707a69160d0536 (patch)
tree39c3fc0b6e05f5b05c5d826203c2e04092217fcd /src
parentc1ab9e7afd5072c11d879db913e1b553c7fe0dbe (diff)
Make asTypeOf work for bundles with zero-width fields. (#1079)
Closes #1075.
Diffstat (limited to 'src')
-rw-r--r--src/test/scala/chiselTests/AsTypeOfTester.scala22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/test/scala/chiselTests/AsTypeOfTester.scala b/src/test/scala/chiselTests/AsTypeOfTester.scala
index c78ddb17..563e2b11 100644
--- a/src/test/scala/chiselTests/AsTypeOfTester.scala
+++ b/src/test/scala/chiselTests/AsTypeOfTester.scala
@@ -27,6 +27,24 @@ class AsTypeOfBundleTester extends BasicTester {
stop()
}
+class AsTypeOfBundleZeroWidthTester extends BasicTester {
+ class ZeroWidthBundle extends Bundle {
+ val a = UInt(0.W)
+ val b = UInt(1.W)
+ val c = UInt(0.W)
+ }
+
+ val bun = new ZeroWidthBundle
+
+ val bunAsTypeOf = 1.U.asTypeOf(bun)
+
+ assert(bunAsTypeOf.a === 0.U)
+ assert(bunAsTypeOf.b === 1.U)
+ assert(bunAsTypeOf.c === 0.U)
+
+ stop()
+}
+
class AsTypeOfVecTester extends BasicTester {
val vec = ((15 << 12) + (0 << 8) + (1 << 4) + (2 << 0)).U.asTypeOf(Vec(4, SInt(4.W)))
@@ -103,6 +121,10 @@ class AsTypeOfSpec extends ChiselFlatSpec {
assertTesterPasses{ new AsTypeOfBundleTester }
}
+ it should "work with Bundles that have fields of zero width" in {
+ assertTesterPasses{ new AsTypeOfBundleZeroWidthTester }
+ }
+
it should "work with Vecs containing Bits Types" in {
assertTesterPasses{ new AsTypeOfVecTester }
}