diff options
| author | Jack Koenig | 2017-12-28 16:56:05 -0800 |
|---|---|---|
| committer | Richard Lin | 2018-01-02 13:43:01 -0800 |
| commit | ade792ee7c5bb718f738f5e4c3886b2e87c68756 (patch) | |
| tree | 0b3fb00565e1c442abd7885d490cd4324f02d3fe /src/test/scala/chiselTests/AutoNestedCloneSpec.scala | |
| parent | 43e4d6dbd0f131c7484dc24cb09ab3a25614cb62 (diff) | |
Add support for autoclonetype of bound, anonymous inner Bundles
Also change Data.outerModule to Bundle._outerInst since it is only used
in autoclonetype. _outerInst is also Option[Object] instead of
Option[BaseModule] because the outer object could also be a Bundle.
Diffstat (limited to 'src/test/scala/chiselTests/AutoNestedCloneSpec.scala')
| -rw-r--r-- | src/test/scala/chiselTests/AutoNestedCloneSpec.scala | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/test/scala/chiselTests/AutoNestedCloneSpec.scala b/src/test/scala/chiselTests/AutoNestedCloneSpec.scala index d3977213..746780be 100644 --- a/src/test/scala/chiselTests/AutoNestedCloneSpec.scala +++ b/src/test/scala/chiselTests/AutoNestedCloneSpec.scala @@ -5,6 +5,12 @@ import Chisel.ChiselException import org.scalatest._ import chisel3._ +class BundleWithAnonymousInner(val w: Int) extends Bundle { + val inner = new Bundle { + val foo = Input(UInt(w.W)) + } +} + class AutoNestedCloneSpec extends ChiselFlatSpec with Matchers { behavior of "autoCloneType of inner Bundle in Chisel3" @@ -18,7 +24,7 @@ class AutoNestedCloneSpec extends ChiselFlatSpec with Matchers { def getIO = new InnerIOType } val io = IO(new Bundle {}) - val myWire = Wire((new Middle(w)).getIO) + val myWire = Wire((new Middle(w)).getIO) } new Outer(2) } @@ -56,6 +62,33 @@ class AutoNestedCloneSpec extends ChiselFlatSpec with Matchers { } } + it should "clone an anonymous, bound, inner bundle of another bundle successfully" in { + elaborate { + class TestModule(w: Int) extends Module { + val io = IO(new BundleWithAnonymousInner(w) ) + val w0 = WireInit(io) + val w1 = WireInit(io.inner) + } + new TestModule(8) + } + } + + it should "clone an anonymous, inner bundle of a Module, bound to another bundle successfully" in { + elaborate { + class TestModule(w: Int) extends Module { + val bun = new Bundle { + val foo = UInt(w.W) + } + val io = IO(new Bundle { + val inner = Input(bun) + }) + val w0 = WireInit(io) + val w1 = WireInit(io.inner) + } + new TestModule(8) + } + } + behavior of "anonymous doubly-nested inner bundle fails with clear error" ( the[ChiselException] thrownBy { elaborate { |
