summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/test/scala/chiselTests/NamingAnnotationTest.scala32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/test/scala/chiselTests/NamingAnnotationTest.scala b/src/test/scala/chiselTests/NamingAnnotationTest.scala
index e35c77c1..a02dfe56 100644
--- a/src/test/scala/chiselTests/NamingAnnotationTest.scala
+++ b/src/test/scala/chiselTests/NamingAnnotationTest.scala
@@ -203,6 +203,32 @@ class PartialNamedModule extends NamedModuleTester {
val test = innerNamedFunction()
}
+@chiselName
+class NoChiselNamePrefixTester extends NamedModuleTester {
+ @chiselName
+ class NoChiselNamePrefixClass extends chisel3.experimental.NoChiselNamePrefix {
+ val a = expectName(1.U +& 2.U, "a")
+ }
+ val inst = new NoChiselNamePrefixClass
+ @chiselName
+ class NormalClass {
+ val b = 1.U +& 2.U
+ }
+ val foo = new NormalClass
+ expectName(foo.b, "foo_b")
+ val bar = new NormalClass with chisel3.experimental.NoChiselNamePrefix
+ expectName(bar.b, "b")
+
+ // Check that we're not matching by name but actual type
+ trait NoChiselNamePrefix
+ @chiselName
+ class FakeNoChiselNamePrefix extends NoChiselNamePrefix {
+ val c = 1.U +& 2.U
+ }
+ val fizz = new FakeNoChiselNamePrefix
+ expectName(fizz.c, "fizz_c")
+}
+
/** A simple test that checks the recursive function val naming annotation both compiles and
* generates the expected names.
@@ -240,4 +266,10 @@ class NamingAnnotationSpec extends ChiselPropSpec {
property("NonBuilderFunction should run outside a Builder context") {
NonNamedHelper.NonBuilderFunction() should be (2)
}
+
+ property("NoChiselNamePrefix should prevent prefixing when using @chiselName") {
+ var module: NoChiselNamePrefixTester = null
+ elaborate { module = new NoChiselNamePrefixTester; module }
+ assert(module.getNameFailures().isEmpty)
+ }
}