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.nestAny().addPass(verif::createStripContractsPass());
308 pm.addPass(verif::createLowerFormalToHWPass());
313 pm.addPass(sv::createSVExtractTestCodePass(
322 FirtoolOptions::RandomKind::Reg),
328 pm.addPass(seq::createHWMemSimImplPass(
330 FirtoolOptions::RandomKind::Mem),
335 ? seq::ReadEnableMode::Ignore
336 : seq::ReadEnableMode::Undefined,
344 modulePM.addPass(mlir::createCSEPass());
346 modulePM.addPass(mlir::createCSEPass());
347 modulePM.addPass(sv::createHWCleanupPass(
352 pm.addPass(hw::createVerifyInnerRefNamespacePass());
355 pm.addPass(om::createVerifyObjectFieldsPass());
366 pm.addNestedPass<
hw::HWModuleOp>(verif::createVerifyClockedAssertLikePass());
377 if (
auto fileLoc = dyn_cast<FileLineColLoc>(loc))
378 return fileLoc.getFilename().getValue().ends_with(
".fir");
384 [](mlir::Location loc) {
return true; }));
402 std::unique_ptr<llvm::raw_ostream> os) {
412 llvm::raw_ostream &os) {
422 llvm::StringRef directory) {
433 pm.addPass(om::createFreezePathsPass());
440 llvm::raw_ostream &os) {
442 pm.addNestedPass<
hw::HWModuleOp>(circt::verif::createPrepareForFormalPass());
456struct FirtoolCmdOptions {
459 llvm::cl::desc(
"Output filename, or directory for split output"),
460 llvm::cl::value_desc(
"filename"),
465 "disable-annotation-unknown",
466 llvm::cl::desc(
"Ignore unknown annotations when parsing"),
467 llvm::cl::init(
false)};
470 "disable-annotation-classless",
471 llvm::cl::desc(
"Ignore annotations without a class when parsing"),
472 llvm::cl::init(
false)};
475 "lower-annotations-no-ref-type-ports",
477 "Create real ports instead of ref type ports when resolving "
478 "wiring problems inside the LowerAnnotations pass"),
479 llvm::cl::init(
false), llvm::cl::Hidden};
482 "allow-adding-ports-on-public-modules",
483 llvm::cl::desc(
"Allow adding ports to public modules"),
484 llvm::cl::init(
false), llvm::cl::Hidden};
488 llvm::cl::desc(
"Convert probes to non-probe signals"),
489 llvm::cl::init(
false), llvm::cl::Hidden};
493 "preserve-aggregate",
494 llvm::cl::desc(
"Specify input file format:"),
497 "Preserve no aggregate"),
499 "Preserve only 1d vectors of ground type"),
501 "Preserve only vectors"),
503 "Preserve vectors and bundles")),
509 llvm::cl::desc(
"Specify the values which can be optimized away"),
512 "Strip all names. No name is preserved"),
514 "Names could be preserved by best-effort unlike `strip`"),
516 "Preserve values with meaningful names"),
518 "Preserve all values")),
522 "g", llvm::cl::desc(
"Enable the generation of debug information"),
523 llvm::cl::init(
false)};
527 "O", llvm::cl::desc(
"Controls how much optimization should be performed"),
530 "Compile with only necessary optimizations"),
532 "release",
"Compile with optimizations")),
536 llvm::cl::desc(
"Disable layer sink"),
541 llvm::cl::desc(
"Disable optimizations"),
545 "export-chisel-interface",
546 llvm::cl::desc(
"Generate a Scala Chisel interface to the top level "
547 "module of the firrtl circuit"),
548 llvm::cl::init(
false)};
551 "chisel-interface-out-dir",
553 "The output directory for generated Chisel interface files"),
558 llvm::cl::desc(
"Transform vectors of bundles to bundles of vectors"),
559 llvm::cl::init(
false)};
563 llvm::cl::desc(
"Disable deduplication of structurally identical modules"),
564 llvm::cl::init(
false)};
567 "grand-central-companion-mode",
568 llvm::cl::desc(
"Specifies the handling of Grand Central companions"),
570 clEnumValN(firrtl::CompanionMode::Bind,
"bind",
571 "Lower companion instances to SystemVerilog binds"),
572 clEnumValN(firrtl::CompanionMode::Instantiate,
"instantiate",
573 "Instantiate companions in the design"),
574 clEnumValN(firrtl::CompanionMode::Drop,
"drop",
575 "Remove companions from the design")),
576 llvm::cl::init(firrtl::CompanionMode::Bind),
581 "disable-aggressive-merge-connections",
583 "Disable aggressive merge connections (i.e. merge all field-level "
584 "connections into bulk connections)"),
585 llvm::cl::init(
false)};
588 "advanced-layer-sink",
589 llvm::cl::desc(
"Sink logic into layer blocks (advanced)"),
590 llvm::cl::init(
false)};
594 llvm::cl::desc(
"Lower memories to have memories with masks as an "
595 "array with one memory per ground type"),
596 llvm::cl::init(
false)};
601 "Optional path to use as the root of black box annotations"),
602 llvm::cl::value_desc(
"path"),
608 llvm::cl::desc(
"Replace the seq mem for macro replacement and emit "
609 "relevant metadata"),
610 llvm::cl::init(
false)};
613 "repl-seq-mem-file", llvm::cl::desc(
"File name for seq mem metadata"),
617 "extract-test-code", llvm::cl::desc(
"Run the extract test code pass"),
618 llvm::cl::init(
false)};
621 "ignore-read-enable-mem",
622 llvm::cl::desc(
"Ignore the read enable signal, instead of "
623 "assigning X on read disable"),
624 llvm::cl::init(
false)};
628 "Disable random initialization code (may break semantics!)"),
630 clEnumValN(firtool::FirtoolOptions::RandomKind::Mem,
631 "disable-mem-randomization",
632 "Disable emission of memory randomization code"),
633 clEnumValN(firtool::FirtoolOptions::RandomKind::Reg,
634 "disable-reg-randomization",
635 "Disable emission of register randomization code"),
636 clEnumValN(firtool::FirtoolOptions::RandomKind::All,
637 "disable-all-randomization",
638 "Disable emission of all randomization code")),
639 llvm::cl::init(firtool::FirtoolOptions::RandomKind::None)};
642 "output-annotation-file",
643 llvm::cl::desc(
"Optional output annotation file"),
644 llvm::cl::CommaSeparated, llvm::cl::value_desc(
"filename")};
647 "warn-on-unprocessed-annotations",
649 "Warn about annotations that were not removed by lower-to-hw"),
650 llvm::cl::init(
false)};
654 llvm::cl::desc(
"Annotate mux pragmas for memory array access"),
655 llvm::cl::init(
false)};
658 "verification-flavor",
659 llvm::cl::desc(
"Specify a verification flavor used in LowerFIRRTLToHW"),
661 clEnumValN(firrtl::VerificationFlavor::None,
"none",
662 "Use the flavor specified by the op"),
663 clEnumValN(firrtl::VerificationFlavor::IfElseFatal,
"if-else-fatal",
664 "Use Use `if(cond) else $fatal(..)` format"),
665 clEnumValN(firrtl::VerificationFlavor::Immediate,
"immediate",
666 "Use immediate verif statements"),
667 clEnumValN(firrtl::VerificationFlavor::SVA,
"sva",
"Use SVA")),
668 llvm::cl::init(firrtl::VerificationFlavor::None)};
671 "emit-separate-always-blocks",
673 "Prevent always blocks from being merged and emit constructs into "
674 "separate always blocks whenever possible"),
675 llvm::cl::init(
false)};
678 "etc-disable-instance-extraction",
679 llvm::cl::desc(
"Disable extracting instances only that feed test code"),
680 llvm::cl::init(
false)};
683 "etc-disable-register-extraction",
684 llvm::cl::desc(
"Disable extracting registers that only feed test code"),
685 llvm::cl::init(
false)};
688 "etc-disable-module-inlining",
689 llvm::cl::desc(
"Disable inlining modules that only feed test code"),
690 llvm::cl::init(
false)};
693 "add-vivado-ram-address-conflict-synthesis-bug-workaround",
695 "Add a vivado specific SV attribute (* ram_style = "
696 "\"distributed\" *) to unpacked array registers as a workaronud "
697 "for a vivado synthesis bug that incorrectly modifies "
698 "address conflict behavivor of combinational memories"),
699 llvm::cl::init(
false)};
706 "ckg-name", llvm::cl::desc(
"Clock gate module name"),
707 llvm::cl::init(
"EICG_wrapper")};
710 "ckg-input", llvm::cl::desc(
"Clock gate input port name"),
711 llvm::cl::init(
"in")};
714 "ckg-output", llvm::cl::desc(
"Clock gate output port name"),
715 llvm::cl::init(
"out")};
718 "ckg-enable", llvm::cl::desc(
"Clock gate enable port name"),
719 llvm::cl::init(
"en")};
723 llvm::cl::desc(
"Clock gate test enable port name (optional)"),
724 llvm::cl::init(
"test_en")};
727 "export-module-hierarchy",
728 llvm::cl::desc(
"Export module and instance hierarchy as JSON"),
729 llvm::cl::init(
false)};
732 "strip-fir-debug-info",
734 "Disable source fir locator information in output Verilog"),
735 llvm::cl::init(
true)};
739 llvm::cl::desc(
"Disable source locator information in output Verilog"),
740 llvm::cl::init(
false)};
743 "fixup-eicg-wrapper",
744 llvm::cl::desc(
"Lower `EICG_wrapper` modules into clock gate intrinsics"),
745 llvm::cl::init(
false)};
748 "add-companion-assume",
749 llvm::cl::desc(
"Add companion assumes to assertions"),
750 llvm::cl::init(
false)};
753 "select-default-for-unspecified-instance-choice",
755 "Specialize instance choice to default, if no option selected"),
756 llvm::cl::init(
false)};
760 llvm::cl::desc(
"Control how symbolic values are lowered"),
761 llvm::cl::init(verif::SymbolicValueLowering::ExtModule),
762 verif::symbolicValueLoweringCLValues()};
778 : outputFilename(
"-"), disableAnnotationsUnknown(false),
779 disableAnnotationsClassless(false), lowerAnnotationsNoRefTypePorts(false),
780 allowAddingPortsOnPublic(false), probesToSignals(false),
781 preserveAggregate(firrtl::PreserveAggregate::None),
782 preserveMode(firrtl::PreserveValues::None), enableDebugInfo(false),
783 buildMode(BuildModeRelease), disableLayerSink(false),
785 chiselInterfaceOutDirectory(
""), vbToBV(false), noDedup(false),
786 companionMode(firrtl::CompanionMode::Bind),
787 disableAggressiveMergeConnections(false), advancedLayerSink(false),
788 lowerMemories(false), blackBoxRootPath(
""), replSeqMem(false),
789 replSeqMemFile(
""), extractTestCode(false), ignoreReadEnableMem(false),
790 disableRandom(
RandomKind::None), outputAnnotationFilename(
""),
791 enableAnnotationWarning(false), addMuxPragmas(false),
792 verificationFlavor(firrtl::VerificationFlavor::None),
793 emitSeparateAlwaysBlocks(false), etcDisableInstanceExtraction(false),
794 etcDisableRegisterExtraction(false), etcDisableModuleInlining(false),
795 addVivadoRAMAddressConflictSynthesisBugWorkaround(false),
796 ckgModuleName(
"EICG_wrapper"), ckgInputName(
"in"), ckgOutputName(
"out"),
797 ckgEnableName(
"en"), ckgTestEnableName(
"test_en"), ckgInstName(
"ckg"),
798 exportModuleHierarchy(false), stripFirDebugInfo(true),
799 stripDebugInfo(false), fixupEICGWrapper(false), addCompanionAssume(false),
800 disableCSEinClasses(false), selectDefaultInstanceChoice(false) {
821 clOptions->disableAggressiveMergeConnections;
839 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)