CIRCT 24.0.0git
Loading...
Searching...
No Matches
Firtool.h
Go to the documentation of this file.
1//===- Firtool.h - Definitions for the firtool pipeline setup ---*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This library parses options for firtool and sets up its pipeline.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef CIRCT_FIRTOOL_FIRTOOL_H
14#define CIRCT_FIRTOOL_FIRTOOL_H
15
20#include "circt/Support/LLVM.h"
21#include "mlir/Pass/PassManager.h"
22#include "llvm/Support/CommandLine.h"
23
24namespace circt {
25namespace firtool {
26
27//===----------------------------------------------------------------------===//
28// FirtoolOptions
29//===----------------------------------------------------------------------===//
30
31/// Set of options used to control the behavior of the firtool pipeline.
33public:
35
36 // Helper Types
38 enum class RandomKind { None, Mem, Reg, All };
39
40 enum class DomainMode {
41 /// Erase domains from the input circuit.
42 Strip,
43 /// Disable domain checking.
44 Disable,
45 /// Check domains without inference.
46 Check,
47 /// Check domains with inference for private modules.
48 Infer,
49 /// Check domains with inference for both public and private modules.
51 };
52
53 /// Convert the "domain mode" firtool option to a "firrtl::InferDomainsMode",
54 /// the configuration for a pass.
55 static constexpr std::optional<firrtl::InferDomainsMode>
70
71 bool isRandomEnabled(RandomKind kind) const {
72 return disableRandom != RandomKind::All && disableRandom != kind;
73 }
74
75 /// Advance the disabled-randomization lattice. Calling this twice with
76 /// the two individual kinds is equivalent to calling it once with All.
77 static RandomKind mergeRandomKind(RandomKind current, RandomKind incoming) {
78 if (current == RandomKind::None)
79 return incoming;
80 if (current == incoming)
81 return current;
82 return RandomKind::All;
83 }
84
89
91 switch (buildMode) {
92 case BuildModeDebug:
97 return preserveMode;
98 }
99 llvm_unreachable("unknown build mode");
100 }
101
102 StringRef getOutputFilename() const { return outputFilename; }
103 StringRef getBlackBoxRootPath() const { return blackBoxRootPath; }
105 StringRef getOutputAnnotationFilename() const {
107 }
108
113
114 bool getNoViews() const { return noViews; }
115
116 seq::ExternalizeClockGateOptions getClockGateOptions() const {
119 }
120
121 FirtoolOptions &setClockGateOptions(seq::ExternalizeClockGateOptions &opts) {
122 ckgModuleName = opts.moduleName;
123 ckgInputName = opts.inputName;
124 ckgOutputName = opts.outputName;
125 ckgEnableName = opts.enableName;
126 ckgTestEnableName = opts.testEnableName;
127 ckgInstName = opts.instName;
128 return *this;
129 }
130
131 bool isDefaultOutputFilename() const { return outputFilename == "-"; }
145 bool shouldLowerMemories() const { return lowerMemories; }
146 bool shouldDedup() const { return !noDedup; }
147 bool shouldDedupClasses() const { return dedupClasses; }
148 bool shouldEnableDebugInfo() const { return enableDebugInfo; }
151 bool shouldConvertVecOfBundle() const { return vbToBV; }
152 bool shouldStripDebugInfo() const { return stripDebugInfo; }
160 bool shouldLowerToCore() const { return lowerToCore; }
165 bool shouldAddMuxPragmas() const { return addMuxPragmas; }
174
179
181
182 bool getLintXmrsInDesign() const { return lintXmrsInDesign; }
183
184 bool getEmitAllBindFiles() const { return emitAllBindFiles; }
185
187
189
190 ArrayRef<std::string> getSkippedDomains() const { return skippedDomains; }
191
192 // Setters, used by the CAPI
194 outputFilename = name;
195 return *this;
196 }
197
200 return *this;
201 }
202
205 return *this;
206 }
207
210 return *this;
211 }
212
214 probesToSignals = value;
215 return *this;
216 }
217
223
226 preserveMode = value;
227 return *this;
228 }
229
231 enableDebugInfo = value;
232 return *this;
233 }
234
236 buildMode = value;
237 return *this;
238 }
239
241 disableLayerSink = value;
242 return *this;
243 }
244
246 disableOptimization = value;
247 return *this;
248 }
249
251 vbToBV = value;
252 return *this;
253 }
254
256 noDedup = value;
257 return *this;
258 }
259
261 dedupClasses = value;
262 return *this;
263 }
264
266 companionMode = value;
267 return *this;
268 }
269
271 noViews = value;
272 return *this;
273 }
274
279
281 lowerMemories = value;
282 return *this;
283 }
284
286 blackBoxRootPath = value;
287 return *this;
288 }
289
291 replSeqMem = value;
292 return *this;
293 }
294
296 replSeqMemFile = value;
297 return *this;
298 }
299
301 ignoreReadEnableMem = value;
302 return *this;
303 }
304
306 useNewFullResetFlow = value;
307 return *this;
308 }
309
312 return *this;
313 }
314
317 return *this;
318 }
319
321 warnOnTruncation = value;
322 return *this;
323 }
324
326 lowerToCore = value;
327 return *this;
328 }
329
331 addMuxPragmas = value;
332 return *this;
333 }
334
339
342 return *this;
343 }
344
350
352 ckgModuleName = value;
353 return *this;
354 }
355
356 FirtoolOptions &setCkgInputName(StringRef value) {
357 ckgInputName = value;
358 return *this;
359 }
360
362 ckgOutputName = value;
363 return *this;
364 }
365
367 ckgEnableName = value;
368 return *this;
369 }
370
372 ckgTestEnableName = value;
373 return *this;
374 }
375
377 exportModuleHierarchy = value;
378 return *this;
379 }
380
382 stripFirDebugInfo = value;
383 return *this;
384 }
385
387 stripDebugInfo = value;
388 return *this;
389 }
390
392 fixupEICGWrapper = value;
393 return *this;
394 }
395
397 disableCSEinClasses = value;
398 return *this;
399 }
400
403 return *this;
404 }
405
410
413 return *this;
414 }
415
417 lintStaticAsserts = value;
418 return *this;
419 }
420
422 lintXmrsInDesign = value;
423 return *this;
424 }
425
427 emitAllBindFiles = value;
428 return *this;
429 }
430
433 return *this;
434 }
435
437 domainMode = value;
438 return *this;
439 }
440
441private:
442 std::string outputFilename;
443
444 // LowerFIRRTLAnnotations
448
456 bool vbToBV;
463 std::string blackBoxRootPath;
465 std::string replSeqMemFile;
477 std::string ckgModuleName;
478 std::string ckgInputName;
479 std::string ckgOutputName;
480 std::string ckgEnableName;
481 std::string ckgTestEnableName;
482 std::string ckgInstName;
496 SmallVector<std::string> skippedDomains;
497};
498
500
501LogicalResult populatePreprocessTransforms(mlir::PassManager &pm,
502 const FirtoolOptions &opt);
503
504LogicalResult populateCHIRRTLToLowFIRRTL(mlir::PassManager &pm,
505 const FirtoolOptions &opt);
506
507LogicalResult populateLowFIRRTLToHW(mlir::PassManager &pm,
508 const FirtoolOptions &opt,
509 StringRef inputFilename);
510
511LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt);
512
513LogicalResult populateExportVerilog(mlir::PassManager &pm,
514 const FirtoolOptions &opt,
515 std::unique_ptr<llvm::raw_ostream> os);
516
517LogicalResult populateExportVerilog(mlir::PassManager &pm,
518 const FirtoolOptions &opt,
519 llvm::raw_ostream &os);
520
521LogicalResult populateExportSplitVerilog(mlir::PassManager &pm,
522 const FirtoolOptions &opt,
523 llvm::StringRef directory);
524
525LogicalResult populateFinalizeIR(mlir::PassManager &pm,
526 const FirtoolOptions &opt);
527
528LogicalResult populateHWToBTOR2(mlir::PassManager &pm,
529 const FirtoolOptions &opt,
530 llvm::raw_ostream &os);
531
532} // namespace firtool
533} // namespace circt
534
535#endif // CIRCT_FIRTOOL_FIRTOOL_H
Set of options used to control the behavior of the firtool pipeline.
Definition Firtool.h:32
FirtoolOptions & setFixupEICGWrapper(bool value)
Definition Firtool.h:391
FirtoolOptions & setPreserveAggregate(firrtl::PreserveAggregate::PreserveMode value)
Definition Firtool.h:219
FirtoolOptions & setAddVivadoRAMAddressConflictSynthesisBugWorkaround(bool value)
Definition Firtool.h:346
bool shouldStripDebugInfo() const
Definition Firtool.h:152
FirtoolOptions & setBuildMode(BuildMode value)
Definition Firtool.h:235
FirtoolOptions & setDisableAggressiveMergeConnections(bool value)
Definition Firtool.h:275
FirtoolOptions & setCkgInputName(StringRef value)
Definition Firtool.h:356
firrtl::PreserveAggregate::PreserveMode getPreserveAggregate() const
Definition Firtool.h:109
FirtoolOptions & setLowerToCore(bool value)
Definition Firtool.h:325
bool shouldAddVivadoRAMAddressConflictSynthesisBugWorkaround() const
Definition Firtool.h:166
bool shouldDisableLayerSink() const
Definition Firtool.h:143
firrtl::PreserveValues::PreserveMode preserveMode
Definition Firtool.h:451
FirtoolOptions & setDisableCSEinClasses(bool value)
Definition Firtool.h:396
auto getVerificationFlavor() const
Definition Firtool.h:161
@ Strip
Erase domains from the input circuit.
@ Check
Check domains without inference.
@ Infer
Check domains with inference for private modules.
@ InferAll
Check domains with inference for both public and private modules.
FirtoolOptions & setClockGateOptions(seq::ExternalizeClockGateOptions &opts)
Definition Firtool.h:121
FirtoolOptions & setCkgTestEnableName(StringRef value)
Definition Firtool.h:371
FirtoolOptions & mergeDisableRandom(RandomKind kind)
Definition Firtool.h:85
bool isDefaultOutputFilename() const
Definition Firtool.h:131
StringRef getOutputFilename() const
Definition Firtool.h:102
FirtoolOptions & setDedupClasses(bool value)
Definition Firtool.h:260
bool shouldDisableAggressiveMergeConnections() const
Definition Firtool.h:155
bool shouldWarnOnTruncation() const
Definition Firtool.h:159
StringRef getReplaceSequentialMemoriesFile() const
Definition Firtool.h:104
bool addVivadoRAMAddressConflictSynthesisBugWorkaround
Definition Firtool.h:476
FirtoolOptions & setSymbolicValueLowering(verif::SymbolicValueLowering mode)
Definition Firtool.h:406
SmallVector< std::string > skippedDomains
Definition Firtool.h:496
FirtoolOptions & setLowerMemories(bool value)
Definition Firtool.h:280
FirtoolOptions & setNoDedup(bool value)
Definition Firtool.h:255
bool shouldFixupEICGWrapper() const
Definition Firtool.h:169
bool shouldConvertProbesToSignals() const
Definition Firtool.h:141
firrtl::PreserveValues::PreserveMode getPreserveMode() const
Definition Firtool.h:90
FirtoolOptions & setLowerAnnotationsNoRefTypePorts(bool value)
Definition Firtool.h:208
bool shouldDedupClasses() const
Definition Firtool.h:147
FirtoolOptions & setUseNewFullResetFlow(bool value)
Definition Firtool.h:305
StringRef getBlackBoxRootPath() const
Definition Firtool.h:103
bool shouldDisableCSEinClasses() const
Definition Firtool.h:170
bool shouldDisableOptimization() const
Definition Firtool.h:144
firrtl::CompanionMode getCompanionMode() const
Definition Firtool.h:112
bool shouldDisableClasslessAnnotations() const
Definition Firtool.h:135
FirtoolOptions & setAddMuxPragmas(bool value)
Definition Firtool.h:330
FirtoolOptions & setPreserveValues(firrtl::PreserveValues::PreserveMode value)
Definition Firtool.h:225
bool getEmitAllBindFiles() const
Definition Firtool.h:184
bool shouldReplaceSequentialMemories() const
Definition Firtool.h:142
FirtoolOptions & setDomainMode(DomainMode value)
Definition Firtool.h:436
bool shouldIgnoreReadEnableMemories() const
Definition Firtool.h:149
FirtoolOptions & setOutputAnnotationFilename(StringRef value)
Definition Firtool.h:310
FirtoolOptions & setCkgOutputName(StringRef value)
Definition Firtool.h:361
bool isRandomEnabled(RandomKind kind) const
Definition Firtool.h:71
bool shouldDisableUnknownAnnotations() const
Definition Firtool.h:132
FirtoolOptions & setNoViews(bool value)
Definition Firtool.h:270
static RandomKind mergeRandomKind(RandomKind current, RandomKind incoming)
Advance the disabled-randomization lattice.
Definition Firtool.h:77
FirtoolOptions & setVbToBV(bool value)
Definition Firtool.h:250
bool shouldAddMuxPragmas() const
Definition Firtool.h:165
bool shouldEnableAnnotationWarning() const
Definition Firtool.h:158
FirtoolOptions & setEmitAllBindFiles(bool value)
Definition Firtool.h:426
FirtoolOptions & setCkgModuleName(StringRef value)
Definition Firtool.h:351
bool shouldConvertVecOfBundle() const
Definition Firtool.h:151
StringRef getOutputAnnotationFilename() const
Definition Firtool.h:105
bool shouldStripFirDebugInfo() const
Definition Firtool.h:153
FirtoolOptions & setConvertProbesToSignals(bool value)
Definition Firtool.h:213
FirtoolOptions & setIgnoreReadEnableMem(bool value)
Definition Firtool.h:300
FirtoolOptions & setEnableDebugInfo(bool value)
Definition Firtool.h:230
FirtoolOptions & setDisableAnnotationsClassless(bool value)
Definition Firtool.h:203
FirtoolOptions & setDisableLayerSink(bool value)
Definition Firtool.h:240
FirtoolOptions & setEmitSeparateAlwaysBlocks(bool value)
Definition Firtool.h:340
FirtoolOptions & setDisableOptimization(bool value)
Definition Firtool.h:245
std::string outputAnnotationFilename
Definition Firtool.h:469
firrtl::VerificationFlavor verificationFlavor
Definition Firtool.h:474
firrtl::PreserveAggregate::PreserveMode preserveAggregate
Definition Firtool.h:450
FirtoolOptions & setInlineInputOnlyModules(bool value)
Definition Firtool.h:431
FirtoolOptions & setLintXmrsInDesign(bool value)
Definition Firtool.h:421
bool shouldLowerMemories() const
Definition Firtool.h:145
FirtoolOptions & setDisableWireElimination(bool value)
Definition Firtool.h:411
FirtoolOptions & setCompanionMode(firrtl::CompanionMode value)
Definition Firtool.h:265
FirtoolOptions & setWarnOnTruncation(bool value)
Definition Firtool.h:320
FirtoolOptions & setVerificationFlavor(firrtl::VerificationFlavor value)
Definition Firtool.h:335
DomainMode getDomainMode() const
Definition Firtool.h:188
bool getLintStaticAsserts() const
Definition Firtool.h:180
bool shouldLowerNoRefTypePortAnnotations() const
Definition Firtool.h:138
FirtoolOptions & setReplSeqMem(bool value)
Definition Firtool.h:290
verif::SymbolicValueLowering getSymbolicValueLowering() const
Definition Firtool.h:175
FirtoolOptions & setCkgEnableName(StringRef value)
Definition Firtool.h:366
bool shouldUseNewFullResetFlow() const
Definition Firtool.h:150
bool shouldExportModuleHierarchy() const
Definition Firtool.h:154
firrtl::CompanionMode companionMode
Definition Firtool.h:459
FirtoolOptions & setStripDebugInfo(bool value)
Definition Firtool.h:386
FirtoolOptions & setExportModuleHierarchy(bool value)
Definition Firtool.h:376
FirtoolOptions & setDisableUnknownAnnotations(bool disable)
Definition Firtool.h:198
bool shouldDisableWireElimination() const
Definition Firtool.h:178
FirtoolOptions & setEnableAnnotationWarning(bool value)
Definition Firtool.h:315
FirtoolOptions & setReplSeqMemFile(StringRef value)
Definition Firtool.h:295
bool shouldSelectDefaultInstanceChoice() const
Definition Firtool.h:171
FirtoolOptions & setLintStaticAsserts(bool value)
Definition Firtool.h:416
bool shouldInlineInputOnlyModules() const
Definition Firtool.h:186
verif::SymbolicValueLowering symbolicValueLowering
Definition Firtool.h:489
bool getLintXmrsInDesign() const
Definition Firtool.h:182
FirtoolOptions & setSelectDefaultInstanceChoice(bool value)
Definition Firtool.h:401
FirtoolOptions & setStripFirDebugInfo(bool value)
Definition Firtool.h:381
seq::ExternalizeClockGateOptions getClockGateOptions() const
Definition Firtool.h:116
bool shouldEnableDebugInfo() const
Definition Firtool.h:148
bool shouldEmitSeparateAlwaysBlocks() const
Definition Firtool.h:162
static constexpr std::optional< firrtl::InferDomainsMode > toInferDomainsPassMode(DomainMode mode)
Convert the "domain mode" firtool option to a "firrtl::InferDomainsMode", the configuration for a pas...
Definition Firtool.h:56
ArrayRef< std::string > getSkippedDomains() const
Definition Firtool.h:190
FirtoolOptions & setOutputFilename(StringRef name)
Definition Firtool.h:193
FirtoolOptions & setBlackBoxRootPath(StringRef value)
Definition Firtool.h:285
@ None
Don't explicitly preserve any named values.
Definition Passes.h:57
@ Strip
Erase domains from the input circuit.
@ Check
Check domains without inference.
@ Infer
Check domains with inference for private modules.
@ InferAll
Check domains with inference for both public and private modules.
LogicalResult populateLowFIRRTLToHW(mlir::PassManager &pm, const FirtoolOptions &opt, StringRef inputFilename)
Definition Firtool.cpp:251
LogicalResult populateHWToBTOR2(mlir::PassManager &pm, const FirtoolOptions &opt, llvm::raw_ostream &os)
BTOR2 emission pipeline, triggered with --btor2 flag.
Definition Firtool.cpp:468
LogicalResult populateExportSplitVerilog(mlir::PassManager &pm, const FirtoolOptions &opt, llvm::StringRef directory)
Definition Firtool.cpp:443
LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:340
LogicalResult populateExportVerilog(mlir::PassManager &pm, const FirtoolOptions &opt, std::unique_ptr< llvm::raw_ostream > os)
Definition Firtool.cpp:424
LogicalResult populatePreprocessTransforms(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:27
void registerFirtoolCLOptions()
Register a set of useful command-line options that can be used to configure various flags within the ...
Definition Firtool.cpp:863
LogicalResult populateFinalizeIR(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:453
LogicalResult populateCHIRRTLToLowFIRRTL(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:54
SymbolicValueLowering
Ways to lower symbolic values.
Definition VerifPasses.h:29
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.