From 1c5bd39a192272877cf4b8dc3d26a9284eb0c05d Mon Sep 17 00:00:00 2001 From: mergify[bot] Date: Tue, 23 Aug 2022 21:31:57 +0000 Subject: Add AffectsChiselPrefix tests to PrefixSpec (#2693) (#2695) (cherry picked from commit 1a23b42429bf9de7dfab9f0a8e67334f8c5d4540) Co-authored-by: Jared Barocsi <82000041+jared-barocsi@users.noreply.github.com>--- src/test/scala/chiselTests/naming/PrefixSpec.scala | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/test/scala/chiselTests/naming') diff --git a/src/test/scala/chiselTests/naming/PrefixSpec.scala b/src/test/scala/chiselTests/naming/PrefixSpec.scala index 6d52407e..b5eac1d4 100644 --- a/src/test/scala/chiselTests/naming/PrefixSpec.scala +++ b/src/test/scala/chiselTests/naming/PrefixSpec.scala @@ -7,6 +7,7 @@ import chisel3.stage.ChiselStage import chisel3.aop.Select import chisel3.experimental.{dump, noPrefix, prefix, treedump} import chiselTests.{ChiselPropSpec, Utils} +import chisel3.experimental.AffectsChiselPrefix class PrefixSpec extends ChiselPropSpec with Utils { implicit val minimumMajorVersion: Int = 12 @@ -497,4 +498,27 @@ class PrefixSpec extends ChiselPropSpec with Utils { Select.wires(top).map(_.instanceName) should be(List("a_b_c_d")) } } + + property("Prefixing of AffectsChiselPrefix objects should work") { + class NotAData extends AffectsChiselPrefix { + val value = Wire(UInt(3.W)) + } + class NotADataUnprefixed { + val value = Wire(UInt(3.W)) + } + class Test extends Module { + { + val nonData = new NotAData + // Instance name of nonData.value should be nonData_value + nonData.value := RegNext(3.U) + + val nonData2 = new NotADataUnprefixed + // Instance name of nonData2.value should be value + nonData2.value := RegNext(3.U) + } + } + aspectTest(() => new Test) { top: Test => + Select.wires(top).map(_.instanceName) should be(List("nonData_value", "value")) + } + } } -- cgit v1.2.3 From 80b3b28f451efa85be50994f732599f043f83d86 Mon Sep 17 00:00:00 2001 From: mergify[bot] Date: Wed, 19 Oct 2022 14:28:34 -0700 Subject: 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 --- src/test/scala/chiselTests/naming/PrefixSpec.scala | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/test/scala/chiselTests/naming') 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")) + } + } } -- cgit v1.2.3