Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AffectsChiselPrefix test #2693

Merged
merged 1 commit into from
Aug 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/test/scala/chiselTests/naming/PrefixSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"))
}
}
}