Skip to content

Commit

Permalink
[SV] Add Intermediary Assert Op for better enable polarity flip (#7302)
Browse files Browse the repository at this point in the history
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 ).
  • Loading branch information
dobios authored Jul 12, 2024
1 parent 8bc5e93 commit 2f8ba28
Show file tree
Hide file tree
Showing 12 changed files with 383 additions and 245 deletions.
3 changes: 2 additions & 1 deletion include/circt/Dialect/SV/SVDialect.td
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def SVDialect : Dialect {
This dialect defines the `sv` dialect, which represents various
SystemVerilog-specific constructs in an AST-like representation.
}];
let dependentDialects = ["circt::comb::CombDialect", "circt::hw::HWDialect"];
let dependentDialects = ["circt::comb::CombDialect", "circt::hw::HWDialect",
"circt::ltl::LTLDialect"];

let useDefaultTypePrinterParser = 1;
let useDefaultAttributePrinterParser = 1;
Expand Down
2 changes: 2 additions & 0 deletions include/circt/Dialect/SV/SVOps.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

#include "circt/Dialect/HW/HWAttributes.h"
#include "circt/Dialect/HW/HWOps.h"
#include "circt/Dialect/LTL/LTLDialect.h"
#include "circt/Dialect/LTL/LTLTypes.h"
#include "circt/Dialect/SV/SVAttributes.h"
#include "circt/Dialect/SV/SVDialect.h"
#include "circt/Dialect/SV/SVTypes.h"
Expand Down
54 changes: 54 additions & 0 deletions include/circt/Dialect/SV/SVVerification.td
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// declarations.
//
//===----------------------------------------------------------------------===//
include "circt/Dialect/LTL/LTLTypes.td"

/// Immediate assertions, like `assert`.
def ImmediateAssert: I32EnumAttrCase<"Immediate", 0, "immediate">;
Expand Down Expand Up @@ -159,3 +160,56 @@ def CoverConcurrentOp : ConcurrentVerifOp<"cover.concurrent",
section 16.5 of the SystemVerilog 2017 specification.
}];
}


/// Property Assertions/Assumptions/Cover analogous to SVA property verification ops.
class PropertyVerifOp<string mnemonic, list<Trait> traits = [AttrSizedOperandSegments]> :
SVOp<mnemonic, traits> {
let arguments = (ins
LTLAnyPropertyType:$property,
OptionalAttr<EventControlAttr>:$event, Optional<I1>:$clock,
Optional<I1>:$disable,
OptionalAttr<StrAttr>:$label);

let assemblyFormat = [{
$property (`on` $event^)? ($clock^)? (`disable_iff` $disable^)?
(`label` $label^)? attr-dict `:` type($property)
}];

let builders = [
// no clock or event
OpBuilder<(ins "mlir::Value":$property,
"mlir::Value":$disable,
CArg<"StringAttr","StringAttr()">: $label),
[{ build(odsBuilder, odsState, property, EventControlAttr{}, Value(), disable, label); }]>
];

let hasVerifier = true;
}

def AssertPropertyOp : PropertyVerifOp<"assert_property"> {
let summary = "property assertion -- can be disabled and clocked";
let description = [{
Assert that a given SVA-style property holds. This is only checked when
the disable signal is low and a clock event occurs. This is analogous to
the verif.assert operation, but with a flipped enable polarity.
}];
}

def AssumePropertyOp : PropertyVerifOp<"assume_property"> {
let summary = "property assumption -- can be disabled and clocked";
let description = [{
Assume that a given SVA-style property holds. This is only considered when
the disable signal is low and a clock event occurs. This is analogous to
the verif.assume operation, but with a flipped enable polarity.
}];
}

def CoverPropertyOp : PropertyVerifOp<"cover_property"> {
let summary = "property cover point -- can be disabled and clocked";
let description = [{
Cover when a given SVA-style property holds. This is only checked when
the disable signal is low and a clock event occurs. This is analogous to
the verif.cover operation, but with a flipped enable polarity.
}];
}
6 changes: 5 additions & 1 deletion include/circt/Dialect/SV/SVVisitors.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class Visitor {
FuncDPIImportOp,
// Verification statements.
AssertOp, AssumeOp, CoverOp, AssertConcurrentOp, AssumeConcurrentOp,
CoverConcurrentOp,
CoverConcurrentOp, AssertPropertyOp, AssumePropertyOp,
CoverPropertyOp,
// Bind Statements
BindOp,
// Simulator control tasks
Expand Down Expand Up @@ -154,6 +155,9 @@ class Visitor {
HANDLE(AssertConcurrentOp, Unhandled);
HANDLE(AssumeConcurrentOp, Unhandled);
HANDLE(CoverConcurrentOp, Unhandled);
HANDLE(AssertPropertyOp, Unhandled);
HANDLE(AssumePropertyOp, Unhandled);
HANDLE(CoverPropertyOp, Unhandled);

// Bind statements.
HANDLE(BindOp, Unhandled);
Expand Down
Loading

0 comments on commit 2f8ba28

Please sign in to comment.