summaryrefslogtreecommitdiff
path: root/src/test/scala/chiselTests
diff options
context:
space:
mode:
authormergify[bot]2022-10-19 14:28:34 -0700
committerGitHub2022-10-19 14:28:34 -0700
commit80b3b28f451efa85be50994f732599f043f83d86 (patch)
tree8cd6de2c958dde403a275a6811e711ed2b0adde0 /src/test/scala/chiselTests
parent9b8536b6af9f029a0edfb1c8df4f47a67e861c9d (diff)
Don't modify the Builder prefix if reinvoking suggestName on a Data (backport #2789) (#2790)
* Only set the chisel3 Builder prefix during the first invocation of suggestName (cherry picked from commit b684506abab2f7b99d56181d548cb8119d317323) # Conflicts: # core/src/main/scala/chisel3/internal/Builder.scala * Add simple test to show bug fix (cherry picked from commit 255068b105de77a045a0016e3a157b52a81c86d6) * Fix merge conflict * Fix test to not use Hardware inside a bundle for prefixing Co-authored-by: Jared Barocsi <jared.barocsi@sifive.com>
Diffstat (limited to 'src/test/scala/chiselTests')
-rw-r--r--src/test/scala/chiselTests/naming/PrefixSpec.scala26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/test/scala/chiselTests/naming/PrefixSpec.scala b/src/test/scala/chiselTests/naming/PrefixSpec.scala
index b5eac1d4..d8cb3348 100644
--- a/src/test/scala/chiselTests/naming/PrefixSpec.scala
+++ b/src/test/scala/chiselTests/naming/PrefixSpec.scala
@@ -521,4 +521,30 @@ class PrefixSpec extends ChiselPropSpec with Utils {
Select.wires(top).map(_.instanceName) should be(List("nonData_value", "value"))
}
}
+ property("Prefixing should not be affected by repeated calls of suggestName") {
+ class Test extends Module {
+ val in = IO(Input(UInt(3.W)))
+ val prefixed = {
+ val wire = Wire(UInt(3.W)).suggestName("wire") // "prefixed_wire"
+ wire := in
+
+ val thisShouldNotBeHere = {
+ // Second suggestName doesn't modify the instanceName since it was
+ // already suggested, but also should not modify the prefix either
+
+ // Incorrect behavior would rename the wire to
+ // "prefixed_thisShouldNotBeHere_wire"
+ wire.suggestName("wire")
+
+ val out = IO(Output(UInt(3.W)))
+ out := wire
+ out
+ }
+ thisShouldNotBeHere
+ }
+ }
+ aspectTest(() => new Test) { top: Test =>
+ Select.wires(top).map(_.instanceName) should be(List("prefixed_wire"))
+ }
+ }
}