From 4cccd877c25116a1f0b90824aabfc689d7fe50ea Mon Sep 17 00:00:00 2001 From: Wesley W. Terpstra Date: Mon, 18 Jun 2018 19:40:17 +0200 Subject: Fixed UIntToOH(x, 1) invocation with x.width == 0 (#778) --- src/test/scala/chiselTests/OneHotMuxSpec.scala | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/test') diff --git a/src/test/scala/chiselTests/OneHotMuxSpec.scala b/src/test/scala/chiselTests/OneHotMuxSpec.scala index e12d7913..be252bef 100644 --- a/src/test/scala/chiselTests/OneHotMuxSpec.scala +++ b/src/test/scala/chiselTests/OneHotMuxSpec.scala @@ -43,6 +43,14 @@ class OneHotMuxSpec extends FreeSpec with Matchers with ChiselRunners { "UIntToOH with output width greater than 2^(input width)" in { assertTesterPasses(new UIntToOHTester) } + "UIntToOH should not accept width of zero (until zero-width wires are fixed" in { + intercept[java.lang.IllegalArgumentException] { + assertTesterPasses(new BasicTester { + val out = UIntToOH(0.U, 0) + }) + } + } + } class SimpleOneHotTester extends BasicTester { @@ -288,9 +296,13 @@ class DifferentBundleOneHotTester extends BasicTester { class UIntToOHTester extends BasicTester { val out = UIntToOH(1.U, 3) - require(out.getWidth == 3) assert(out === 2.U) + val out2 = UIntToOH(0.U, 1) + require(out2.getWidth == 1) + assert(out2 === 1.U) + stop() } + -- cgit v1.2.3