@@ -577,6 +577,7 @@ struct FIRRTLModuleLowering
577577 CircuitLoweringState &loweringState);
578578 LogicalResult lowerSimulationBody (verif::SimulationOp simulationOp,
579579 CircuitLoweringState &loweringState);
580+ LogicalResult lowerFileBody (emit::FileOp op);
580581 LogicalResult lowerBody (Operation *op, CircuitLoweringState &loweringState);
581582};
582583
@@ -692,6 +693,11 @@ void FIRRTLModuleLowering::runOnOperation() {
692693 opsToProcess.push_back (newOp);
693694 return success ();
694695 })
696+ .Case <emit::FileOp>([&](auto fileOp) {
697+ fileOp->moveBefore (topLevelModule, topLevelModule->end ());
698+ opsToProcess.push_back (fileOp);
699+ return success ();
700+ })
695701 .Default ([&](Operation *op) {
696702 // We don't know what this op is. If it has no illegal FIRRTL
697703 // types, we can forward the operation. Otherwise, we emit an
@@ -1851,6 +1857,7 @@ struct FIRRTLLowering : public FIRRTLVisitor<FIRRTLLowering, LogicalResult> {
18511857 LogicalResult visitStmt (RefForceInitialOp op);
18521858 LogicalResult visitStmt (RefReleaseOp op);
18531859 LogicalResult visitStmt (RefReleaseInitialOp op);
1860+ LogicalResult visitStmt (BindOp op);
18541861
18551862 FailureOr<Value> lowerSubindex (SubindexOp op, Value input);
18561863 FailureOr<Value> lowerSubaccess (SubaccessOp op, Value input);
@@ -1966,6 +1973,18 @@ FIRRTLModuleLowering::lowerModuleBody(hw::HWModuleOp module,
19661973 return FIRRTLLowering (module , loweringState).run ();
19671974}
19681975
1976+ LogicalResult FIRRTLModuleLowering::lowerFileBody (emit::FileOp fileOp) {
1977+ OpBuilder b (&getContext ());
1978+ fileOp->walk ([&](Operation *op) {
1979+ if (auto bindOp = dyn_cast<BindOp>(op)) {
1980+ b.setInsertionPointAfter (bindOp);
1981+ b.create <sv::BindOp>(bindOp.getLoc (), bindOp.getInstanceAttr ());
1982+ bindOp->erase ();
1983+ }
1984+ });
1985+ return success ();
1986+ }
1987+
19691988LogicalResult
19701989FIRRTLModuleLowering::lowerBody (Operation *op,
19711990 CircuitLoweringState &loweringState) {
@@ -1975,6 +1994,8 @@ FIRRTLModuleLowering::lowerBody(Operation *op,
19751994 return lowerFormalBody (formalOp, loweringState);
19761995 if (auto simulationOp = dyn_cast<verif::SimulationOp>(op))
19771996 return lowerSimulationBody (simulationOp, loweringState);
1997+ if (auto fileOp = dyn_cast<emit::FileOp>(op))
1998+ return lowerFileBody (fileOp);
19781999 return failure ();
19792000}
19802001
@@ -5165,6 +5186,11 @@ LogicalResult FIRRTLLowering::visitStmt(AttachOp op) {
51655186 return success ();
51665187}
51675188
5189+ LogicalResult FIRRTLLowering::visitStmt (BindOp op) {
5190+ builder.create <sv::BindOp>(op.getInstanceAttr ());
5191+ return success ();
5192+ }
5193+
51685194LogicalResult FIRRTLLowering::fixupLTLOps () {
51695195 if (ltlOpFixupWorklist.empty ())
51705196 return success ();
0 commit comments