summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authormergify[bot]2022-07-06 00:28:02 +0000
committerGitHub2022-07-06 00:28:02 +0000
commit2b977a74293a49e9e2a5d960a6a9c07df22430ce (patch)
tree320e9ee49d336fa18e63a04bf79dfcf6dbb1856d /src/test
parenta931c5e218014c659bbff7d0dec74c882281d9a0 (diff)
Implement trait for Chisel compiler to name arbitrary non-Data types (#2610) (#2617)
Co-authored-by: Jack Koenig <koenig@sifive.com> Co-authored-by: Megan Wachs <megan@sifive.com> (cherry picked from commit 3ab34cddd8b87c22d5fc31020f10ddb2f1990d51) Co-authored-by: Jared Barocsi <82000041+jared-barocsi@users.noreply.github.com>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/scala/chiselTests/NamingAnnotationTest.scala31
1 files changed, 11 insertions, 20 deletions
diff --git a/src/test/scala/chiselTests/NamingAnnotationTest.scala b/src/test/scala/chiselTests/NamingAnnotationTest.scala
index ded321cd..a3f39c51 100644
--- a/src/test/scala/chiselTests/NamingAnnotationTest.scala
+++ b/src/test/scala/chiselTests/NamingAnnotationTest.scala
@@ -4,12 +4,13 @@ package chiselTests
import chisel3._
import chisel3.experimental.chiselName
+import chisel3.experimental.AffectsChiselPrefix
import chisel3.internal.InstanceId
import chisel3.stage.ChiselStage
import scala.collection.mutable.ListBuffer
-trait NamedModuleTester extends Module {
+trait NamedModuleTester extends Module with AffectsChiselPrefix {
val expectedNameMap = ListBuffer[(InstanceId, String)]()
val expectedModuleNameMap = ListBuffer[(Module, String)]()
@@ -48,25 +49,20 @@ trait NamedModuleTester extends Module {
failures.toList
}
}
-@chiselName
-class OuterNamedNonModule {
+class OuterNamedNonModule extends AffectsChiselPrefix {
val value = Wire(Bool())
}
-@chiselName
-class NonModule {
+class NonModule extends AffectsChiselPrefix {
val value = Wire(Bool())
- @chiselName
- class InnerNamedNonModule {
+ class InnerNamedNonModule extends AffectsChiselPrefix {
val value = Wire(Bool())
}
val inner = new InnerNamedNonModule
val outer = new OuterNamedNonModule
}
-@chiselName
class NamedModule extends NamedModuleTester {
- @chiselName
def FunctionMockupInner(): UInt = {
val my2A = 1.U
val my2B = expectName(my2A +& 2.U, "test_myNested_my2B")
@@ -74,7 +70,6 @@ class NamedModule extends NamedModuleTester {
my2C
}
- @chiselName
def FunctionMockup(): UInt = {
val myNested = expectName(FunctionMockupInner(), "test_myNested")
val myA = expectName(1.U + myNested, "test_myA")
@@ -123,11 +118,9 @@ class NamedModule extends NamedModuleTester {
NoReturnFunction()
}
-@chiselName
class NameCollisionModule extends NamedModuleTester {
- @chiselName
- def repeatedCalls(id: Int): UInt = {
- val test = expectName(1.U + 3.U, s"test_$id") // should disambiguate by invocation order
+ def repeatedCalls(name: String): UInt = {
+ val test = expectName(1.U + 3.U, s"${name}_test") // should disambiguate by invocation order
test + 2.U
}
@@ -135,8 +128,8 @@ class NameCollisionModule extends NamedModuleTester {
def innerNamedFunction() {
// ... but not this inner function
def innerUnnamedFunction() {
- val a = repeatedCalls(1)
- val b = repeatedCalls(2)
+ val a = repeatedCalls("a")
+ val b = repeatedCalls("b")
}
innerUnnamedFunction()
@@ -212,19 +205,17 @@ class NoChiselNamePrefixTester extends NamedModuleTester {
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
+ val foo = new NormalClass with AffectsChiselPrefix
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 {
+ class FakeNoChiselNamePrefix extends NoChiselNamePrefix with AffectsChiselPrefix {
val c = 1.U +& 2.U
}
val fizz = new FakeNoChiselNamePrefix