CIRCT 22.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 /// Disable domain checking.
42 Disable,
43 /// Check domains without inference.
44 Check,
45 /// Check domains with inference for private modules.
46 Infer,
47 /// Check domains with inference for both public and private modules.
49 };
50
51 /// Convert the "domain mode" firtool option to a "firrtl::InferDomainsMode",
52 /// the configuration for a pass.
53 static constexpr std::optional<firrtl::InferDomainsMode>
55 switch (mode) {
57 return std::nullopt;
64 }
65 }
66
67 bool isRandomEnabled(RandomKind kind) const {
68 return disableRandom != RandomKind::All && disableRandom != kind;
69 }
70
72 switch (buildMode) {
73 case BuildModeDebug:
78 return preserveMode;
79 }
80 llvm_unreachable("unknown build mode");
81 }
82
83 StringRef getOutputFilename() const { return outputFilename; }
84 StringRef getBlackBoxRootPath() const { return blackBoxRootPath; }
86 StringRef getOutputAnnotationFilename() const {
88 }
89
94
95 bool getNoViews() const { return noViews; }
96
97 seq::ExternalizeClockGateOptions getClockGateOptions() const {
100 }
101
102 FirtoolOptions &setClockGateOptions(seq::ExternalizeClockGateOptions &opts) {
103 ckgModuleName = opts.moduleName;
104 ckgInputName = opts.inputName;
105 ckgOutputName = opts.outputName;
106 ckgEnableName = opts.enableName;
107 ckgTestEnableName = opts.testEnableName;
108 ckgInstName = opts.instName;
109 return *this;
110 }
111
112 bool isDefaultOutputFilename() const { return outputFilename == "-"; }
126 bool shouldLowerMemories() const { return lowerMemories; }
127 bool shouldDedup() const { return !noDedup; }
128 bool shouldDedupClasses() const { return dedupClasses; }
129 bool shouldEnableDebugInfo() const { return enableDebugInfo; }
131 bool shouldConvertVecOfBundle() const { return vbToBV; }
141 bool shouldStripDebugInfo() const { return stripDebugInfo; }
152 bool shouldAddMuxPragmas() const { return addMuxPragmas; }
156 bool shouldExtractTestCode() const { return extractTestCode; }
162
167
169
170 bool getLintXmrsInDesign() const { return lintXmrsInDesign; }
171
172 bool getEmitAllBindFiles() const { return emitAllBindFiles; }
173
175
177
178 // Setters, used by the CAPI
180 outputFilename = name;
181 return *this;
182 }
183
186 return *this;
187 }
188
191 return *this;
192 }
193
196 return *this;
197 }
198
200 probesToSignals = value;
201 return *this;
202 }
203
209
212 preserveMode = value;
213 return *this;
214 }
215
217 enableDebugInfo = value;
218 return *this;
219 }
220
222 buildMode = value;
223 return *this;
224 }
225
227 disableLayerSink = value;
228 return *this;
229 }
230
232 disableOptimization = value;
233 return *this;
234 }
235
237 vbToBV = value;
238 return *this;
239 }
240
242 noDedup = value;
243 return *this;
244 }
245
247 dedupClasses = value;
248 return *this;
249 }
250
252 companionMode = value;
253 return *this;
254 }
255
257 noViews = value;
258 return *this;
259 }
260
265
267 lowerMemories = value;
268 return *this;
269 }
270
272 blackBoxRootPath = value;
273 return *this;
274 }
275
277 replSeqMem = value;
278 return *this;
279 }
280
282 replSeqMemFile = value;
283 return *this;
284 }
285
287 extractTestCode = value;
288 return *this;
289 }
290
292 ignoreReadEnableMem = value;
293 return *this;
294 }
295
297 disableRandom = value;
298 return *this;
299 }
300
303 return *this;
304 }
305
308 return *this;
309 }
310
312 addMuxPragmas = value;
313 return *this;
314 }
315
320
323 return *this;
324 }
325
328 return *this;
329 }
330
333 return *this;
334 }
335
338 return *this;
339 }
340
346
348 ckgModuleName = value;
349 return *this;
350 }
351
352 FirtoolOptions &setCkgInputName(StringRef value) {
353 ckgInputName = value;
354 return *this;
355 }
356
358 ckgOutputName = value;
359 return *this;
360 }
361
363 ckgEnableName = value;
364 return *this;
365 }
366
368 ckgTestEnableName = value;
369 return *this;
370 }
371
373 exportModuleHierarchy = value;
374 return *this;
375 }
376
378 stripFirDebugInfo = value;
379 return *this;
380 }
381
383 stripDebugInfo = value;
384 return *this;
385 }
386
388 fixupEICGWrapper = value;
389 return *this;
390 }
391
393 disableCSEinClasses = value;
394 return *this;
395 }
396
399 return *this;
400 }
401
406
409 return *this;
410 }
411
413 lintStaticAsserts = value;
414 return *this;
415 }
416
418 lintXmrsInDesign = value;
419 return *this;
420 }
421
423 emitAllBindFiles = value;
424 return *this;
425 }
426
429 return *this;
430 }
431
433 domainMode = value;
434 return *this;
435 }
436
437private:
438 std::string outputFilename;
439
440 // LowerFIRRTLAnnotations
444
452 bool vbToBV;
459 std::string blackBoxRootPath;
461 std::string replSeqMemFile;
474 std::string ckgModuleName;
475 std::string ckgInputName;
476 std::string ckgOutputName;
477 std::string ckgEnableName;
478 std::string ckgTestEnableName;
479 std::string ckgInstName;
493};
494
496
497LogicalResult populatePreprocessTransforms(mlir::PassManager &pm,
498 const FirtoolOptions &opt);
499
500LogicalResult populateCHIRRTLToLowFIRRTL(mlir::PassManager &pm,
501 const FirtoolOptions &opt);
502
503LogicalResult populateLowFIRRTLToHW(mlir::PassManager &pm,
504 const FirtoolOptions &opt,
505 StringRef inputFilename);
506
507LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt);
508
509LogicalResult populateExportVerilog(mlir::PassManager &pm,
510 const FirtoolOptions &opt,
511 std::unique_ptr<llvm::raw_ostream> os);
512
513LogicalResult populateExportVerilog(mlir::PassManager &pm,
514 const FirtoolOptions &opt,
515 llvm::raw_ostream &os);
516
517LogicalResult populateExportSplitVerilog(mlir::PassManager &pm,
518 const FirtoolOptions &opt,
519 llvm::StringRef directory);
520
521LogicalResult populateFinalizeIR(mlir::PassManager &pm,
522 const FirtoolOptions &opt);
523
524LogicalResult populateHWToBTOR2(mlir::PassManager &pm,
525 const FirtoolOptions &opt,
526 llvm::raw_ostream &os);
527
528} // namespace firtool
529} // namespace circt
530
531#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:387
FirtoolOptions & setPreserveAggregate(firrtl::PreserveAggregate::PreserveMode value)
Definition Firtool.h:205
FirtoolOptions & setAddVivadoRAMAddressConflictSynthesisBugWorkaround(bool value)
Definition Firtool.h:342
bool shouldStripDebugInfo() const
Definition Firtool.h:141
FirtoolOptions & setBuildMode(BuildMode value)
Definition Firtool.h:221
FirtoolOptions & setDisableAggressiveMergeConnections(bool value)
Definition Firtool.h:261
FirtoolOptions & setCkgInputName(StringRef value)
Definition Firtool.h:352
firrtl::PreserveAggregate::PreserveMode getPreserveAggregate() const
Definition Firtool.h:90
bool shouldAddVivadoRAMAddressConflictSynthesisBugWorkaround() const
Definition Firtool.h:153
bool shouldDisableLayerSink() const
Definition Firtool.h:124
firrtl::PreserveValues::PreserveMode preserveMode
Definition Firtool.h:447
FirtoolOptions & setDisableCSEinClasses(bool value)
Definition Firtool.h:392
auto getVerificationFlavor() const
Definition Firtool.h:148
@ 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:102
FirtoolOptions & setCkgTestEnableName(StringRef value)
Definition Firtool.h:367
bool isDefaultOutputFilename() const
Definition Firtool.h:112
StringRef getOutputFilename() const
Definition Firtool.h:83
FirtoolOptions & setDedupClasses(bool value)
Definition Firtool.h:246
bool shouldDisableAggressiveMergeConnections() const
Definition Firtool.h:144
StringRef getReplaceSequentialMemoriesFile() const
Definition Firtool.h:85
bool addVivadoRAMAddressConflictSynthesisBugWorkaround
Definition Firtool.h:473
FirtoolOptions & setSymbolicValueLowering(verif::SymbolicValueLowering mode)
Definition Firtool.h:402
FirtoolOptions & setLowerMemories(bool value)
Definition Firtool.h:266
FirtoolOptions & setDisableRandom(RandomKind value)
Definition Firtool.h:296
bool shouldExtractTestCode() const
Definition Firtool.h:156
FirtoolOptions & setNoDedup(bool value)
Definition Firtool.h:241
bool shouldFixupEICGWrapper() const
Definition Firtool.h:157
bool shouldConvertProbesToSignals() const
Definition Firtool.h:122
firrtl::PreserveValues::PreserveMode getPreserveMode() const
Definition Firtool.h:71
FirtoolOptions & setLowerAnnotationsNoRefTypePorts(bool value)
Definition Firtool.h:194
bool shouldDedupClasses() const
Definition Firtool.h:128
StringRef getBlackBoxRootPath() const
Definition Firtool.h:84
bool shouldDisableCSEinClasses() const
Definition Firtool.h:158
bool shouldDisableOptimization() const
Definition Firtool.h:125
firrtl::CompanionMode getCompanionMode() const
Definition Firtool.h:93
bool shouldDisableClasslessAnnotations() const
Definition Firtool.h:116
FirtoolOptions & setAddMuxPragmas(bool value)
Definition Firtool.h:311
FirtoolOptions & setPreserveValues(firrtl::PreserveValues::PreserveMode value)
Definition Firtool.h:211
bool getEmitAllBindFiles() const
Definition Firtool.h:172
bool shouldReplaceSequentialMemories() const
Definition Firtool.h:123
FirtoolOptions & setDomainMode(DomainMode value)
Definition Firtool.h:432
bool shouldIgnoreReadEnableMemories() const
Definition Firtool.h:130
FirtoolOptions & setEtcDisableInstanceExtraction(bool value)
Definition Firtool.h:326
FirtoolOptions & setOutputAnnotationFilename(StringRef value)
Definition Firtool.h:301
FirtoolOptions & setCkgOutputName(StringRef value)
Definition Firtool.h:357
bool isRandomEnabled(RandomKind kind) const
Definition Firtool.h:67
bool shouldDisableUnknownAnnotations() const
Definition Firtool.h:113
FirtoolOptions & setNoViews(bool value)
Definition Firtool.h:256
FirtoolOptions & setVbToBV(bool value)
Definition Firtool.h:236
bool shouldAddMuxPragmas() const
Definition Firtool.h:152
bool shouldEnableAnnotationWarning() const
Definition Firtool.h:147
FirtoolOptions & setEmitAllBindFiles(bool value)
Definition Firtool.h:422
bool shouldEtcDisableInstanceExtraction() const
Definition Firtool.h:132
FirtoolOptions & setCkgModuleName(StringRef value)
Definition Firtool.h:347
bool shouldConvertVecOfBundle() const
Definition Firtool.h:131
StringRef getOutputAnnotationFilename() const
Definition Firtool.h:86
bool shouldStripFirDebugInfo() const
Definition Firtool.h:142
FirtoolOptions & setConvertProbesToSignals(bool value)
Definition Firtool.h:199
bool shouldEtcDisableRegisterExtraction() const
Definition Firtool.h:135
FirtoolOptions & setEtcDisableModuleInlining(bool value)
Definition Firtool.h:336
FirtoolOptions & setIgnoreReadEnableMem(bool value)
Definition Firtool.h:291
FirtoolOptions & setEnableDebugInfo(bool value)
Definition Firtool.h:216
FirtoolOptions & setDisableAnnotationsClassless(bool value)
Definition Firtool.h:189
FirtoolOptions & setDisableLayerSink(bool value)
Definition Firtool.h:226
FirtoolOptions & setEmitSeparateAlwaysBlocks(bool value)
Definition Firtool.h:321
FirtoolOptions & setDisableOptimization(bool value)
Definition Firtool.h:231
FirtoolOptions & setExtractTestCode(bool value)
Definition Firtool.h:286
std::string outputAnnotationFilename
Definition Firtool.h:465
firrtl::VerificationFlavor verificationFlavor
Definition Firtool.h:468
firrtl::PreserveAggregate::PreserveMode preserveAggregate
Definition Firtool.h:446
FirtoolOptions & setInlineInputOnlyModules(bool value)
Definition Firtool.h:427
FirtoolOptions & setLintXmrsInDesign(bool value)
Definition Firtool.h:417
bool shouldLowerMemories() const
Definition Firtool.h:126
FirtoolOptions & setDisableWireElimination(bool value)
Definition Firtool.h:407
bool shouldEtcDisableModuleInlining() const
Definition Firtool.h:138
FirtoolOptions & setCompanionMode(firrtl::CompanionMode value)
Definition Firtool.h:251
FirtoolOptions & setVerificationFlavor(firrtl::VerificationFlavor value)
Definition Firtool.h:316
DomainMode getDomainMode() const
Definition Firtool.h:176
bool getLintStaticAsserts() const
Definition Firtool.h:168
bool shouldLowerNoRefTypePortAnnotations() const
Definition Firtool.h:119
FirtoolOptions & setReplSeqMem(bool value)
Definition Firtool.h:276
verif::SymbolicValueLowering getSymbolicValueLowering() const
Definition Firtool.h:163
FirtoolOptions & setCkgEnableName(StringRef value)
Definition Firtool.h:362
bool shouldExportModuleHierarchy() const
Definition Firtool.h:143
firrtl::CompanionMode companionMode
Definition Firtool.h:455
FirtoolOptions & setStripDebugInfo(bool value)
Definition Firtool.h:382
FirtoolOptions & setExportModuleHierarchy(bool value)
Definition Firtool.h:372
FirtoolOptions & setDisableUnknownAnnotations(bool disable)
Definition Firtool.h:184
bool shouldDisableWireElimination() const
Definition Firtool.h:166
FirtoolOptions & setEnableAnnotationWarning(bool value)
Definition Firtool.h:306
FirtoolOptions & setEtcDisableRegisterExtraction(bool value)
Definition Firtool.h:331
FirtoolOptions & setReplSeqMemFile(StringRef value)
Definition Firtool.h:281
bool shouldSelectDefaultInstanceChoice() const
Definition Firtool.h:159
FirtoolOptions & setLintStaticAsserts(bool value)
Definition Firtool.h:412
bool shouldInlineInputOnlyModules() const
Definition Firtool.h:174
verif::SymbolicValueLowering symbolicValueLowering
Definition Firtool.h:486
bool getLintXmrsInDesign() const
Definition Firtool.h:170
FirtoolOptions & setSelectDefaultInstanceChoice(bool value)
Definition Firtool.h:397
FirtoolOptions & setStripFirDebugInfo(bool value)
Definition Firtool.h:377
seq::ExternalizeClockGateOptions getClockGateOptions() const
Definition Firtool.h:97
bool shouldEnableDebugInfo() const
Definition Firtool.h:129
bool shouldEmitSeparateAlwaysBlocks() const
Definition Firtool.h:149
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:54
FirtoolOptions & setOutputFilename(StringRef name)
Definition Firtool.h:179
FirtoolOptions & setBlackBoxRootPath(StringRef value)
Definition Firtool.h:271
@ None
Don't explicitly preserve any named values.
Definition Passes.h:52
@ 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:811
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.