@@ -577,6 +577,7 @@ struct FIRRTLModuleLowering
577
577
CircuitLoweringState &loweringState);
578
578
LogicalResult lowerSimulationBody (verif::SimulationOp simulationOp,
579
579
CircuitLoweringState &loweringState);
580
+ LogicalResult lowerFileBody (emit::FileOp op);
580
581
LogicalResult lowerBody (Operation *op, CircuitLoweringState &loweringState);
581
582
};
582
583
@@ -692,6 +693,11 @@ void FIRRTLModuleLowering::runOnOperation() {
692
693
opsToProcess.push_back (newOp);
693
694
return success ();
694
695
})
696
+ .Case <emit::FileOp>([&](auto fileOp) {
697
+ fileOp->moveBefore (topLevelModule, topLevelModule->end ());
698
+ opsToProcess.push_back (fileOp);
699
+ return success ();
700
+ })
695
701
.Default ([&](Operation *op) {
696
702
// We don't know what this op is. If it has no illegal FIRRTL
697
703
// types, we can forward the operation. Otherwise, we emit an
@@ -1851,6 +1857,7 @@ struct FIRRTLLowering : public FIRRTLVisitor<FIRRTLLowering, LogicalResult> {
1851
1857
LogicalResult visitStmt (RefForceInitialOp op);
1852
1858
LogicalResult visitStmt (RefReleaseOp op);
1853
1859
LogicalResult visitStmt (RefReleaseInitialOp op);
1860
+ LogicalResult visitStmt (BindOp op);
1854
1861
1855
1862
FailureOr<Value> lowerSubindex (SubindexOp op, Value input);
1856
1863
FailureOr<Value> lowerSubaccess (SubaccessOp op, Value input);
@@ -1966,6 +1973,18 @@ FIRRTLModuleLowering::lowerModuleBody(hw::HWModuleOp module,
1966
1973
return FIRRTLLowering (module , loweringState).run ();
1967
1974
}
1968
1975
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
+
1969
1988
LogicalResult
1970
1989
FIRRTLModuleLowering::lowerBody (Operation *op,
1971
1990
CircuitLoweringState &loweringState) {
@@ -1975,6 +1994,8 @@ FIRRTLModuleLowering::lowerBody(Operation *op,
1975
1994
return lowerFormalBody (formalOp, loweringState);
1976
1995
if (auto simulationOp = dyn_cast<verif::SimulationOp>(op))
1977
1996
return lowerSimulationBody (simulationOp, loweringState);
1997
+ if (auto fileOp = dyn_cast<emit::FileOp>(op))
1998
+ return lowerFileBody (fileOp);
1978
1999
return failure ();
1979
2000
}
1980
2001
@@ -5165,6 +5186,11 @@ LogicalResult FIRRTLLowering::visitStmt(AttachOp op) {
5165
5186
return success ();
5166
5187
}
5167
5188
5189
+ LogicalResult FIRRTLLowering::visitStmt (BindOp op) {
5190
+ builder.create <sv::BindOp>(op.getInstanceAttr ());
5191
+ return success ();
5192
+ }
5193
+
5168
5194
LogicalResult FIRRTLLowering::fixupLTLOps () {
5169
5195
if (ltlOpFixupWorklist.empty ())
5170
5196
return success ();
0 commit comments