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(
71 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
72 mlir::createCSEPass());
74 pm.nest<firrtl::CircuitOp>().nestAny().addPass(mlir::createCSEPass());
77 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
80 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
83 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
88 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
94 pm.nest<firrtl::CircuitOp>().addPass(
107 pm.nest<firrtl::CircuitOp>().addPass(
124 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
134 auto &modulePM = pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>();
151 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
159 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
164 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
170 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
177 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
196 pm.addNestedPass<firrtl::CircuitOp>(mlir::createSymbolDCEPass());
206 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
208 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
210 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
215 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
221 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
226 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
234 StringRef inputFilename) {
240 pm.nest<firrtl::CircuitOp>().addPass(
243 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
261 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
265 if (outputFilename ==
"-")
268 pm.nest<firrtl::CircuitOp>().addPass(
277 pm.addNestedPass<firrtl::CircuitOp>(
282 ? llvm::sys::path::parent_path(inputFilename)
284 pm.nest<firrtl::CircuitOp>().addPass(
289 pm.nest<firrtl::CircuitOp>().addPass(
294 pm.nest<firrtl::CircuitOp>().addPass(om::createVerifyObjectFieldsPass());
297 pm.nest<firrtl::CircuitOp>().nest<firrtl::FModuleOp>().addPass(
305 modulePM.addPass(mlir::createCSEPass());
310 pm.addPass(hw::createVerifyInnerRefNamespacePass());
313 pm.addPass(om::createVerifyObjectFieldsPass());
316 pm.addNestedPass<
hw::HWModuleOp>(verif::createVerifyClockedAssertLikePass());
323 pm.nestAny().addPass(verif::createStripContractsPass());
324 pm.addPass(verif::createLowerFormalToHWPass());
329 pm.addPass(sv::createSVExtractTestCodePass(
338 FirtoolOptions::RandomKind::Reg),
344 pm.addPass(seq::createHWMemSimImplPass(
346 FirtoolOptions::RandomKind::Mem),
351 ? seq::ReadEnableMode::Ignore
352 : seq::ReadEnableMode::Undefined,
360 modulePM.addPass(mlir::createCSEPass());
362 modulePM.addPass(mlir::createCSEPass());
363 modulePM.addPass(sv::createHWCleanupPass(
368 pm.addPass(hw::createVerifyInnerRefNamespacePass());
371 pm.addPass(om::createVerifyObjectFieldsPass());
382 pm.addNestedPass<
hw::HWModuleOp>(verif::createVerifyClockedAssertLikePass());
393 if (
auto fileLoc = dyn_cast<FileLineColLoc>(loc))
394 return fileLoc.getFilename().getValue().ends_with(
".fir");
400 [](mlir::Location loc) {
return true; }));
418 std::unique_ptr<llvm::raw_ostream> os) {
428 llvm::raw_ostream &os) {
438 llvm::StringRef directory) {
449 pm.addPass(om::createFreezePathsPass());
456 llvm::raw_ostream &os) {
458 pm.addNestedPass<
hw::HWModuleOp>(circt::verif::createPrepareForFormalPass());
472struct FirtoolCmdOptions {
475 llvm::cl::desc(
"Output filename, or directory for split output"),
476 llvm::cl::value_desc(
"filename"),
481 "disable-annotation-unknown",
482 llvm::cl::desc(
"Ignore unknown annotations when parsing"),
483 llvm::cl::init(
false)};
486 "disable-annotation-classless",
487 llvm::cl::desc(
"Ignore annotations without a class when parsing"),
488 llvm::cl::init(
false)};
491 "lower-annotations-no-ref-type-ports",
493 "Create real ports instead of ref type ports when resolving "
494 "wiring problems inside the LowerAnnotations pass"),
495 llvm::cl::init(
false), llvm::cl::Hidden};
498 "allow-adding-ports-on-public-modules",
499 llvm::cl::desc(
"Allow adding ports to public modules"),
500 llvm::cl::init(
false), llvm::cl::Hidden};
504 llvm::cl::desc(
"Convert probes to non-probe signals"),
505 llvm::cl::init(
false), llvm::cl::Hidden};
509 "preserve-aggregate",
510 llvm::cl::desc(
"Specify input file format:"),
513 "Preserve no aggregate"),
515 "Preserve only 1d vectors of ground type"),
517 "Preserve only vectors"),
519 "Preserve vectors and bundles")),
525 llvm::cl::desc(
"Specify the values which can be optimized away"),
528 "Strip all names. No name is preserved"),
530 "Names could be preserved by best-effort unlike `strip`"),
532 "Preserve values with meaningful names"),
534 "Preserve all values")),
538 "g", llvm::cl::desc(
"Enable the generation of debug information"),
539 llvm::cl::init(
false)};
543 "O", llvm::cl::desc(
"Controls how much optimization should be performed"),
546 "Compile with only necessary optimizations"),
548 "release",
"Compile with optimizations")),
552 llvm::cl::desc(
"Disable layer sink"),
557 llvm::cl::desc(
"Disable optimizations"),
561 "export-chisel-interface",
562 llvm::cl::desc(
"Generate a Scala Chisel interface to the top level "
563 "module of the firrtl circuit"),
564 llvm::cl::init(
false)};
567 "chisel-interface-out-dir",
569 "The output directory for generated Chisel interface files"),
574 llvm::cl::desc(
"Transform vectors of bundles to bundles of vectors"),
575 llvm::cl::init(
false)};
579 llvm::cl::desc(
"Disable deduplication of structurally identical modules"),
580 llvm::cl::init(
false)};
583 "grand-central-companion-mode",
584 llvm::cl::desc(
"Specifies the handling of Grand Central companions"),
586 clEnumValN(firrtl::CompanionMode::Bind,
"bind",
587 "Lower companion instances to SystemVerilog binds"),
588 clEnumValN(firrtl::CompanionMode::Instantiate,
"instantiate",
589 "Instantiate companions in the design"),
590 clEnumValN(firrtl::CompanionMode::Drop,
"drop",
591 "Remove companions from the design")),
592 llvm::cl::init(firrtl::CompanionMode::Bind),
597 "disable-aggressive-merge-connections",
599 "Disable aggressive merge connections (i.e. merge all field-level "
600 "connections into bulk connections)"),
601 llvm::cl::init(
false)};
604 "advanced-layer-sink",
605 llvm::cl::desc(
"Sink logic into layer blocks (advanced)"),
606 llvm::cl::init(
false)};
610 llvm::cl::desc(
"Lower memories to have memories with masks as an "
611 "array with one memory per ground type"),
612 llvm::cl::init(
false)};
617 "Optional path to use as the root of black box annotations"),
618 llvm::cl::value_desc(
"path"),
624 llvm::cl::desc(
"Replace the seq mem for macro replacement and emit "
625 "relevant metadata"),
626 llvm::cl::init(
false)};
629 "repl-seq-mem-file", llvm::cl::desc(
"File name for seq mem metadata"),
633 "extract-test-code", llvm::cl::desc(
"Run the extract test code pass"),
634 llvm::cl::init(
false)};
637 "ignore-read-enable-mem",
638 llvm::cl::desc(
"Ignore the read enable signal, instead of "
639 "assigning X on read disable"),
640 llvm::cl::init(
false)};
644 "Disable random initialization code (may break semantics!)"),
646 clEnumValN(firtool::FirtoolOptions::RandomKind::Mem,
647 "disable-mem-randomization",
648 "Disable emission of memory randomization code"),
649 clEnumValN(firtool::FirtoolOptions::RandomKind::Reg,
650 "disable-reg-randomization",
651 "Disable emission of register randomization code"),
652 clEnumValN(firtool::FirtoolOptions::RandomKind::All,
653 "disable-all-randomization",
654 "Disable emission of all randomization code")),
655 llvm::cl::init(firtool::FirtoolOptions::RandomKind::None)};
658 "output-annotation-file",
659 llvm::cl::desc(
"Optional output annotation file"),
660 llvm::cl::CommaSeparated, llvm::cl::value_desc(
"filename")};
663 "warn-on-unprocessed-annotations",
665 "Warn about annotations that were not removed by lower-to-hw"),
666 llvm::cl::init(
false)};
670 llvm::cl::desc(
"Annotate mux pragmas for memory array access"),
671 llvm::cl::init(
false)};
674 "verification-flavor",
675 llvm::cl::desc(
"Specify a verification flavor used in LowerFIRRTLToHW"),
677 clEnumValN(firrtl::VerificationFlavor::None,
"none",
678 "Use the flavor specified by the op"),
679 clEnumValN(firrtl::VerificationFlavor::IfElseFatal,
"if-else-fatal",
680 "Use Use `if(cond) else $fatal(..)` format"),
681 clEnumValN(firrtl::VerificationFlavor::Immediate,
"immediate",
682 "Use immediate verif statements"),
683 clEnumValN(firrtl::VerificationFlavor::SVA,
"sva",
"Use SVA")),
684 llvm::cl::init(firrtl::VerificationFlavor::None)};
687 "emit-separate-always-blocks",
689 "Prevent always blocks from being merged and emit constructs into "
690 "separate always blocks whenever possible"),
691 llvm::cl::init(
false)};
694 "etc-disable-instance-extraction",
695 llvm::cl::desc(
"Disable extracting instances only that feed test code"),
696 llvm::cl::init(
false)};
699 "etc-disable-register-extraction",
700 llvm::cl::desc(
"Disable extracting registers that only feed test code"),
701 llvm::cl::init(
false)};
704 "etc-disable-module-inlining",
705 llvm::cl::desc(
"Disable inlining modules that only feed test code"),
706 llvm::cl::init(
false)};
709 "add-vivado-ram-address-conflict-synthesis-bug-workaround",
711 "Add a vivado specific SV attribute (* ram_style = "
712 "\"distributed\" *) to unpacked array registers as a workaronud "
713 "for a vivado synthesis bug that incorrectly modifies "
714 "address conflict behavivor of combinational memories"),
715 llvm::cl::init(
false)};
722 "ckg-name", llvm::cl::desc(
"Clock gate module name"),
723 llvm::cl::init(
"EICG_wrapper")};
726 "ckg-input", llvm::cl::desc(
"Clock gate input port name"),
727 llvm::cl::init(
"in")};
730 "ckg-output", llvm::cl::desc(
"Clock gate output port name"),
731 llvm::cl::init(
"out")};
734 "ckg-enable", llvm::cl::desc(
"Clock gate enable port name"),
735 llvm::cl::init(
"en")};
739 llvm::cl::desc(
"Clock gate test enable port name (optional)"),
740 llvm::cl::init(
"test_en")};
743 "export-module-hierarchy",
744 llvm::cl::desc(
"Export module and instance hierarchy as JSON"),
745 llvm::cl::init(
false)};
748 "strip-fir-debug-info",
750 "Disable source fir locator information in output Verilog"),
751 llvm::cl::init(
true)};
755 llvm::cl::desc(
"Disable source locator information in output Verilog"),
756 llvm::cl::init(
false)};
759 "fixup-eicg-wrapper",
760 llvm::cl::desc(
"Lower `EICG_wrapper` modules into clock gate intrinsics"),
761 llvm::cl::init(
false)};
764 "add-companion-assume",
765 llvm::cl::desc(
"Add companion assumes to assertions"),
766 llvm::cl::init(
false)};
769 "select-default-for-unspecified-instance-choice",
771 "Specialize instance choice to default, if no option selected"),
772 llvm::cl::init(
false)};
776 llvm::cl::desc(
"Control how symbolic values are lowered"),
777 llvm::cl::init(verif::SymbolicValueLowering::ExtModule),
778 verif::symbolicValueLoweringCLValues()};
781 "disable-wire-elimination", llvm::cl::desc(
"Disable wire elimination"),
782 llvm::cl::init(
false)};
798 : outputFilename(
"-"), disableAnnotationsUnknown(false),
799 disableAnnotationsClassless(false), lowerAnnotationsNoRefTypePorts(false),
800 allowAddingPortsOnPublic(false), probesToSignals(false),
801 preserveAggregate(firrtl::PreserveAggregate::None),
802 preserveMode(firrtl::PreserveValues::None), enableDebugInfo(false),
803 buildMode(BuildModeRelease), disableLayerSink(false),
805 chiselInterfaceOutDirectory(
""), vbToBV(false), noDedup(false),
806 companionMode(firrtl::CompanionMode::Bind),
807 disableAggressiveMergeConnections(false), advancedLayerSink(false),
808 lowerMemories(false), blackBoxRootPath(
""), replSeqMem(false),
809 replSeqMemFile(
""), extractTestCode(false), ignoreReadEnableMem(false),
810 disableRandom(
RandomKind::None), outputAnnotationFilename(
""),
811 enableAnnotationWarning(false), addMuxPragmas(false),
812 verificationFlavor(firrtl::VerificationFlavor::None),
813 emitSeparateAlwaysBlocks(false), etcDisableInstanceExtraction(false),
814 etcDisableRegisterExtraction(false), etcDisableModuleInlining(false),
815 addVivadoRAMAddressConflictSynthesisBugWorkaround(false),
816 ckgModuleName(
"EICG_wrapper"), ckgInputName(
"in"), ckgOutputName(
"out"),
817 ckgEnableName(
"en"), ckgTestEnableName(
"test_en"), ckgInstName(
"ckg"),
818 exportModuleHierarchy(false), stripFirDebugInfo(true),
819 stripDebugInfo(false), fixupEICGWrapper(false), addCompanionAssume(false),
820 disableCSEinClasses(false), selectDefaultInstanceChoice(false),
821 symbolicValueLowering(
verif::SymbolicValueLowering::ExtModule),
822 disableWireElimination(false) {
843 clOptions->disableAggressiveMergeConnections;
861 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 > createEliminateWiresPass()
This is the pass constructor.
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)