diff options
| author | Jim Lawson | 2018-07-31 14:11:33 -0700 |
|---|---|---|
| committer | Jack Koenig | 2018-07-31 14:11:33 -0700 |
| commit | 64a8f52c48905e9bf28e709cde2de89215a35c80 (patch) | |
| tree | 0ce0f63a3891fed71810f81866ca5b7ee957b3c2 /src/test | |
| parent | fea4f3a80d2ed5d4735ef33558bebbab290290fb (diff) | |
Ensure names work for bundles and literals. (#853)
Fixes #852
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/scala/chiselTests/InstanceNameSpec.scala | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/test/scala/chiselTests/InstanceNameSpec.scala b/src/test/scala/chiselTests/InstanceNameSpec.scala new file mode 100644 index 00000000..30dc46ba --- /dev/null +++ b/src/test/scala/chiselTests/InstanceNameSpec.scala @@ -0,0 +1,54 @@ +// See LICENSE for license details. + +package chiselTests + +import chisel3._ +import chisel3.experimental.{DataMirror, FixedPoint} +import chisel3.testers.BasicTester + +class InstanceNameModule extends Module { + val io = IO(new Bundle { + val foo = Input(UInt(32.W)) + val bar = Output(UInt(32.W)) + }) + val x = 3.U + val y = UInt(8.W) + val z = new Bundle { + val foo = UInt(8.W) + } + + val q = Module(new util.Queue(UInt(32.W), 4)) + + io.bar := io.foo + x +} + +class InstanceNameSpec extends ChiselFlatSpec { + behavior of "instanceName" + val moduleName = "InstanceNameModule" + var m: InstanceNameModule = _ + elaborate { m = new InstanceNameModule; m } + + it should "work with module IO" in { + val io = m.io.pathName + assert(io == moduleName + ".io") + } + + it should "work with internal vals" in { + val x = m.x.pathName + val y = m.y.pathName + val z = m.z.pathName + assert(x == moduleName + ".UInt<2>(\"h03\")") + assert(y == moduleName + ".y") + assert(z == moduleName + ".z") + } + + it should "work with bundle elements" in { + val foo = m.z.foo.pathName + assert(foo == moduleName + ".z.foo") + } + + it should "work with modules" in { + val q = m.q.pathName + assert(q == moduleName + ".q") + } +} |
