20#include "mlir/Transforms/Passes.h"
21#include "llvm/Support/FileSystem.h"
22#include "llvm/Support/Path.h"
29 pm.nest<firrtl::CircuitOp>().addPass(
30 firrtl::createCheckRecursiveInstantiation());
31 pm.nest<firrtl::CircuitOp>().addPass(firrtl::createCheckLayers());
33 pm.nest<firrtl::CircuitOp>().addPass(firrtl::createLowerOpenAggs());
35 pm.nest<firrtl::CircuitOp>().addPass(firrtl::createResolvePaths());
37 pm.nest<firrtl::CircuitOp>().addPass(firrtl::createLowerFIRRTLAnnotations(
44 pm.nest<firrtl::CircuitOp>().addNestedPass<firrtl::FModuleOp>(
45 firrtl::createMaterializeDebugInfo());
47 pm.nest<firrtl::CircuitOp>().addPass(firrtl::createLowerIntmodules(
49 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
50 firrtl::createLowerIntrinsics());
59 pm.addNestedPass<firrtl::CircuitOp>(firrtl::createSpecializeOption(
62 pm.nest<firrtl::CircuitOp>().addPass(firrtl::createLowerSignatures());
68 pm.nest<firrtl::CircuitOp>().addPass(firrtl::createInjectDUTHierarchy());
72 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
73 mlir::createCSEPass());
75 pm.nest<firrtl::CircuitOp>().nestAny().addPass(mlir::createCSEPass());
78 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
79 firrtl::createPassiveWires());
81 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
84 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
85 firrtl::createLowerCHIRRTLPass());
89 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
90 firrtl::createLowerMatches());
93 pm.nest<firrtl::CircuitOp>().addPass(firrtl::createInferWidths());
95 pm.nest<firrtl::CircuitOp>().addPass(firrtl::createMemToRegOfVec(
99 pm.nest<firrtl::CircuitOp>().addPass(firrtl::createInferResets());
101 pm.nest<firrtl::CircuitOp>().addPass(firrtl::createDropConst());
104 firrtl::DedupOptions opts;
106 pm.nest<firrtl::CircuitOp>().addPass(firrtl::createDedup(opts));
110 pm.addNestedPass<firrtl::CircuitOp>(firrtl::createLowerFIRRTLTypes(
113 pm.addNestedPass<firrtl::CircuitOp>(firrtl::createVBToBV());
117 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
118 firrtl::createFlattenMemory());
123 pm.addNestedPass<firrtl::CircuitOp>(firrtl::createLowerFIRRTLTypes(
128 auto &modulePM = pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>();
129 modulePM.addPass(firrtl::createExpandWhens());
130 modulePM.addPass(firrtl::createSFCCompat());
133 pm.addNestedPass<firrtl::CircuitOp>(firrtl::createCheckCombLoops());
137 pm.addNestedPass<firrtl::CircuitOp>(firrtl::createSpecializeLayers());
141 pm.nest<firrtl::CircuitOp>().addPass(firrtl::createProbesToSignals());
143 pm.nest<firrtl::CircuitOp>().addPass(firrtl::createInliner());
145 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
146 firrtl::createLayerMerge());
153 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
154 firrtl::createRandomizeRegisterInit());
158 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
164 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
165 firrtl::createInferReadWrite());
168 pm.nest<firrtl::CircuitOp>().addPass(firrtl::createLowerMemory());
171 pm.nest<firrtl::CircuitOp>().addPass(firrtl::createIMConstProp());
173 pm.addNestedPass<firrtl::CircuitOp>(firrtl::createAddSeqMemPorts());
175 pm.addPass(firrtl::createCreateSiFiveMetadata(
182 pm.addNestedPass<firrtl::CircuitOp>(firrtl::createExtractInstances());
186 pm.addNestedPass<firrtl::CircuitOp>(mlir::createSymbolDCEPass());
189 pm.addPass(firrtl::createInnerSymbolDCE());
196 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
197 circt::firrtl::createEliminateWires());
198 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
200 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
201 circt::firrtl::createRegisterOptimizer());
204 pm.nest<firrtl::CircuitOp>().addPass(firrtl::createIMConstProp());
205 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
207 pm.addPass(firrtl::createIMDeadCodeElim());
211 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
212 firrtl::createMergeConnections(
217 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
218 firrtl::createVectorization());
225 StringRef inputFilename) {
230 pm.nest<firrtl::CircuitOp>().addPass(firrtl::createLayerSink());
235 pm.nest<firrtl::CircuitOp>().addPass(firrtl::createLowerXMR());
244 pm.nest<firrtl::CircuitOp>().addPass(
247 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
251 if (outputFilename ==
"-")
254 pm.nest<firrtl::CircuitOp>().addPass(firrtl::createAssignOutputDirs(
255 {outputFilename.str()}));
263 pm.addNestedPass<firrtl::CircuitOp>(
268 ? llvm::sys::path::parent_path(inputFilename)
270 pm.nest<firrtl::CircuitOp>().addPass(
271 firrtl::createBlackBoxReader({blackBoxRoot.str()}));
275 pm.nest<firrtl::CircuitOp>().addPass(
278 pm.nest<firrtl::CircuitOp>().addPass(firrtl::createLowerDPI());
279 pm.nest<firrtl::CircuitOp>().addPass(firrtl::createLowerDomains());
280 pm.nest<firrtl::CircuitOp>().addPass(firrtl::createLowerClasses());
281 pm.nest<firrtl::CircuitOp>().addPass(om::createVerifyObjectFieldsPass());
284 pm.nest<firrtl::CircuitOp>().addPass(circt::firrtl::createLint(
293 modulePM.addPass(mlir::createCSEPass());
298 pm.addPass(hw::createVerifyInnerRefNamespace());
301 pm.addPass(om::createVerifyObjectFieldsPass());
304 pm.addNestedPass<
hw::HWModuleOp>(verif::createVerifyClockedAssertLikePass());
311 pm.nestAny().addPass(verif::createStripContractsPass());
312 pm.addPass(verif::createLowerFormalToHWPass());
317 pm.addPass(sv::createSVExtractTestCodePass(
326 FirtoolOptions::RandomKind::Reg),
332 pm.addPass(seq::createHWMemSimImplPass(
334 FirtoolOptions::RandomKind::Mem),
339 ? seq::ReadEnableMode::Ignore
340 : seq::ReadEnableMode::Undefined,
348 modulePM.addPass(mlir::createCSEPass());
350 modulePM.addPass(mlir::createCSEPass());
351 modulePM.addPass(sv::createHWCleanupPass(
356 pm.addPass(hw::createVerifyInnerRefNamespace());
359 pm.addPass(om::createVerifyObjectFieldsPass());
370 pm.addNestedPass<
hw::HWModuleOp>(verif::createVerifyClockedAssertLikePass());
381 if (
auto fileLoc = dyn_cast<FileLineColLoc>(loc))
382 return fileLoc.getFilename().getValue().ends_with(
".fir");
388 [](mlir::Location loc) {
return true; }));
395 pm.addPass(hw::createVerifyInnerRefNamespace());
406 std::unique_ptr<llvm::raw_ostream> os) {
416 llvm::raw_ostream &os) {
426 llvm::StringRef directory) {
436 pm.addPass(firrtl::createFinalizeIR());
437 pm.addPass(om::createFreezePathsPass());
444 llvm::raw_ostream &os) {
446 pm.addNestedPass<
hw::HWModuleOp>(circt::verif::createPrepareForFormalPass());
447 pm.addPass(circt::hw::createFlattenModules());
460struct FirtoolCmdOptions {
463 llvm::cl::desc(
"Output filename, or directory for split output"),
464 llvm::cl::value_desc(
"filename"),
469 "disable-annotation-unknown",
470 llvm::cl::desc(
"Ignore unknown annotations when parsing"),
471 llvm::cl::init(
false)};
474 "disable-annotation-classless",
475 llvm::cl::desc(
"Ignore annotations without a class when parsing"),
476 llvm::cl::init(
false)};
479 "lower-annotations-no-ref-type-ports",
481 "Create real ports instead of ref type ports when resolving "
482 "wiring problems inside the LowerAnnotations pass"),
483 llvm::cl::init(
false), llvm::cl::Hidden};
486 "allow-adding-ports-on-public-modules",
487 llvm::cl::desc(
"Allow adding ports to public modules"),
488 llvm::cl::init(
false), llvm::cl::Hidden};
492 llvm::cl::desc(
"Convert probes to non-probe signals"),
493 llvm::cl::init(
false), llvm::cl::Hidden};
497 "preserve-aggregate",
498 llvm::cl::desc(
"Specify input file format:"),
501 "Preserve no aggregate"),
503 "Preserve only 1d vectors of ground type"),
505 "Preserve only vectors"),
507 "Preserve vectors and bundles")),
513 llvm::cl::desc(
"Specify the values which can be optimized away"),
516 "Strip all names. No name is preserved"),
518 "Names could be preserved by best-effort unlike `strip`"),
520 "Preserve values with meaningful names"),
522 "Preserve all values")),
526 "g", llvm::cl::desc(
"Enable the generation of debug information"),
527 llvm::cl::init(
false)};
531 "O", llvm::cl::desc(
"Controls how much optimization should be performed"),
534 "Compile with only necessary optimizations"),
536 "release",
"Compile with optimizations")),
540 llvm::cl::desc(
"Disable layer sink"),
545 llvm::cl::desc(
"Disable optimizations"),
550 llvm::cl::desc(
"Transform vectors of bundles to bundles of vectors"),
551 llvm::cl::init(
false)};
555 llvm::cl::desc(
"Disable deduplication of structurally identical modules"),
556 llvm::cl::init(
false)};
561 "Deduplicate FIRRTL classes, violating their nominal typing"),
562 llvm::cl::init(
true)};
565 "grand-central-companion-mode",
566 llvm::cl::desc(
"Specifies the handling of Grand Central companions"),
568 clEnumValN(firrtl::CompanionMode::Bind,
"bind",
569 "Lower companion instances to SystemVerilog binds"),
570 clEnumValN(firrtl::CompanionMode::Instantiate,
"instantiate",
571 "Instantiate companions in the design"),
572 clEnumValN(firrtl::CompanionMode::Drop,
"drop",
573 "Remove companions from the design")),
574 llvm::cl::init(firrtl::CompanionMode::Bind),
579 "disable-aggressive-merge-connections",
581 "Disable aggressive merge connections (i.e. merge all field-level "
582 "connections into bulk connections)"),
583 llvm::cl::init(
false)};
587 llvm::cl::desc(
"Lower memories to have memories with masks as an "
588 "array with one memory per ground type"),
589 llvm::cl::init(
false)};
594 "Optional path to use as the root of black box annotations"),
595 llvm::cl::value_desc(
"path"),
601 llvm::cl::desc(
"Replace the seq mem for macro replacement and emit "
602 "relevant metadata"),
603 llvm::cl::init(
false)};
606 "repl-seq-mem-file", llvm::cl::desc(
"File name for seq mem metadata"),
610 "extract-test-code", llvm::cl::desc(
"Run the extract test code pass"),
611 llvm::cl::init(
false)};
614 "ignore-read-enable-mem",
615 llvm::cl::desc(
"Ignore the read enable signal, instead of "
616 "assigning X on read disable"),
617 llvm::cl::init(
false)};
621 "Disable random initialization code (may break semantics!)"),
623 clEnumValN(firtool::FirtoolOptions::RandomKind::Mem,
624 "disable-mem-randomization",
625 "Disable emission of memory randomization code"),
626 clEnumValN(firtool::FirtoolOptions::RandomKind::Reg,
627 "disable-reg-randomization",
628 "Disable emission of register randomization code"),
629 clEnumValN(firtool::FirtoolOptions::RandomKind::All,
630 "disable-all-randomization",
631 "Disable emission of all randomization code")),
632 llvm::cl::init(firtool::FirtoolOptions::RandomKind::None)};
635 "output-annotation-file",
636 llvm::cl::desc(
"Optional output annotation file"),
637 llvm::cl::CommaSeparated, llvm::cl::value_desc(
"filename")};
640 "warn-on-unprocessed-annotations",
642 "Warn about annotations that were not removed by lower-to-hw"),
643 llvm::cl::init(
false)};
647 llvm::cl::desc(
"Annotate mux pragmas for memory array access"),
648 llvm::cl::init(
false)};
651 "verification-flavor",
652 llvm::cl::desc(
"Specify a verification flavor used in LowerFIRRTLToHW"),
654 clEnumValN(firrtl::VerificationFlavor::None,
"none",
655 "Use the flavor specified by the op"),
656 clEnumValN(firrtl::VerificationFlavor::IfElseFatal,
"if-else-fatal",
657 "Use Use `if(cond) else $fatal(..)` format"),
658 clEnumValN(firrtl::VerificationFlavor::Immediate,
"immediate",
659 "Use immediate verif statements"),
660 clEnumValN(firrtl::VerificationFlavor::SVA,
"sva",
"Use SVA")),
661 llvm::cl::init(firrtl::VerificationFlavor::None)};
664 "emit-separate-always-blocks",
666 "Prevent always blocks from being merged and emit constructs into "
667 "separate always blocks whenever possible"),
668 llvm::cl::init(
false)};
671 "etc-disable-instance-extraction",
672 llvm::cl::desc(
"Disable extracting instances only that feed test code"),
673 llvm::cl::init(
false)};
676 "etc-disable-register-extraction",
677 llvm::cl::desc(
"Disable extracting registers that only feed test code"),
678 llvm::cl::init(
false)};
681 "etc-disable-module-inlining",
682 llvm::cl::desc(
"Disable inlining modules that only feed test code"),
683 llvm::cl::init(
false)};
686 "add-vivado-ram-address-conflict-synthesis-bug-workaround",
688 "Add a vivado specific SV attribute (* ram_style = "
689 "\"distributed\" *) to unpacked array registers as a workaronud "
690 "for a vivado synthesis bug that incorrectly modifies "
691 "address conflict behavivor of combinational memories"),
692 llvm::cl::init(
false)};
699 "ckg-name", llvm::cl::desc(
"Clock gate module name"),
700 llvm::cl::init(
"EICG_wrapper")};
703 "ckg-input", llvm::cl::desc(
"Clock gate input port name"),
704 llvm::cl::init(
"in")};
707 "ckg-output", llvm::cl::desc(
"Clock gate output port name"),
708 llvm::cl::init(
"out")};
711 "ckg-enable", llvm::cl::desc(
"Clock gate enable port name"),
712 llvm::cl::init(
"en")};
716 llvm::cl::desc(
"Clock gate test enable port name (optional)"),
717 llvm::cl::init(
"test_en")};
720 "export-module-hierarchy",
721 llvm::cl::desc(
"Export module and instance hierarchy as JSON"),
722 llvm::cl::init(
false)};
725 "strip-fir-debug-info",
727 "Disable source fir locator information in output Verilog"),
728 llvm::cl::init(
true)};
732 llvm::cl::desc(
"Disable source locator information in output Verilog"),
733 llvm::cl::init(
false)};
736 "fixup-eicg-wrapper",
737 llvm::cl::desc(
"Lower `EICG_wrapper` modules into clock gate intrinsics"),
738 llvm::cl::init(
false)};
741 "select-default-for-unspecified-instance-choice",
743 "Specialize instance choice to default, if no option selected"),
744 llvm::cl::init(
false)};
748 llvm::cl::desc(
"Control how symbolic values are lowered"),
749 llvm::cl::init(verif::SymbolicValueLowering::ExtModule),
750 verif::symbolicValueLoweringCLValues()};
753 "disable-wire-elimination", llvm::cl::desc(
"Disable wire elimination"),
754 llvm::cl::init(
false)};
757 "emit-all-bind-files",
758 llvm::cl::desc(
"Emit bindfiles for private modules"),
759 llvm::cl::init(
false)};
766 "lint-static-asserts", llvm::cl::desc(
"Lint static assertions"),
767 llvm::cl::init(
true)};
771 "lint-xmrs-in-design", llvm::cl::desc(
"Lint XMRs in the design"),
772 llvm::cl::init(
false)};
788 : outputFilename(
"-"), disableAnnotationsUnknown(false),
789 disableAnnotationsClassless(false), lowerAnnotationsNoRefTypePorts(false),
790 allowAddingPortsOnPublic(false), probesToSignals(false),
791 preserveAggregate(firrtl::PreserveAggregate::None),
792 preserveMode(firrtl::PreserveValues::None), enableDebugInfo(false),
793 buildMode(BuildModeRelease), disableLayerSink(false),
794 disableOptimization(false), vbToBV(false), noDedup(false),
795 dedupClasses(true), companionMode(firrtl::CompanionMode::Bind),
796 disableAggressiveMergeConnections(false), lowerMemories(false),
797 blackBoxRootPath(
""), replSeqMem(false), replSeqMemFile(
""),
798 extractTestCode(false), ignoreReadEnableMem(false),
799 disableRandom(
RandomKind::None), outputAnnotationFilename(
""),
800 enableAnnotationWarning(false), addMuxPragmas(false),
801 verificationFlavor(firrtl::VerificationFlavor::None),
802 emitSeparateAlwaysBlocks(false), etcDisableInstanceExtraction(false),
803 etcDisableRegisterExtraction(false), etcDisableModuleInlining(false),
804 addVivadoRAMAddressConflictSynthesisBugWorkaround(false),
805 ckgModuleName(
"EICG_wrapper"), ckgInputName(
"in"), ckgOutputName(
"out"),
806 ckgEnableName(
"en"), ckgTestEnableName(
"test_en"), ckgInstName(
"ckg"),
807 exportModuleHierarchy(false), stripFirDebugInfo(true),
808 stripDebugInfo(false), fixupEICGWrapper(false),
809 disableCSEinClasses(false), selectDefaultInstanceChoice(false),
810 symbolicValueLowering(
verif::SymbolicValueLowering::ExtModule),
811 disableWireElimination(false), lintStaticAsserts(true),
812 lintXmrsInDesign(true), emitAllBindFiles(false) {
832 clOptions->disableAggressiveMergeConnections;
849 clOptions->addVivadoRAMAddressConflictSynthesisBugWorkaround;
@ All
Preserve all aggregate values.
@ OneDimVec
Preserve only 1d vectors of ground type (e.g. UInt<2>[3]).
@ Vec
Preserve only vectors (e.g. UInt<2>[3][3]).
@ None
Don't preserve aggregate at all.
@ None
Don't explicitly preserve any named values.
@ Strip
Strip all names. No name on declaration is preserved.
std::unique_ptr< mlir::Pass > createVerifyObjectFieldsPass()
std::unique_ptr< mlir::Pass > createHWExportModuleHierarchyPass()
std::unique_ptr< mlir::Pass > createHWLegalizeModulesPass()
std::unique_ptr< mlir::Pass > createPrettifyVerilogPass()
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
std::unique_ptr< mlir::Pass > createExportSplitVerilogPass(llvm::StringRef directory="./")
std::unique_ptr< OperationPass< hw::HWModuleOp > > createLowerVerifToSVPass()
Create the Verif to SV conversion pass.
std::unique_ptr< mlir::Pass > createLowerSeqToSVPass(const LowerSeqToSVOptions &options={})
std::unique_ptr< mlir::Pass > createLowerLTLToCorePass()
std::unique_ptr< mlir::Pass > createLowerFIRRTLToHWPass(bool enableAnnotationWarning=false, firrtl::VerificationFlavor assertionFlavor=firrtl::VerificationFlavor::None)
This is the pass constructor.
std::unique_ptr< mlir::Pass > createLowerSimToSVPass()
std::unique_ptr< Pass > createSimpleCanonicalizerPass()
Create a simple canonicalizer pass.
std::unique_ptr< mlir::Pass > createConvertHWToBTOR2Pass()
std::unique_ptr< mlir::Pass > createExportVerilogPass()
std::unique_ptr< mlir::Pass > createStripDebugInfoWithPredPass(const std::function< bool(mlir::Location)> &pred)
Creates a pass to strip debug information from a function.
LogicalResult populatePrepareForExportVerilog(mlir::PassManager &pm, const firtool::FirtoolOptions &opt)