-
Notifications
You must be signed in to change notification settings - Fork 613
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
Fix Arg.name and earlyLocalName for probes #4359
Fix Arg.name and earlyLocalName for probes #4359
Conversation
I think this makes sense, but can you please add a unit test like the example in the PR description that shows the issue and confirms we don't regress in the future? |
Thanks for identifying and chasing this down!! |
LGTM but agree it needs a test. Not sure of the best place for this specific test, something in ProbeSpec would be fine or it could be treated as a DataMirror check like here:
|
I added a simple unit test. But, there may be more to this. This test is failing with
|
Lol, looks like that test was expecting the previous bad output, you should just update that test! |
"Left (ProbeSpec_Anon.p: IO[UInt<4>]) and Right (ProbeSpec_Anon.Node(ProbeSpec_Anon.w: Wire[Bool]): OpResult[Bool]) have different types" | ||
"Left (ProbeSpec_Anon.p: IO[UInt<4>]) and Right (ProbeSpec_Anon.probe(w): OpResult[Bool]) have different types" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test was failing due to missing cases in earlyLocalName
for probes. I added cases for them, and this error message seems sensible to me now.
class TestMod extends RawModule { | ||
val a = IO(Output(Probe(UInt()))) | ||
val w = WireInit(UInt(32.W), 0.U) | ||
a := w | ||
require(reflect.DataMirror.queryNameGuess(a) == "a") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class TestMod extends RawModule { | |
val a = IO(Output(Probe(UInt()))) | |
val w = WireInit(UInt(32.W), 0.U) | |
a := w | |
require(reflect.DataMirror.queryNameGuess(a) == "a") | |
} | |
class TestMod extends RawModule { | |
val a = IO(Output(Probe(UInt()))) | |
val w = WireInit(UInt(32.W), 0.U) | |
a := w | |
require(reflect.DataMirror.queryNameGuess(a) == "a") | |
} | |
ChiselStage.emitCHIRRTL(new TestMod) |
You have to actually run elaboration for this test to do anything. This is why I always make sure my unit tests fail before they pass (e.g. change the check to say it's equal to "b"
, see it fail, then fix it).
case Some(ProbeExpr(Node(ref))) => s"probe(${earlyLocalName(ref, includeRoot)})" | ||
case Some(RWProbeExpr(Node(ref))) => s"rwprobe(${earlyLocalName(ref, includeRoot)})" | ||
case Some(ProbeRead(Node(ref))) => s"read(${earlyLocalName(ref, includeRoot)})" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
case Some(ProbeExpr(Node(ref))) => s"probe(${earlyLocalName(ref, includeRoot)})" | |
case Some(RWProbeExpr(Node(ref))) => s"rwprobe(${earlyLocalName(ref, includeRoot)})" | |
case Some(ProbeRead(Node(ref))) => s"read(${earlyLocalName(ref, includeRoot)})" | |
case Some(ProbeExpr(Node(ref))) => s"${earlyLocalName(ref, includeRoot)}" | |
case Some(RWProbeExpr(Node(ref))) => s"${earlyLocalName(ref, includeRoot)}" | |
case Some(ProbeRead(Node(ref))) => s"${earlyLocalName(ref, includeRoot)}" |
Probe information is not part of the name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks Trevor!
(cherry picked from commit 15c3cc9) # Conflicts: # src/test/scala/chiselTests/ProbeSpec.scala
(cherry picked from commit 15c3cc9) # Conflicts: # src/test/scala/chiselTests/ProbeSpec.scala
Contributor Checklist
docs/src
?Type of Improvement
Names for probe Args will be the default
toString
. For example, if you useDataMirror
to get theearlyName
of a probe (derived fromArg.name
), you will see this defaulttoString
.If that name is ever used for an identifier, Chisel will throw an exception due to the invalid name.
Desired Merge Strategy
Release Notes
Reviewer Checklist (only modified by reviewer)
3.6.x
,5.x
, or6.x
depending on impact, API modification or big change:7.0
)?Enable auto-merge (squash)
, clean up the commit message, and label withPlease Merge
.Create a merge commit
.