-
Notifications
You must be signed in to change notification settings - Fork 143
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
[slang] Introduce clock resolution support (SystemVerilog LRM 16.13/16.16 sections). #1027
base: master
Are you sure you want to change the base?
[slang] Introduce clock resolution support (SystemVerilog LRM 16.13/16.16 sections). #1027
Conversation
a83cca8
to
a2d5e00
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1027 +/- ##
==========================================
+ Coverage 94.69% 94.87% +0.18%
==========================================
Files 191 193 +2
Lines 47553 48023 +470
==========================================
+ Hits 45031 45563 +532
+ Misses 2522 2460 -62
... and 20 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
8b9899d
to
d955064
Compare
Thanks for the PR. I'll do a more thorough review of the resolution logic, but to comment on the high level approach:
|
Closes #536
In this PR, I introduce the implementation of all possible illegal situations from the SystemVerilog LRM 16.13/16.16 sections and also some additional clock checks that support VCS.
Here is the bunch of new error types such as:
The main data structure is
ClockingEvent
, which is a wrapper forSignalEventControl
, it stores the event in two different forms - edge (EdgeKind
) + vector of signal references (EventList
) andstrEvent
(string representation for comparing two different clock events - in case the event is a complex expression (e.g. containsiff expr...
)). This data structure is designed to accumulate clock events during AST traversal and then compare them (in the case of a complex event - they are compared as strings, otherwise the symbol vectors are simply compared together with the edge).The algorithm starts its work immediately after the end of the elaboration of the AST. It is launched only in the absence of errors (
invalid
nodes) in it, as incorrect assumptions can be made during the analysis of clock signals.A clock signal is considered to be a signal that is present in the
EventList
sequence or properties, as well as those signals from the sensitivity list of the always block that are not used anywhere inside except for assertions.The algorithm is implemented as nested AST visitors. The main one is the
ClockResolutionVisitor
, which searches for clocking blocks (which override the clock event for the entire instance) by calling theClockingBlockVisitor
(checking the correctness of assertion sequences and properties inside it) for each instance of the module. It first callsMarkInvalidVisitor
to mark invalid nodes that slang may leave even in the absence of errors. When encountering an assertion, it callsConcurrentAssertionVisitor
, which traverses the property under the assertion and tries to infer a clock event for it, which in turn callsSequenceVisitor
to traverse and check clock properties of the sequence under the property.There are also 2 separate visitors -
AlwaysTimingVisitor
andAlwaysTimingCheckUseVisitor
, the first of which fills in inferred clocks fromSignalEventControl
, and the second one removes from inferred clocks those which are used outside of assertions - those that are not considered clocks according to the standard.