Skip to content

Commit 2f8ba28

Browse files
authored
[SV] Add Intermediary Assert Op for better enable polarity flip (#7302)
This PR introduces a new assert property op to the sv dialect and uses that as an intermediary for property assertion emission. This should solve the issue of the polarity being different in SV and in verif for the enable signals ( enable in verif, disable in sv ).
1 parent 8bc5e93 commit 2f8ba28

File tree

12 files changed

+383
-245
lines changed

12 files changed

+383
-245
lines changed

include/circt/Dialect/SV/SVDialect.td

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ def SVDialect : Dialect {
2222
This dialect defines the `sv` dialect, which represents various
2323
SystemVerilog-specific constructs in an AST-like representation.
2424
}];
25-
let dependentDialects = ["circt::comb::CombDialect", "circt::hw::HWDialect"];
25+
let dependentDialects = ["circt::comb::CombDialect", "circt::hw::HWDialect",
26+
"circt::ltl::LTLDialect"];
2627

2728
let useDefaultTypePrinterParser = 1;
2829
let useDefaultAttributePrinterParser = 1;

include/circt/Dialect/SV/SVOps.h

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
#include "circt/Dialect/HW/HWAttributes.h"
1717
#include "circt/Dialect/HW/HWOps.h"
18+
#include "circt/Dialect/LTL/LTLDialect.h"
19+
#include "circt/Dialect/LTL/LTLTypes.h"
1820
#include "circt/Dialect/SV/SVAttributes.h"
1921
#include "circt/Dialect/SV/SVDialect.h"
2022
#include "circt/Dialect/SV/SVTypes.h"

include/circt/Dialect/SV/SVVerification.td

+54
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
// declarations.
1111
//
1212
//===----------------------------------------------------------------------===//
13+
include "circt/Dialect/LTL/LTLTypes.td"
1314

1415
/// Immediate assertions, like `assert`.
1516
def ImmediateAssert: I32EnumAttrCase<"Immediate", 0, "immediate">;
@@ -159,3 +160,56 @@ def CoverConcurrentOp : ConcurrentVerifOp<"cover.concurrent",
159160
section 16.5 of the SystemVerilog 2017 specification.
160161
}];
161162
}
163+
164+
165+
/// Property Assertions/Assumptions/Cover analogous to SVA property verification ops.
166+
class PropertyVerifOp<string mnemonic, list<Trait> traits = [AttrSizedOperandSegments]> :
167+
SVOp<mnemonic, traits> {
168+
let arguments = (ins
169+
LTLAnyPropertyType:$property,
170+
OptionalAttr<EventControlAttr>:$event, Optional<I1>:$clock,
171+
Optional<I1>:$disable,
172+
OptionalAttr<StrAttr>:$label);
173+
174+
let assemblyFormat = [{
175+
$property (`on` $event^)? ($clock^)? (`disable_iff` $disable^)?
176+
(`label` $label^)? attr-dict `:` type($property)
177+
}];
178+
179+
let builders = [
180+
// no clock or event
181+
OpBuilder<(ins "mlir::Value":$property,
182+
"mlir::Value":$disable,
183+
CArg<"StringAttr","StringAttr()">: $label),
184+
[{ build(odsBuilder, odsState, property, EventControlAttr{}, Value(), disable, label); }]>
185+
];
186+
187+
let hasVerifier = true;
188+
}
189+
190+
def AssertPropertyOp : PropertyVerifOp<"assert_property"> {
191+
let summary = "property assertion -- can be disabled and clocked";
192+
let description = [{
193+
Assert that a given SVA-style property holds. This is only checked when
194+
the disable signal is low and a clock event occurs. This is analogous to
195+
the verif.assert operation, but with a flipped enable polarity.
196+
}];
197+
}
198+
199+
def AssumePropertyOp : PropertyVerifOp<"assume_property"> {
200+
let summary = "property assumption -- can be disabled and clocked";
201+
let description = [{
202+
Assume that a given SVA-style property holds. This is only considered when
203+
the disable signal is low and a clock event occurs. This is analogous to
204+
the verif.assume operation, but with a flipped enable polarity.
205+
}];
206+
}
207+
208+
def CoverPropertyOp : PropertyVerifOp<"cover_property"> {
209+
let summary = "property cover point -- can be disabled and clocked";
210+
let description = [{
211+
Cover when a given SVA-style property holds. This is only checked when
212+
the disable signal is low and a clock event occurs. This is analogous to
213+
the verif.cover operation, but with a flipped enable polarity.
214+
}];
215+
}

include/circt/Dialect/SV/SVVisitors.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ class Visitor {
4848
FuncDPIImportOp,
4949
// Verification statements.
5050
AssertOp, AssumeOp, CoverOp, AssertConcurrentOp, AssumeConcurrentOp,
51-
CoverConcurrentOp,
51+
CoverConcurrentOp, AssertPropertyOp, AssumePropertyOp,
52+
CoverPropertyOp,
5253
// Bind Statements
5354
BindOp,
5455
// Simulator control tasks
@@ -154,6 +155,9 @@ class Visitor {
154155
HANDLE(AssertConcurrentOp, Unhandled);
155156
HANDLE(AssumeConcurrentOp, Unhandled);
156157
HANDLE(CoverConcurrentOp, Unhandled);
158+
HANDLE(AssertPropertyOp, Unhandled);
159+
HANDLE(AssumePropertyOp, Unhandled);
160+
HANDLE(CoverPropertyOp, Unhandled);
157161

158162
// Bind statements.
159163
HANDLE(BindOp, Unhandled);

0 commit comments

Comments
 (0)