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(
57 StringRef inputFilename) {
68 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
69 mlir::createCSEPass());
71 pm.nest<firrtl::CircuitOp>().nestAny().addPass(mlir::createCSEPass());
74 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
77 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
80 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
85 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
91 pm.nest<firrtl::CircuitOp>().addPass(
104 pm.nest<firrtl::CircuitOp>().addPass(
121 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
131 auto &modulePM = pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>();
148 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
156 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
161 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
167 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
174 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
190 pm.addNestedPass<firrtl::CircuitOp>(mlir::createSymbolDCEPass());
199 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
201 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
206 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
212 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
217 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
228 pm.nest<firrtl::CircuitOp>().addPass(
231 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
236 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
240 if (outputFilename ==
"-")
243 pm.nest<firrtl::CircuitOp>().addPass(
252 pm.addNestedPass<firrtl::CircuitOp>(
257 ? llvm::sys::path::parent_path(inputFilename)
259 pm.nest<firrtl::CircuitOp>().addPass(
268 pm.nest<firrtl::CircuitOp>().addPass(
278 pm.nest<firrtl::CircuitOp>().addPass(om::createVerifyObjectFieldsPass());
281 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
289 modulePM.addPass(mlir::createCSEPass());
294 pm.addPass(hw::createVerifyInnerRefNamespacePass());
297 pm.addPass(om::createVerifyObjectFieldsPass());
300 pm.addNestedPass<
hw::HWModuleOp>(verif::createVerifyClockedAssertLikePass());
307 pm.addPass(verif::createLowerFormalToHWPass());
310 pm.addPass(sv::createSVExtractTestCodePass(
319 FirtoolOptions::RandomKind::Reg),
325 pm.addPass(seq::createHWMemSimImplPass(
327 FirtoolOptions::RandomKind::Mem),
332 ? seq::ReadEnableMode::Ignore
333 : seq::ReadEnableMode::Undefined,
341 modulePM.addPass(mlir::createCSEPass());
343 modulePM.addPass(mlir::createCSEPass());
344 modulePM.addPass(sv::createHWCleanupPass(
349 pm.addPass(hw::createVerifyInnerRefNamespacePass());
352 pm.addPass(om::createVerifyObjectFieldsPass());
363 pm.addNestedPass<
hw::HWModuleOp>(verif::createVerifyClockedAssertLikePass());
374 if (
auto fileLoc = dyn_cast<FileLineColLoc>(loc))
375 return fileLoc.getFilename().getValue().ends_with(
".fir");
381 [](mlir::Location loc) {
return true; }));
399 std::unique_ptr<llvm::raw_ostream> os) {
409 llvm::raw_ostream &os) {
419 llvm::StringRef directory) {
430 pm.addPass(om::createFreezePathsPass());
437 llvm::raw_ostream &os) {
439 pm.addNestedPass<
hw::HWModuleOp>(circt::verif::createPrepareForFormalPass());
453struct FirtoolCmdOptions {
456 llvm::cl::desc(
"Output filename, or directory for split output"),
457 llvm::cl::value_desc(
"filename"),
462 "disable-annotation-unknown",
463 llvm::cl::desc(
"Ignore unknown annotations when parsing"),
464 llvm::cl::init(
false)};
467 "disable-annotation-classless",
468 llvm::cl::desc(
"Ignore annotations without a class when parsing"),
469 llvm::cl::init(
false)};
472 "lower-annotations-no-ref-type-ports",
474 "Create real ports instead of ref type ports when resolving "
475 "wiring problems inside the LowerAnnotations pass"),
476 llvm::cl::init(
false), llvm::cl::Hidden};
479 "allow-adding-ports-on-public-modules",
480 llvm::cl::desc(
"Allow adding ports to public modules"),
481 llvm::cl::init(
false), llvm::cl::Hidden};
485 llvm::cl::desc(
"Convert probes to non-probe signals"),
486 llvm::cl::init(
false), llvm::cl::Hidden};
490 "preserve-aggregate",
491 llvm::cl::desc(
"Specify input file format:"),
494 "Preserve no aggregate"),
496 "Preserve only 1d vectors of ground type"),
498 "Preserve only vectors"),
500 "Preserve vectors and bundles")),
506 llvm::cl::desc(
"Specify the values which can be optimized away"),
509 "Strip all names. No name is preserved"),
511 "Names could be preserved by best-effort unlike `strip`"),
513 "Preserve values with meaningful names"),
515 "Preserve all values")),
519 "g", llvm::cl::desc(
"Enable the generation of debug information"),
520 llvm::cl::init(
false)};
524 "O", llvm::cl::desc(
"Controls how much optimization should be performed"),
527 "Compile with only necessary optimizations"),
529 "release",
"Compile with optimizations")),
533 llvm::cl::desc(
"Disable layer sink"),
538 llvm::cl::desc(
"Disable optimizations"),
542 "export-chisel-interface",
543 llvm::cl::desc(
"Generate a Scala Chisel interface to the top level "
544 "module of the firrtl circuit"),
545 llvm::cl::init(
false)};
548 "chisel-interface-out-dir",
550 "The output directory for generated Chisel interface files"),
555 llvm::cl::desc(
"Transform vectors of bundles to bundles of vectors"),
556 llvm::cl::init(
false)};
560 llvm::cl::desc(
"Disable deduplication of structurally identical modules"),
561 llvm::cl::init(
false)};
564 "grand-central-companion-mode",
565 llvm::cl::desc(
"Specifies the handling of Grand Central companions"),
567 clEnumValN(firrtl::CompanionMode::Bind,
"bind",
568 "Lower companion instances to SystemVerilog binds"),
569 clEnumValN(firrtl::CompanionMode::Instantiate,
"instantiate",
570 "Instantiate companions in the design"),
571 clEnumValN(firrtl::CompanionMode::Drop,
"drop",
572 "Remove companions from the design")),
573 llvm::cl::init(firrtl::CompanionMode::Bind),
578 "disable-aggressive-merge-connections",
580 "Disable aggressive merge connections (i.e. merge all field-level "
581 "connections into bulk connections)"),
582 llvm::cl::init(
false)};
585 "advanced-layer-sink",
586 llvm::cl::desc(
"Sink logic into layer blocks (advanced)"),
587 llvm::cl::init(
false)};
591 llvm::cl::desc(
"Lower memories to have memories with masks as an "
592 "array with one memory per ground type"),
593 llvm::cl::init(
false)};
598 "Optional path to use as the root of black box annotations"),
599 llvm::cl::value_desc(
"path"),
605 llvm::cl::desc(
"Replace the seq mem for macro replacement and emit "
606 "relevant metadata"),
607 llvm::cl::init(
false)};
610 "repl-seq-mem-file", llvm::cl::desc(
"File name for seq mem metadata"),
614 "extract-test-code", llvm::cl::desc(
"Run the extract test code pass"),
615 llvm::cl::init(
false)};
618 "ignore-read-enable-mem",
619 llvm::cl::desc(
"Ignore the read enable signal, instead of "
620 "assigning X on read disable"),
621 llvm::cl::init(
false)};
625 "Disable random initialization code (may break semantics!)"),
627 clEnumValN(firtool::FirtoolOptions::RandomKind::Mem,
628 "disable-mem-randomization",
629 "Disable emission of memory randomization code"),
630 clEnumValN(firtool::FirtoolOptions::RandomKind::Reg,
631 "disable-reg-randomization",
632 "Disable emission of register randomization code"),
633 clEnumValN(firtool::FirtoolOptions::RandomKind::All,
634 "disable-all-randomization",
635 "Disable emission of all randomization code")),
636 llvm::cl::init(firtool::FirtoolOptions::RandomKind::None)};
639 "output-annotation-file",
640 llvm::cl::desc(
"Optional output annotation file"),
641 llvm::cl::CommaSeparated, llvm::cl::value_desc(
"filename")};
644 "warn-on-unprocessed-annotations",
646 "Warn about annotations that were not removed by lower-to-hw"),
647 llvm::cl::init(
false)};
651 llvm::cl::desc(
"Annotate mux pragmas for memory array access"),
652 llvm::cl::init(
false)};
655 "verification-flavor",
656 llvm::cl::desc(
"Specify a verification flavor used in LowerFIRRTLToHW"),
658 clEnumValN(firrtl::VerificationFlavor::None,
"none",
659 "Use the flavor specified by the op"),
660 clEnumValN(firrtl::VerificationFlavor::IfElseFatal,
"if-else-fatal",
661 "Use Use `if(cond) else $fatal(..)` format"),
662 clEnumValN(firrtl::VerificationFlavor::Immediate,
"immediate",
663 "Use immediate verif statements"),
664 clEnumValN(firrtl::VerificationFlavor::SVA,
"sva",
"Use SVA")),
665 llvm::cl::init(firrtl::VerificationFlavor::None)};
668 "emit-separate-always-blocks",
670 "Prevent always blocks from being merged and emit constructs into "
671 "separate always blocks whenever possible"),
672 llvm::cl::init(
false)};
675 "etc-disable-instance-extraction",
676 llvm::cl::desc(
"Disable extracting instances only that feed test code"),
677 llvm::cl::init(
false)};
680 "etc-disable-register-extraction",
681 llvm::cl::desc(
"Disable extracting registers that only feed test code"),
682 llvm::cl::init(
false)};
685 "etc-disable-module-inlining",
686 llvm::cl::desc(
"Disable inlining modules that only feed test code"),
687 llvm::cl::init(
false)};
690 "add-vivado-ram-address-conflict-synthesis-bug-workaround",
692 "Add a vivado specific SV attribute (* ram_style = "
693 "\"distributed\" *) to unpacked array registers as a workaronud "
694 "for a vivado synthesis bug that incorrectly modifies "
695 "address conflict behavivor of combinational memories"),
696 llvm::cl::init(
false)};
703 "ckg-name", llvm::cl::desc(
"Clock gate module name"),
704 llvm::cl::init(
"EICG_wrapper")};
707 "ckg-input", llvm::cl::desc(
"Clock gate input port name"),
708 llvm::cl::init(
"in")};
711 "ckg-output", llvm::cl::desc(
"Clock gate output port name"),
712 llvm::cl::init(
"out")};
715 "ckg-enable", llvm::cl::desc(
"Clock gate enable port name"),
716 llvm::cl::init(
"en")};
720 llvm::cl::desc(
"Clock gate test enable port name (optional)"),
721 llvm::cl::init(
"test_en")};
724 "export-module-hierarchy",
725 llvm::cl::desc(
"Export module and instance hierarchy as JSON"),
726 llvm::cl::init(
false)};
729 "strip-fir-debug-info",
731 "Disable source fir locator information in output Verilog"),
732 llvm::cl::init(
true)};
736 llvm::cl::desc(
"Disable source locator information in output Verilog"),
737 llvm::cl::init(
false)};
740 "fixup-eicg-wrapper",
741 llvm::cl::desc(
"Lower `EICG_wrapper` modules into clock gate intrinsics"),
742 llvm::cl::init(
false)};
745 "add-companion-assume",
746 llvm::cl::desc(
"Add companion assumes to assertions"),
747 llvm::cl::init(
false)};
750 "select-default-for-unspecified-instance-choice",
752 "Specialize instance choice to default, if no option selected"),
753 llvm::cl::init(
false)};
769 : outputFilename(
"-"), disableAnnotationsUnknown(false),
770 disableAnnotationsClassless(false), lowerAnnotationsNoRefTypePorts(false),
771 allowAddingPortsOnPublic(false), probesToSignals(false),
772 preserveAggregate(firrtl::PreserveAggregate::None),
773 preserveMode(firrtl::PreserveValues::None), enableDebugInfo(false),
774 buildMode(BuildModeRelease), disableLayerSink(false),
776 chiselInterfaceOutDirectory(
""), vbToBV(false), noDedup(false),
777 companionMode(firrtl::CompanionMode::Bind),
778 disableAggressiveMergeConnections(false), advancedLayerSink(false),
779 lowerMemories(false), blackBoxRootPath(
""), replSeqMem(false),
780 replSeqMemFile(
""), extractTestCode(false), ignoreReadEnableMem(false),
781 disableRandom(
RandomKind::None), outputAnnotationFilename(
""),
782 enableAnnotationWarning(false), addMuxPragmas(false),
783 verificationFlavor(firrtl::VerificationFlavor::None),
784 emitSeparateAlwaysBlocks(false), etcDisableInstanceExtraction(false),
785 etcDisableRegisterExtraction(false), etcDisableModuleInlining(false),
786 addVivadoRAMAddressConflictSynthesisBugWorkaround(false),
787 ckgModuleName(
"EICG_wrapper"), ckgInputName(
"in"), ckgOutputName(
"out"),
788 ckgEnableName(
"en"), ckgTestEnableName(
"test_en"), ckgInstName(
"ckg"),
789 exportModuleHierarchy(false), stripFirDebugInfo(true),
790 stripDebugInfo(false), fixupEICGWrapper(false), addCompanionAssume(false),
791 disableCSEinClasses(false), selectDefaultInstanceChoice(false) {
812 clOptions->disableAggressiveMergeConnections;
830 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)