16 #include "mlir/Pass/Pass.h"
20 #define GEN_PASS_DEF_CREATECOMPANIONASSUME
21 #include "circt/Dialect/FIRRTL/Passes.h.inc"
25 using namespace circt;
26 using namespace firrtl;
29 struct CreateCompanionAssumePass
30 :
public circt::firrtl::impl::CreateCompanionAssumeBase<
31 CreateCompanionAssumePass> {
32 void runOnOperation()
override {
34 getOperation().walk([&](firrtl::AssertOp assertOp) {
35 OpBuilder builder(assertOp);
36 builder.setInsertionPointAfter(assertOp);
37 auto guards = assertOp->getAttrOfType<ArrayAttr>(
"guards");
39 bool isUnrOnlyAssert =
false;
43 isUnrOnlyAssert = llvm::any_of(guards, [](Attribute attr) {
44 StringAttr strAttr = dyn_cast<StringAttr>(attr);
45 return strAttr && strAttr.getValue() ==
"USE_UNR_ONLY_CONSTRAINTS";
53 assume = builder.create<firrtl::UnclockedAssumeIntrinsicOp>(
54 assertOp.getLoc(), assertOp.getPredicate(), assertOp.getEnable(),
55 emptyMessage, ValueRange{}, assertOp.getName());
58 assume = builder.create<firrtl::AssumeOp>(
59 assertOp.getLoc(), assertOp.getClock(), assertOp.getPredicate(),
60 assertOp.getEnable(), emptyMessage, ValueRange{},
65 SmallVector<Attribute> newGuards{
66 builder.getStringAttr(
"USE_PROPERTY_AS_CONSTRAINT")};
68 newGuards.append(guards.begin(), guards.end());
69 assume->setAttr(
"guards", builder.getArrayAttr(newGuards));
77 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.