17 #include "mlir/IR/BuiltinTypes.h"
18 #include "mlir/IR/OperationSupport.h"
19 #include "mlir/Transforms/DialectConversion.h"
20 #include "mlir/Transforms/GreedyPatternRewriteDriver.h"
24 #define GEN_PASS_DEF_CLKINSERTION
25 #define GEN_PASS_DEF_RESETINSERTION
26 #include "circt/Dialect/Calyx/CalyxPasses.h.inc"
30 using namespace circt;
31 using namespace calyx;
38 static void doPortPassthrough(ComponentOp comp, Value fromPort,
40 MLIRContext *ctx = comp.getContext();
41 OpBuilder builder(ctx);
42 builder.setInsertionPointToStart(comp.getWiresOp().getBodyBlock());
44 for (
auto cell : comp.getOps<CellInterface>()) {
45 for (
auto port : cell.getInputPorts()) {
46 if (!cell.portInfo(port).hasAttribute(portID))
48 builder.create<AssignOp>(cell.getLoc(), port, fromPort);
53 struct ClkInsertionPass
54 :
public circt::calyx::impl::ClkInsertionBase<ClkInsertionPass> {
55 void runOnOperation()
override {
56 doPortPassthrough(getOperation(), getOperation().getClkPort(),
"clk");
60 struct ResetInsertionPass
61 :
public circt::calyx::impl::ResetInsertionBase<ResetInsertionPass> {
62 void runOnOperation()
override {
63 doPortPassthrough(getOperation(), getOperation().getResetPort(),
"reset");
70 return std::make_unique<ClkInsertionPass>();
74 return std::make_unique<ResetInsertionPass>();
std::unique_ptr< mlir::Pass > createResetInsertionPass()
std::unique_ptr< mlir::Pass > createClkInsertionPass()
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.