From e769e5a26f6bd3f87962ad084776c01316ad6fbf Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Fri, 24 Mar 2017 15:09:07 -0700 Subject: Fix getWidth on empty Vecs; add test Use fold(0) instead of reduce to handle the corner case. --- src/test/scala/chiselTests/Vec.scala | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/test') diff --git a/src/test/scala/chiselTests/Vec.scala b/src/test/scala/chiselTests/Vec.scala index d7c2c648..80c4040d 100644 --- a/src/test/scala/chiselTests/Vec.scala +++ b/src/test/scala/chiselTests/Vec.scala @@ -134,6 +134,11 @@ class OneBitUnitRegVecTester extends BasicTester { stop() } +class ZeroEntryVecTester extends BasicTester { + require(Vec(0, Bool()).getWidth == 0) + stop() +} + class VecSpec extends ChiselPropSpec { // Disable shrinking on error. implicit val noShrinkListVal = Shrink[List[Int]](_ => Stream.empty) @@ -187,4 +192,8 @@ class VecSpec extends ChiselPropSpec { property("A Reg of a Vec of a single 1 bit element should compile and work") { assertTesterPasses{ new OneBitUnitRegVecTester } } + + property("A Vec with zero entries should compile and have zero width") { + assertTesterPasses{ new ZeroEntryVecTester } + } } -- cgit v1.2.3