-
Notifications
You must be signed in to change notification settings - Fork 607
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 potential name collision caused by LTL properties #4551
Fix potential name collision caused by LTL properties #4551
Conversation
00d200c
to
af8d1f6
Compare
af8d1f6
to
e898cf1
Compare
@@ -407,4 +407,21 @@ class LTLSpec extends AnyFlatSpec with Matchers with ChiselRunners { | |||
assert(assertBlockLoc < delayIntrinsicLoc) | |||
assert(assumeblockLoc < implicationIntrinsicLoc) | |||
} | |||
|
|||
it should "not produce name collisions with clock" in { |
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.
I added this test to reproduce the bug. It seems like a silly test now that there is no possibility for a name collision. However, it also felt wrong to delete a test, even if it is trivially passing.
Should we keep it?
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.
We should keep it, but possibly extend it to check the names that come out
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.
Sounds good, will add the extended test shortly
@@ -50,7 +50,7 @@ private[chisel3] object BinaryLTLIntrinsic { | |||
)( | |||
implicit sourceInfo: SourceInfo | |||
): Bool = | |||
BaseIntrinsic(f"ltl_$intrinsicName", Bool(), params)(lhs, rhs).suggestName(intrinsicName) | |||
BaseIntrinsic(f"ltl_$intrinsicName", Bool(), params)(lhs, rhs) |
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.
Removing these suggestNames makes the naming quality a lot worse (as evidenced by the updates to the tests) so I think we want to find a different way to solve this. Can you explain a bit more about what is problematic about the collision you were seeing? Was something failing?
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.
The issue I was encountering was that the properties and sequences in the LTL library create nodes for the intrinsics. These nodes are named the same as the intrinsic kind.
This can result in confusing name collisions, especially for intrinsics with names that are likely to show up in user code e.g. clock
or delay
.
This is a case I constructed to produce the error.
class Test extends RawModule {
val io = IO(Input(UInt(8.W)))
val clockWire = Wire(Clock())
withClock(clockWire) {
AssertProperty(Property.eventually(io.orR))
}
val clock = IO(Input(Clock()))
clockWire := clock
}
[error] (unknown): Attempted to name Test.clock: IO[Clock] with a duplicated name 'clock'. Use suggestName to seed a unique name
[error] There were 1 error(s) during hardware elaboration.
The assert property creates a node named clock
, but it is not obvious that it would do so. Then, when attempting to create another node clock
in user code, Chisel complains about the name collision.
More broadly I think the issue is that calling suggestName
inside Chisel can make it very tough to determine why name collisions are happening.
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.
I see, so the issue is that the port comes after the property. I do think the real solution is that Chisel needs to track where the previously named thing was so we can point to it. But I see your point that this was hard to debug and we certainly want to reduce the odds that this happens to users.
How about something a bit lighter touch--keep the .suggestName
, but use names that are less likely to collide with signals named by users, e.g. suggest ltl_clock
instead of clock
?
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.
LGTM!
Contributor Checklist
docs/src
?Type of Improvement
Desired Merge Strategy
Release Notes
Some nodes created by LTL properties had
suggestName
called on them, potentially leading to name collisions with user code.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
.