summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Lawson2018-07-31 14:11:33 -0700
committerJack Koenig2018-07-31 14:11:33 -0700
commit64a8f52c48905e9bf28e709cde2de89215a35c80 (patch)
tree0ce0f63a3891fed71810f81866ca5b7ee957b3c2 /src
parentfea4f3a80d2ed5d4735ef33558bebbab290290fb (diff)
Ensure names work for bundles and literals. (#853)
Fixes #852
Diffstat (limited to 'src')
-rw-r--r--src/test/scala/chiselTests/InstanceNameSpec.scala54
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")
+ }
+}