From 92d88ffbe1663b4aa917c6c8b66a4fd697282410 Mon Sep 17 00:00:00 2001 From: Jack Koenig Date: Tue, 5 Nov 2019 13:41:47 -0800 Subject: Support literals cast to aggregates as async reset reg init values (#1225) Accomplished by changing the code gen for casting literals to aggregates. Rather than connecting the literal to a wire that is then bit selected from, just bit select from the literal which saves the creation of an intermediate wire and matches FIRRTL's semantics for legal async reset initial values.--- src/test/scala/chiselTests/AsyncResetSpec.scala | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/test/scala/chiselTests/AsyncResetSpec.scala') diff --git a/src/test/scala/chiselTests/AsyncResetSpec.scala b/src/test/scala/chiselTests/AsyncResetSpec.scala index 78a29e99..d2e04bf8 100644 --- a/src/test/scala/chiselTests/AsyncResetSpec.scala +++ b/src/test/scala/chiselTests/AsyncResetSpec.scala @@ -169,4 +169,36 @@ class AsyncResetSpec extends ChiselFlatSpec { assertTesterPasses(new AsyncResetQueueTester) } + it should "allow literals cast to Bundles as reset values" in { + class MyBundle extends Bundle { + val x = UInt(16.W) + val y = UInt(16.W) + } + assertTesterPasses(new BasicTester { + val reg = withReset(reset.asAsyncReset) { + RegNext(0xbad0cad0L.U.asTypeOf(new MyBundle), 0xdeadbeefL.U.asTypeOf(new MyBundle)) + } + val (count, done) = Counter(true.B, 4) + when (count === 0.U) { + chisel3.assert(reg.asUInt === 0xdeadbeefL.U) + } .otherwise { + chisel3.assert(reg.asUInt === 0xbad0cad0L.U) + } + when (done) { stop() } + }) + } + it should "allow literals cast to Vecs as reset values" in { + assertTesterPasses(new BasicTester { + val reg = withReset(reset.asAsyncReset) { + RegNext(0xbad0cad0L.U.asTypeOf(Vec(4, UInt(8.W))), 0xdeadbeefL.U.asTypeOf(Vec(4, UInt(8.W)))) + } + val (count, done) = Counter(true.B, 4) + when (count === 0.U) { + chisel3.assert(reg.asUInt === 0xdeadbeefL.U) + } .otherwise { + chisel3.assert(reg.asUInt === 0xbad0cad0L.U) + } + when (done) { stop() } + }) + } } -- cgit v1.2.3