25#include "mlir/Dialect/Func/IR/FuncOps.h"
26#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
27#include "mlir/Dialect/SCF/IR/SCF.h"
28#include "mlir/Pass/Pass.h"
29#include "mlir/Transforms/DialectConversion.h"
30#include "llvm/Support/MathExtras.h"
33#define GEN_PASS_DEF_LOWERLTLTOCORE
34#include "circt/Conversion/Passes.h.inc"
52 matchAndRewrite(verif::HasBeenResetOp op, OpAdaptor adaptor,
53 ConversionPatternRewriter &rewriter)
const override {
54 auto i1 = rewriter.getI1Type();
56 Value constZero = seq::createConstantInitialValue(
57 rewriter, op->getLoc(), rewriter.getIntegerAttr(i1, 0));
60 Value constOne = rewriter.create<
hw::ConstantOp>(op.getLoc(), i1, 1);
69 rewriter.create<
comb::OrOp>(op.getLoc(), adaptor.getReset(),
reg);
73 Value reset, resetval;
78 rewriter.createOrFold<seq::ToClockOp>(op.getLoc(), adaptor.getClock()),
79 rewriter.getStringAttr(
"hbr"), reset, resetval, constZero,
87 rewriter.create<
comb::XorOp>(op.getLoc(), adaptor.getReset(), constOne);
101struct LowerLTLToCorePass
102 :
public circt::impl::LowerLTLToCoreBase<LowerLTLToCorePass> {
103 LowerLTLToCorePass() =
default;
104 void runOnOperation()
override;
109void LowerLTLToCorePass::runOnOperation() {
113 ConversionTarget target(getContext());
114 target.addLegalDialect<hw::HWDialect>();
115 target.addLegalDialect<comb::CombDialect>();
116 target.addLegalDialect<sv::SVDialect>();
117 target.addLegalDialect<seq::SeqDialect>();
118 target.addLegalDialect<ltl::LTLDialect>();
119 target.addLegalDialect<verif::VerifDialect>();
120 target.addIllegalOp<verif::HasBeenResetOp>();
123 mlir::TypeConverter converter;
126 converter.addConversion([](IntegerType type) {
return type; });
127 converter.addConversion([](ltl::PropertyType type) {
128 return IntegerType::get(type.getContext(), 1);
130 converter.addConversion([](ltl::SequenceType type) {
131 return IntegerType::get(type.getContext(), 1);
135 converter.addTargetMaterialization(
136 [&](mlir::OpBuilder &builder, mlir::Type resultType,
137 mlir::ValueRange inputs, mlir::Location loc) -> mlir::Value {
138 if (inputs.size() != 1)
141 .create<UnrealizedConversionCastOp>(loc, resultType, inputs[0])
145 converter.addSourceMaterialization(
146 [&](mlir::OpBuilder &builder, mlir::Type resultType,
147 mlir::ValueRange inputs, mlir::Location loc) -> mlir::Value {
148 if (inputs.size() != 1)
151 .create<UnrealizedConversionCastOp>(loc, resultType, inputs[0])
156 RewritePatternSet
patterns(&getContext());
161 applyPartialConversion(getOperation(), target, std::move(
patterns))))
162 return signalPassFailure();
167 return std::make_unique<LowerLTLToCorePass>();
Instantiate one of these and use it to build typed backedges.
Backedge is a wrapper class around a Value.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
std::unique_ptr< mlir::Pass > createLowerLTLToCorePass()
reg(value, clock, reset=None, reset_value=None, name=None, sym_name=None)