20#include "mlir/Transforms/Passes.h"
21#include "llvm/Support/FileSystem.h"
22#include "llvm/Support/Path.h"
29 pm.nest<firrtl::CircuitOp>().addPass(
44 pm.nest<firrtl::CircuitOp>().addNestedPass<firrtl::FModuleOp>(
47 pm.nest<firrtl::CircuitOp>().addPass(
49 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
67 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
68 mlir::createCSEPass());
70 pm.nest<firrtl::CircuitOp>().nestAny().addPass(mlir::createCSEPass());
73 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
76 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
79 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
84 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
90 pm.nest<firrtl::CircuitOp>().addPass(
103 pm.nest<firrtl::CircuitOp>().addPass(
120 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
130 auto &modulePM = pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>();
147 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
155 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
160 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
166 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
173 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
189 pm.addNestedPass<firrtl::CircuitOp>(mlir::createSymbolDCEPass());
198 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
200 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
205 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
211 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
216 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
224 StringRef inputFilename) {
238 pm.nest<firrtl::CircuitOp>().addPass(
241 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
246 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
250 if (outputFilename ==
"-")
253 pm.nest<firrtl::CircuitOp>().addPass(
262 pm.addNestedPass<firrtl::CircuitOp>(
267 ? llvm::sys::path::parent_path(inputFilename)
269 pm.nest<firrtl::CircuitOp>().addPass(
274 pm.nest<firrtl::CircuitOp>().addPass(
279 pm.nest<firrtl::CircuitOp>().addPass(om::createVerifyObjectFieldsPass());
282 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
290 modulePM.addPass(mlir::createCSEPass());
295 pm.addPass(hw::createVerifyInnerRefNamespacePass());
298 pm.addPass(om::createVerifyObjectFieldsPass());
301 pm.addNestedPass<
hw::HWModuleOp>(verif::createVerifyClockedAssertLikePass());
308 pm.nestAny().addPass(verif::createStripContractsPass());
309 pm.addPass(verif::createLowerFormalToHWPass());
314 pm.addPass(sv::createSVExtractTestCodePass(
323 FirtoolOptions::RandomKind::Reg),
329 pm.addPass(seq::createHWMemSimImplPass(
331 FirtoolOptions::RandomKind::Mem),
336 ? seq::ReadEnableMode::Ignore
337 : seq::ReadEnableMode::Undefined,
345 modulePM.addPass(mlir::createCSEPass());
347 modulePM.addPass(mlir::createCSEPass());
348 modulePM.addPass(sv::createHWCleanupPass(
353 pm.addPass(hw::createVerifyInnerRefNamespacePass());
356 pm.addPass(om::createVerifyObjectFieldsPass());
367 pm.addNestedPass<
hw::HWModuleOp>(verif::createVerifyClockedAssertLikePass());
378 if (
auto fileLoc = dyn_cast<FileLineColLoc>(loc))
379 return fileLoc.getFilename().getValue().ends_with(
".fir");
385 [](mlir::Location loc) {
return true; }));
403 std::unique_ptr<llvm::raw_ostream> os) {
413 llvm::raw_ostream &os) {
423 llvm::StringRef directory) {
434 pm.addPass(om::createFreezePathsPass());
441 llvm::raw_ostream &os) {
443 pm.addNestedPass<
hw::HWModuleOp>(circt::verif::createPrepareForFormalPass());
457struct FirtoolCmdOptions {
460 llvm::cl::desc(
"Output filename, or directory for split output"),
461 llvm::cl::value_desc(
"filename"),
466 "disable-annotation-unknown",
467 llvm::cl::desc(
"Ignore unknown annotations when parsing"),
468 llvm::cl::init(
false)};
471 "disable-annotation-classless",
472 llvm::cl::desc(
"Ignore annotations without a class when parsing"),
473 llvm::cl::init(
false)};
476 "lower-annotations-no-ref-type-ports",
478 "Create real ports instead of ref type ports when resolving "
479 "wiring problems inside the LowerAnnotations pass"),
480 llvm::cl::init(
false), llvm::cl::Hidden};
483 "allow-adding-ports-on-public-modules",
484 llvm::cl::desc(
"Allow adding ports to public modules"),
485 llvm::cl::init(
false), llvm::cl::Hidden};
489 llvm::cl::desc(
"Convert probes to non-probe signals"),
490 llvm::cl::init(
false), llvm::cl::Hidden};
494 "preserve-aggregate",
495 llvm::cl::desc(
"Specify input file format:"),
498 "Preserve no aggregate"),
500 "Preserve only 1d vectors of ground type"),
502 "Preserve only vectors"),
504 "Preserve vectors and bundles")),
510 llvm::cl::desc(
"Specify the values which can be optimized away"),
513 "Strip all names. No name is preserved"),
515 "Names could be preserved by best-effort unlike `strip`"),
517 "Preserve values with meaningful names"),
519 "Preserve all values")),
523 "g", llvm::cl::desc(
"Enable the generation of debug information"),
524 llvm::cl::init(
false)};
528 "O", llvm::cl::desc(
"Controls how much optimization should be performed"),
531 "Compile with only necessary optimizations"),
533 "release",
"Compile with optimizations")),
537 llvm::cl::desc(
"Disable layer sink"),
542 llvm::cl::desc(
"Disable optimizations"),
546 "export-chisel-interface",
547 llvm::cl::desc(
"Generate a Scala Chisel interface to the top level "
548 "module of the firrtl circuit"),
549 llvm::cl::init(
false)};
552 "chisel-interface-out-dir",
554 "The output directory for generated Chisel interface files"),
559 llvm::cl::desc(
"Transform vectors of bundles to bundles of vectors"),
560 llvm::cl::init(
false)};
564 llvm::cl::desc(
"Disable deduplication of structurally identical modules"),
565 llvm::cl::init(
false)};
568 "grand-central-companion-mode",
569 llvm::cl::desc(
"Specifies the handling of Grand Central companions"),
571 clEnumValN(firrtl::CompanionMode::Bind,
"bind",
572 "Lower companion instances to SystemVerilog binds"),
573 clEnumValN(firrtl::CompanionMode::Instantiate,
"instantiate",
574 "Instantiate companions in the design"),
575 clEnumValN(firrtl::CompanionMode::Drop,
"drop",
576 "Remove companions from the design")),
577 llvm::cl::init(firrtl::CompanionMode::Bind),
582 "disable-aggressive-merge-connections",
584 "Disable aggressive merge connections (i.e. merge all field-level "
585 "connections into bulk connections)"),
586 llvm::cl::init(
false)};
589 "advanced-layer-sink",
590 llvm::cl::desc(
"Sink logic into layer blocks (advanced)"),
591 llvm::cl::init(
false)};
595 llvm::cl::desc(
"Lower memories to have memories with masks as an "
596 "array with one memory per ground type"),
597 llvm::cl::init(
false)};
602 "Optional path to use as the root of black box annotations"),
603 llvm::cl::value_desc(
"path"),
609 llvm::cl::desc(
"Replace the seq mem for macro replacement and emit "
610 "relevant metadata"),
611 llvm::cl::init(
false)};
614 "repl-seq-mem-file", llvm::cl::desc(
"File name for seq mem metadata"),
618 "extract-test-code", llvm::cl::desc(
"Run the extract test code pass"),
619 llvm::cl::init(
false)};
622 "ignore-read-enable-mem",
623 llvm::cl::desc(
"Ignore the read enable signal, instead of "
624 "assigning X on read disable"),
625 llvm::cl::init(
false)};
629 "Disable random initialization code (may break semantics!)"),
631 clEnumValN(firtool::FirtoolOptions::RandomKind::Mem,
632 "disable-mem-randomization",
633 "Disable emission of memory randomization code"),
634 clEnumValN(firtool::FirtoolOptions::RandomKind::Reg,
635 "disable-reg-randomization",
636 "Disable emission of register randomization code"),
637 clEnumValN(firtool::FirtoolOptions::RandomKind::All,
638 "disable-all-randomization",
639 "Disable emission of all randomization code")),
640 llvm::cl::init(firtool::FirtoolOptions::RandomKind::None)};
643 "output-annotation-file",
644 llvm::cl::desc(
"Optional output annotation file"),
645 llvm::cl::CommaSeparated, llvm::cl::value_desc(
"filename")};
648 "warn-on-unprocessed-annotations",
650 "Warn about annotations that were not removed by lower-to-hw"),
651 llvm::cl::init(
false)};
655 llvm::cl::desc(
"Annotate mux pragmas for memory array access"),
656 llvm::cl::init(
false)};
659 "verification-flavor",
660 llvm::cl::desc(
"Specify a verification flavor used in LowerFIRRTLToHW"),
662 clEnumValN(firrtl::VerificationFlavor::None,
"none",
663 "Use the flavor specified by the op"),
664 clEnumValN(firrtl::VerificationFlavor::IfElseFatal,
"if-else-fatal",
665 "Use Use `if(cond) else $fatal(..)` format"),
666 clEnumValN(firrtl::VerificationFlavor::Immediate,
"immediate",
667 "Use immediate verif statements"),
668 clEnumValN(firrtl::VerificationFlavor::SVA,
"sva",
"Use SVA")),
669 llvm::cl::init(firrtl::VerificationFlavor::None)};
672 "emit-separate-always-blocks",
674 "Prevent always blocks from being merged and emit constructs into "
675 "separate always blocks whenever possible"),
676 llvm::cl::init(
false)};
679 "etc-disable-instance-extraction",
680 llvm::cl::desc(
"Disable extracting instances only that feed test code"),
681 llvm::cl::init(
false)};
684 "etc-disable-register-extraction",
685 llvm::cl::desc(
"Disable extracting registers that only feed test code"),
686 llvm::cl::init(
false)};
689 "etc-disable-module-inlining",
690 llvm::cl::desc(
"Disable inlining modules that only feed test code"),
691 llvm::cl::init(
false)};
694 "add-vivado-ram-address-conflict-synthesis-bug-workaround",
696 "Add a vivado specific SV attribute (* ram_style = "
697 "\"distributed\" *) to unpacked array registers as a workaronud "
698 "for a vivado synthesis bug that incorrectly modifies "
699 "address conflict behavivor of combinational memories"),
700 llvm::cl::init(
false)};
707 "ckg-name", llvm::cl::desc(
"Clock gate module name"),
708 llvm::cl::init(
"EICG_wrapper")};
711 "ckg-input", llvm::cl::desc(
"Clock gate input port name"),
712 llvm::cl::init(
"in")};
715 "ckg-output", llvm::cl::desc(
"Clock gate output port name"),
716 llvm::cl::init(
"out")};
719 "ckg-enable", llvm::cl::desc(
"Clock gate enable port name"),
720 llvm::cl::init(
"en")};
724 llvm::cl::desc(
"Clock gate test enable port name (optional)"),
725 llvm::cl::init(
"test_en")};
728 "export-module-hierarchy",
729 llvm::cl::desc(
"Export module and instance hierarchy as JSON"),
730 llvm::cl::init(
false)};
733 "strip-fir-debug-info",
735 "Disable source fir locator information in output Verilog"),
736 llvm::cl::init(
true)};
740 llvm::cl::desc(
"Disable source locator information in output Verilog"),
741 llvm::cl::init(
false)};
744 "fixup-eicg-wrapper",
745 llvm::cl::desc(
"Lower `EICG_wrapper` modules into clock gate intrinsics"),
746 llvm::cl::init(
false)};
749 "add-companion-assume",
750 llvm::cl::desc(
"Add companion assumes to assertions"),
751 llvm::cl::init(
false)};
754 "select-default-for-unspecified-instance-choice",
756 "Specialize instance choice to default, if no option selected"),
757 llvm::cl::init(
false)};
761 llvm::cl::desc(
"Control how symbolic values are lowered"),
762 llvm::cl::init(verif::SymbolicValueLowering::ExtModule),
763 verif::symbolicValueLoweringCLValues()};
779 : outputFilename(
"-"), disableAnnotationsUnknown(false),
780 disableAnnotationsClassless(false), lowerAnnotationsNoRefTypePorts(false),
781 allowAddingPortsOnPublic(false), probesToSignals(false),
782 preserveAggregate(firrtl::PreserveAggregate::None),
783 preserveMode(firrtl::PreserveValues::None), enableDebugInfo(false),
784 buildMode(BuildModeRelease), disableLayerSink(false),
786 chiselInterfaceOutDirectory(
""), vbToBV(false), noDedup(false),
787 companionMode(firrtl::CompanionMode::Bind),
788 disableAggressiveMergeConnections(false), advancedLayerSink(false),
789 lowerMemories(false), blackBoxRootPath(
""), replSeqMem(false),
790 replSeqMemFile(
""), extractTestCode(false), ignoreReadEnableMem(false),
791 disableRandom(
RandomKind::None), outputAnnotationFilename(
""),
792 enableAnnotationWarning(false), addMuxPragmas(false),
793 verificationFlavor(firrtl::VerificationFlavor::None),
794 emitSeparateAlwaysBlocks(false), etcDisableInstanceExtraction(false),
795 etcDisableRegisterExtraction(false), etcDisableModuleInlining(false),
796 addVivadoRAMAddressConflictSynthesisBugWorkaround(false),
797 ckgModuleName(
"EICG_wrapper"), ckgInputName(
"in"), ckgOutputName(
"out"),
798 ckgEnableName(
"en"), ckgTestEnableName(
"test_en"), ckgInstName(
"ckg"),
799 exportModuleHierarchy(false), stripFirDebugInfo(true),
800 stripDebugInfo(false), fixupEICGWrapper(false), addCompanionAssume(false),
801 disableCSEinClasses(false), selectDefaultInstanceChoice(false),
802 symbolicValueLowering(
verif::SymbolicValueLowering::ExtModule) {
823 clOptions->disableAggressiveMergeConnections;
841 clOptions->addVivadoRAMAddressConflictSynthesisBugWorkaround;
static LogicalResult exportChiselInterface(CircuitOp circuit, llvm::raw_ostream &os)
Exports a Chisel interface to the output stream.
@ 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 > createInferReadWritePass()
std::unique_ptr< mlir::Pass > createCheckCombLoopsPass()
std::unique_ptr< mlir::Pass > createCheckLayers()
std::unique_ptr< mlir::Pass > createCheckRecursiveInstantiation()
std::unique_ptr< mlir::Pass > createFinalizeIRPass()
std::unique_ptr< mlir::Pass > createLowerFIRRTLTypesPass(PreserveAggregate::PreserveMode mode=PreserveAggregate::None, PreserveAggregate::PreserveMode memoryMode=PreserveAggregate::None)
This is the pass constructor.
std::unique_ptr< mlir::Pass > createResolvePathsPass()
std::unique_ptr< mlir::Pass > createLowerFIRRTLAnnotationsPass(bool ignoreUnhandledAnnotations=false, bool ignoreClasslessAnnotations=false, bool noRefTypePorts=false, bool allowAddingPortsOnPublic=false)
This is the pass constructor.
std::unique_ptr< mlir::Pass > createLowerSignaturesPass()
This is the pass constructor.
std::unique_ptr< mlir::Pass > createVBToBVPass()
std::unique_ptr< mlir::Pass > createGrandCentralPass(CompanionMode companionMode=CompanionMode::Bind)
std::unique_ptr< mlir::Pass > createLowerDPIPass()
std::unique_ptr< mlir::Pass > createLowerIntmodulesPass(bool fixupEICGWrapper=false)
This is the pass constructor.
std::unique_ptr< mlir::Pass > createIMConstPropPass()
std::unique_ptr< mlir::Pass > createCreateCompanionAssume()
std::unique_ptr< mlir::Pass > createAdvancedLayerSinkPass()
std::unique_ptr< mlir::Pass > createLayerMergePass()
std::unique_ptr< mlir::Pass > createInlinerPass()
std::unique_ptr< mlir::Pass > createVectorizationPass()
std::unique_ptr< mlir::Pass > createLowerMemoryPass()
std::unique_ptr< mlir::Pass > createDropNamesPass(PreserveValues::PreserveMode mode=PreserveValues::None)
std::unique_ptr< mlir::Pass > createLowerLayersPass()
std::unique_ptr< mlir::Pass > createIMDeadCodeElimPass()
std::unique_ptr< mlir::Pass > createLintingPass()
std::unique_ptr< mlir::Pass > createPassiveWiresPass()
This is the pass constructor.
std::unique_ptr< mlir::Pass > createExtractInstancesPass()
std::unique_ptr< mlir::Pass > createDedupPass()
std::unique_ptr< mlir::Pass > createSpecializeOptionPass(bool selectDefaultInstanceChoice=false)
std::unique_ptr< mlir::Pass > createLayerSinkPass()
std::unique_ptr< mlir::Pass > createSpecializeLayersPass()
std::unique_ptr< mlir::Pass > createLowerCHIRRTLPass()
std::unique_ptr< mlir::Pass > createInnerSymbolDCEPass()
std::unique_ptr< mlir::Pass > createExpandWhensPass()
std::unique_ptr< mlir::Pass > createLowerXMRPass()
std::unique_ptr< mlir::Pass > createLowerIntrinsicsPass()
This is the pass constructor.
std::unique_ptr< mlir::Pass > createInferWidthsPass()
std::unique_ptr< mlir::Pass > createResolveTracesPass(mlir::StringRef outputAnnotationFilename="")
std::unique_ptr< mlir::Pass > createMemToRegOfVecPass(bool replSeqMem=false, bool ignoreReadEnable=false)
std::unique_ptr< mlir::Pass > createCreateSiFiveMetadataPass(bool replSeqMem=false, mlir::StringRef replSeqMemFile="")
std::unique_ptr< mlir::Pass > createAssignOutputDirsPass(mlir::StringRef outputDir="")
std::unique_ptr< mlir::Pass > createBlackBoxReaderPass(std::optional< mlir::StringRef > inputPrefix={})
std::unique_ptr< mlir::Pass > createLowerOpenAggsPass()
This is the pass constructor.
std::unique_ptr< mlir::Pass > createDropConstPass()
std::unique_ptr< mlir::Pass > createSFCCompatPass()
std::unique_ptr< mlir::Pass > createInjectDUTHierarchyPass()
std::unique_ptr< mlir::Pass > createRandomizeRegisterInitPass()
std::unique_ptr< mlir::Pass > createLowerClassesPass()
std::unique_ptr< mlir::Pass > createAddSeqMemPortsPass()
std::unique_ptr< mlir::Pass > createRegisterOptimizerPass()
std::unique_ptr< mlir::Pass > createLowerMatchesPass()
std::unique_ptr< mlir::Pass > createProbesToSignalsPass()
This is the pass constructor.
std::unique_ptr< mlir::Pass > createMergeConnectionsPass(bool enableAggressiveMerging=false)
std::unique_ptr< mlir::Pass > createInferResetsPass()
std::unique_ptr< mlir::Pass > createFlattenMemoryPass()
std::unique_ptr< mlir::Pass > createMaterializeDebugInfoPass()
std::unique_ptr< mlir::Pass > createFlattenModulesPass()
std::unique_ptr< mlir::Pass > createVerifyInnerRefNamespacePass()
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< mlir::Pass > createExportSplitChiselInterfacePass(mlir::StringRef outputDirectory="./")
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 > createExportChiselInterfacePass()
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)