@@ -576,6 +576,7 @@ struct FIRRTLModuleLowering
576
576
CircuitLoweringState &loweringState);
577
577
LogicalResult lowerSimulationBody (verif::SimulationOp simulationOp,
578
578
CircuitLoweringState &loweringState);
579
+ LogicalResult lowerFileBody (emit::FileOp op);
579
580
LogicalResult lowerBody (Operation *op, CircuitLoweringState &loweringState);
580
581
};
581
582
@@ -691,6 +692,11 @@ void FIRRTLModuleLowering::runOnOperation() {
691
692
opsToProcess.push_back (newOp);
692
693
return success ();
693
694
})
695
+ .Case <emit::FileOp>([&](auto fileOp) {
696
+ fileOp->moveBefore (topLevelModule, topLevelModule->end ());
697
+ opsToProcess.push_back (fileOp);
698
+ return success ();
699
+ })
694
700
.Default ([&](Operation *op) {
695
701
// We don't know what this op is. If it has no illegal FIRRTL
696
702
// types, we can forward the operation. Otherwise, we emit an
@@ -1779,6 +1785,7 @@ struct FIRRTLLowering : public FIRRTLVisitor<FIRRTLLowering, LogicalResult> {
1779
1785
LogicalResult visitStmt (RefForceInitialOp op);
1780
1786
LogicalResult visitStmt (RefReleaseOp op);
1781
1787
LogicalResult visitStmt (RefReleaseInitialOp op);
1788
+ LogicalResult visitStmt (BindOp op);
1782
1789
1783
1790
FailureOr<Value> lowerSubindex (SubindexOp op, Value input);
1784
1791
FailureOr<Value> lowerSubaccess (SubaccessOp op, Value input);
@@ -1891,6 +1898,18 @@ FIRRTLModuleLowering::lowerModuleBody(hw::HWModuleOp module,
1891
1898
return FIRRTLLowering (module , loweringState).run ();
1892
1899
}
1893
1900
1901
+ LogicalResult FIRRTLModuleLowering::lowerFileBody (emit::FileOp fileOp) {
1902
+ OpBuilder b (&getContext ());
1903
+ fileOp->walk ([&](Operation *op) {
1904
+ if (auto bindOp = dyn_cast<BindOp>(op)) {
1905
+ b.setInsertionPointAfter (bindOp);
1906
+ b.create <sv::BindOp>(bindOp.getLoc (), bindOp.getInstanceAttr ());
1907
+ bindOp->erase ();
1908
+ }
1909
+ });
1910
+ return success ();
1911
+ }
1912
+
1894
1913
LogicalResult
1895
1914
FIRRTLModuleLowering::lowerBody (Operation *op,
1896
1915
CircuitLoweringState &loweringState) {
@@ -1900,6 +1919,8 @@ FIRRTLModuleLowering::lowerBody(Operation *op,
1900
1919
return lowerFormalBody (formalOp, loweringState);
1901
1920
if (auto simulationOp = dyn_cast<verif::SimulationOp>(op))
1902
1921
return lowerSimulationBody (simulationOp, loweringState);
1922
+ if (auto fileOp = dyn_cast<emit::FileOp>(op))
1923
+ return lowerFileBody (fileOp);
1903
1924
return failure ();
1904
1925
}
1905
1926
@@ -5050,6 +5071,11 @@ LogicalResult FIRRTLLowering::visitStmt(AttachOp op) {
5050
5071
return success ();
5051
5072
}
5052
5073
5074
+ LogicalResult FIRRTLLowering::visitStmt (BindOp op) {
5075
+ builder.create <sv::BindOp>(op.getInstanceAttr ());
5076
+ return success ();
5077
+ }
5078
+
5053
5079
LogicalResult FIRRTLLowering::fixupLTLOps () {
5054
5080
if (ltlOpFixupWorklist.empty ())
5055
5081
return success ();
0 commit comments