CIRCT 23.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
76 switch (buildMode) {
77 case BuildModeDebug:
82 return preserveMode;
83 }
84 llvm_unreachable("unknown build mode");
85 }
86
87 StringRef getOutputFilename() const { return outputFilename; }
88 StringRef getBlackBoxRootPath() const { return blackBoxRootPath; }
90 StringRef getOutputAnnotationFilename() const {
92 }
93
98
99 bool getNoViews() const { return noViews; }
100
101 seq::ExternalizeClockGateOptions getClockGateOptions() const {
104 }
105
106 FirtoolOptions &setClockGateOptions(seq::ExternalizeClockGateOptions &opts) {
107 ckgModuleName = opts.moduleName;
108 ckgInputName = opts.inputName;
109 ckgOutputName = opts.outputName;
110 ckgEnableName = opts.enableName;
111 ckgTestEnableName = opts.testEnableName;
112 ckgInstName = opts.instName;
113 return *this;
114 }
115
116 bool isDefaultOutputFilename() const { return outputFilename == "-"; }
130 bool shouldLowerMemories() const { return lowerMemories; }
131 bool shouldDedup() const { return !noDedup; }
132 bool shouldDedupClasses() const { return dedupClasses; }
133 bool shouldEnableDebugInfo() const { return enableDebugInfo; }
135 bool shouldConvertVecOfBundle() const { return vbToBV; }
145 bool shouldStripDebugInfo() const { return stripDebugInfo; }
156 bool shouldAddMuxPragmas() const { return addMuxPragmas; }
160 bool shouldExtractTestCode() const { return extractTestCode; }
166
171
173
174 bool getLintXmrsInDesign() const { return lintXmrsInDesign; }
175
176 bool getEmitAllBindFiles() const { return emitAllBindFiles; }
177
179
181
182 // Setters, used by the CAPI
184 outputFilename = name;
185 return *this;
186 }
187
190 return *this;
191 }
192
195 return *this;
196 }
197
200 return *this;
201 }
202
204 probesToSignals = value;
205 return *this;
206 }
207
213
216 preserveMode = value;
217 return *this;
218 }
219
221 enableDebugInfo = value;
222 return *this;
223 }
224
226 buildMode = value;
227 return *this;
228 }
229
231 disableLayerSink = value;
232 return *this;
233 }
234
236 disableOptimization = value;
237 return *this;
238 }
239
241 vbToBV = value;
242 return *this;
243 }
244
246 noDedup = value;
247 return *this;
248 }
249
251 dedupClasses = value;
252 return *this;
253 }
254
256 companionMode = value;
257 return *this;
258 }
259
261 noViews = value;
262 return *this;
263 }
264
269
271 lowerMemories = value;
272 return *this;
273 }
274
276 blackBoxRootPath = value;
277 return *this;
278 }
279
281 replSeqMem = value;
282 return *this;
283 }
284
286 replSeqMemFile = value;
287 return *this;
288 }
289
291 extractTestCode = value;
292 return *this;
293 }
294
296 ignoreReadEnableMem = value;
297 return *this;
298 }
299
301 disableRandom = value;
302 return *this;
303 }
304
307 return *this;
308 }
309
312 return *this;
313 }
314
316 addMuxPragmas = value;
317 return *this;
318 }
319
324
327 return *this;
328 }
329
332 return *this;
333 }
334
337 return *this;
338 }
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;
478 std::string ckgModuleName;
479 std::string ckgInputName;
480 std::string ckgOutputName;
481 std::string ckgEnableName;
482 std::string ckgTestEnableName;
483 std::string ckgInstName;
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:209
FirtoolOptions & setAddVivadoRAMAddressConflictSynthesisBugWorkaround(bool value)
Definition Firtool.h:346
bool shouldStripDebugInfo() const
Definition Firtool.h:145
FirtoolOptions & setBuildMode(BuildMode value)
Definition Firtool.h:225
FirtoolOptions & setDisableAggressiveMergeConnections(bool value)
Definition Firtool.h:265
FirtoolOptions & setCkgInputName(StringRef value)
Definition Firtool.h:356
firrtl::PreserveAggregate::PreserveMode getPreserveAggregate() const
Definition Firtool.h:94
bool shouldAddVivadoRAMAddressConflictSynthesisBugWorkaround() const
Definition Firtool.h:157
bool shouldDisableLayerSink() const
Definition Firtool.h:128
firrtl::PreserveValues::PreserveMode preserveMode
Definition Firtool.h:451
FirtoolOptions & setDisableCSEinClasses(bool value)
Definition Firtool.h:396
auto getVerificationFlavor() const
Definition Firtool.h:152
@ 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:106
FirtoolOptions & setCkgTestEnableName(StringRef value)
Definition Firtool.h:371
bool isDefaultOutputFilename() const
Definition Firtool.h:116
StringRef getOutputFilename() const
Definition Firtool.h:87
FirtoolOptions & setDedupClasses(bool value)
Definition Firtool.h:250
bool shouldDisableAggressiveMergeConnections() const
Definition Firtool.h:148
StringRef getReplaceSequentialMemoriesFile() const
Definition Firtool.h:89
bool addVivadoRAMAddressConflictSynthesisBugWorkaround
Definition Firtool.h:477
FirtoolOptions & setSymbolicValueLowering(verif::SymbolicValueLowering mode)
Definition Firtool.h:406
FirtoolOptions & setLowerMemories(bool value)
Definition Firtool.h:270
FirtoolOptions & setDisableRandom(RandomKind value)
Definition Firtool.h:300
bool shouldExtractTestCode() const
Definition Firtool.h:160
FirtoolOptions & setNoDedup(bool value)
Definition Firtool.h:245
bool shouldFixupEICGWrapper() const
Definition Firtool.h:161
bool shouldConvertProbesToSignals() const
Definition Firtool.h:126
firrtl::PreserveValues::PreserveMode getPreserveMode() const
Definition Firtool.h:75
FirtoolOptions & setLowerAnnotationsNoRefTypePorts(bool value)
Definition Firtool.h:198
bool shouldDedupClasses() const
Definition Firtool.h:132
StringRef getBlackBoxRootPath() const
Definition Firtool.h:88
bool shouldDisableCSEinClasses() const
Definition Firtool.h:162
bool shouldDisableOptimization() const
Definition Firtool.h:129
firrtl::CompanionMode getCompanionMode() const
Definition Firtool.h:97
bool shouldDisableClasslessAnnotations() const
Definition Firtool.h:120
FirtoolOptions & setAddMuxPragmas(bool value)
Definition Firtool.h:315
FirtoolOptions & setPreserveValues(firrtl::PreserveValues::PreserveMode value)
Definition Firtool.h:215
bool getEmitAllBindFiles() const
Definition Firtool.h:176
bool shouldReplaceSequentialMemories() const
Definition Firtool.h:127
FirtoolOptions & setDomainMode(DomainMode value)
Definition Firtool.h:436
bool shouldIgnoreReadEnableMemories() const
Definition Firtool.h:134
FirtoolOptions & setEtcDisableInstanceExtraction(bool value)
Definition Firtool.h:330
FirtoolOptions & setOutputAnnotationFilename(StringRef value)
Definition Firtool.h:305
FirtoolOptions & setCkgOutputName(StringRef value)
Definition Firtool.h:361
bool isRandomEnabled(RandomKind kind) const
Definition Firtool.h:71
bool shouldDisableUnknownAnnotations() const
Definition Firtool.h:117
FirtoolOptions & setNoViews(bool value)
Definition Firtool.h:260
FirtoolOptions & setVbToBV(bool value)
Definition Firtool.h:240
bool shouldAddMuxPragmas() const
Definition Firtool.h:156
bool shouldEnableAnnotationWarning() const
Definition Firtool.h:151
FirtoolOptions & setEmitAllBindFiles(bool value)
Definition Firtool.h:426
bool shouldEtcDisableInstanceExtraction() const
Definition Firtool.h:136
FirtoolOptions & setCkgModuleName(StringRef value)
Definition Firtool.h:351
bool shouldConvertVecOfBundle() const
Definition Firtool.h:135
StringRef getOutputAnnotationFilename() const
Definition Firtool.h:90
bool shouldStripFirDebugInfo() const
Definition Firtool.h:146
FirtoolOptions & setConvertProbesToSignals(bool value)
Definition Firtool.h:203
bool shouldEtcDisableRegisterExtraction() const
Definition Firtool.h:139
FirtoolOptions & setEtcDisableModuleInlining(bool value)
Definition Firtool.h:340
FirtoolOptions & setIgnoreReadEnableMem(bool value)
Definition Firtool.h:295
FirtoolOptions & setEnableDebugInfo(bool value)
Definition Firtool.h:220
FirtoolOptions & setDisableAnnotationsClassless(bool value)
Definition Firtool.h:193
FirtoolOptions & setDisableLayerSink(bool value)
Definition Firtool.h:230
FirtoolOptions & setEmitSeparateAlwaysBlocks(bool value)
Definition Firtool.h:325
FirtoolOptions & setDisableOptimization(bool value)
Definition Firtool.h:235
FirtoolOptions & setExtractTestCode(bool value)
Definition Firtool.h:290
std::string outputAnnotationFilename
Definition Firtool.h:469
firrtl::VerificationFlavor verificationFlavor
Definition Firtool.h:472
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:130
FirtoolOptions & setDisableWireElimination(bool value)
Definition Firtool.h:411
bool shouldEtcDisableModuleInlining() const
Definition Firtool.h:142
FirtoolOptions & setCompanionMode(firrtl::CompanionMode value)
Definition Firtool.h:255
FirtoolOptions & setVerificationFlavor(firrtl::VerificationFlavor value)
Definition Firtool.h:320
DomainMode getDomainMode() const
Definition Firtool.h:180
bool getLintStaticAsserts() const
Definition Firtool.h:172
bool shouldLowerNoRefTypePortAnnotations() const
Definition Firtool.h:123
FirtoolOptions & setReplSeqMem(bool value)
Definition Firtool.h:280
verif::SymbolicValueLowering getSymbolicValueLowering() const
Definition Firtool.h:167
FirtoolOptions & setCkgEnableName(StringRef value)
Definition Firtool.h:366
bool shouldExportModuleHierarchy() const
Definition Firtool.h:147
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:188
bool shouldDisableWireElimination() const
Definition Firtool.h:170
FirtoolOptions & setEnableAnnotationWarning(bool value)
Definition Firtool.h:310
FirtoolOptions & setEtcDisableRegisterExtraction(bool value)
Definition Firtool.h:335
FirtoolOptions & setReplSeqMemFile(StringRef value)
Definition Firtool.h:285
bool shouldSelectDefaultInstanceChoice() const
Definition Firtool.h:163
FirtoolOptions & setLintStaticAsserts(bool value)
Definition Firtool.h:416
bool shouldInlineInputOnlyModules() const
Definition Firtool.h:178
verif::SymbolicValueLowering symbolicValueLowering
Definition Firtool.h:490
bool getLintXmrsInDesign() const
Definition Firtool.h:174
FirtoolOptions & setSelectDefaultInstanceChoice(bool value)
Definition Firtool.h:401
FirtoolOptions & setStripFirDebugInfo(bool value)
Definition Firtool.h:381
seq::ExternalizeClockGateOptions getClockGateOptions() const
Definition Firtool.h:101
bool shouldEnableDebugInfo() const
Definition Firtool.h:133
bool shouldEmitSeparateAlwaysBlocks() const
Definition Firtool.h:153
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
FirtoolOptions & setOutputFilename(StringRef name)
Definition Firtool.h:183
FirtoolOptions & setBlackBoxRootPath(StringRef value)
Definition Firtool.h:275
@ None
Don't explicitly preserve any named values.
Definition Passes.h:52
@ 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:232
LogicalResult populateHWToBTOR2(mlir::PassManager &pm, const FirtoolOptions &opt, llvm::raw_ostream &os)
Definition Firtool.cpp:452
LogicalResult populateExportSplitVerilog(mlir::PassManager &pm, const FirtoolOptions &opt, llvm::StringRef directory)
Definition Firtool.cpp:434
LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:319
LogicalResult populateExportVerilog(mlir::PassManager &pm, const FirtoolOptions &opt, std::unique_ptr< llvm::raw_ostream > os)
Definition Firtool.cpp:415
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:813
LogicalResult populateFinalizeIR(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:444
LogicalResult populateCHIRRTLToLowFIRRTL(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:57
SymbolicValueLowering
Ways to lower symbolic values.
Definition VerifPasses.h:29
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.