diff options
| author | Jack Koenig | 2019-11-05 13:41:47 -0800 |
|---|---|---|
| committer | GitHub | 2019-11-05 13:41:47 -0800 |
| commit | 92d88ffbe1663b4aa917c6c8b66a4fd697282410 (patch) | |
| tree | 246e46176067204475afc2cb781816fe7969283a /src | |
| parent | 19e651faccf2c922888fb0eae69981399120774f (diff) | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/scala/chiselTests/AsyncResetSpec.scala | 32 |
1 files changed, 32 insertions, 0 deletions
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() } + }) + } } |
