15 #include "mlir/Pass/Pass.h"
19 #define GEN_PASS_DEF_CREATECOMPANIONASSUME
20 #include "circt/Dialect/FIRRTL/Passes.h.inc"
24 using namespace circt;
25 using namespace firrtl;
28 struct CreateCompanionAssumePass
29 :
public circt::firrtl::impl::CreateCompanionAssumeBase<
30 CreateCompanionAssumePass> {
31 void runOnOperation()
override {
33 getOperation().walk([&](firrtl::AssertOp assertOp) {
34 OpBuilder builder(assertOp);
35 builder.setInsertionPointAfter(assertOp);
36 auto guards = assertOp->getAttrOfType<ArrayAttr>(
"guards");
38 bool isUnrOnlyAssert =
false;
42 isUnrOnlyAssert = llvm::any_of(guards, [](Attribute attr) {
43 StringAttr strAttr = dyn_cast<StringAttr>(attr);
44 return strAttr && strAttr.getValue() ==
"USE_UNR_ONLY_CONSTRAINTS";
52 assume = builder.create<firrtl::UnclockedAssumeIntrinsicOp>(
53 assertOp.getLoc(), assertOp.getPredicate(), assertOp.getEnable(),
54 emptyMessage, ValueRange{}, assertOp.getName());
57 assume = builder.create<firrtl::AssumeOp>(
58 assertOp.getLoc(), assertOp.getClock(), assertOp.getPredicate(),
59 assertOp.getEnable(), emptyMessage, ValueRange{},
64 SmallVector<Attribute> newGuards{
65 builder.getStringAttr(
"USE_PROPERTY_AS_CONSTRAINT")};
67 newGuards.append(guards.begin(), guards.end());
68 assume->setAttr(
"guards", builder.getArrayAttr(newGuards));
76 return std::make_unique<CreateCompanionAssumePass>();
Direction get(bool isOutput)
Returns an output direction if isOutput is true, otherwise returns an input direction.
std::unique_ptr< mlir::Pass > createCreateCompanionAssume()
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.