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 /// 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
71 /// Advance the disabled-randomization lattice. Calling this twice with
72 /// the two individual kinds is equivalent to calling it once with All.
73 static RandomKind mergeRandomKind(RandomKind current, RandomKind incoming) {
74 if (current == RandomKind::None)
75 return incoming;
76 if (current == incoming)
77 return current;
78 return RandomKind::All;
79 }
80
85
87 switch (buildMode) {
88 case BuildModeDebug:
93 return preserveMode;
94 }
95 llvm_unreachable("unknown build mode");
96 }
97
98 StringRef getOutputFilename() const { return outputFilename; }
99 StringRef getBlackBoxRootPath() const { return blackBoxRootPath; }
101 StringRef getOutputAnnotationFilename() const {
103 }
104
109
110 bool getNoViews() const { return noViews; }
111
112 seq::ExternalizeClockGateOptions getClockGateOptions() const {
115 }
116
117 FirtoolOptions &setClockGateOptions(seq::ExternalizeClockGateOptions &opts) {
118 ckgModuleName = opts.moduleName;
119 ckgInputName = opts.inputName;
120 ckgOutputName = opts.outputName;
121 ckgEnableName = opts.enableName;
122 ckgTestEnableName = opts.testEnableName;
123 ckgInstName = opts.instName;
124 return *this;
125 }
126
127 bool isDefaultOutputFilename() const { return outputFilename == "-"; }
141 bool shouldLowerMemories() const { return lowerMemories; }
142 bool shouldDedup() const { return !noDedup; }
143 bool shouldDedupClasses() const { return dedupClasses; }
144 bool shouldEnableDebugInfo() const { return enableDebugInfo; }
146 bool shouldConvertVecOfBundle() const { return vbToBV; }
147 bool shouldStripDebugInfo() const { return stripDebugInfo; }
155 bool shouldLowerToCore() const { return lowerToCore; }
160 bool shouldAddMuxPragmas() const { return addMuxPragmas; }
169
174
176
177 bool getLintXmrsInDesign() const { return lintXmrsInDesign; }
178
179 bool getEmitAllBindFiles() const { return emitAllBindFiles; }
180
182
184
185 bool shouldStripDomain() const { return stripDomain; }
186
187 ArrayRef<std::string> getSkippedDomains() const { return skippedDomains; }
188
189 // Setters, used by the CAPI
191 outputFilename = name;
192 return *this;
193 }
194
197 return *this;
198 }
199
202 return *this;
203 }
204
207 return *this;
208 }
209
211 probesToSignals = value;
212 return *this;
213 }
214
220
223 preserveMode = value;
224 return *this;
225 }
226
228 enableDebugInfo = value;
229 return *this;
230 }
231
233 buildMode = value;
234 return *this;
235 }
236
238 disableLayerSink = value;
239 return *this;
240 }
241
243 disableOptimization = value;
244 return *this;
245 }
246
248 vbToBV = value;
249 return *this;
250 }
251
253 noDedup = value;
254 return *this;
255 }
256
258 dedupClasses = value;
259 return *this;
260 }
261
263 companionMode = value;
264 return *this;
265 }
266
268 noViews = value;
269 return *this;
270 }
271
276
278 lowerMemories = value;
279 return *this;
280 }
281
283 blackBoxRootPath = value;
284 return *this;
285 }
286
288 replSeqMem = value;
289 return *this;
290 }
291
293 replSeqMemFile = value;
294 return *this;
295 }
296
298 ignoreReadEnableMem = value;
299 return *this;
300 }
301
304 return *this;
305 }
306
309 return *this;
310 }
311
313 warnOnTruncation = value;
314 return *this;
315 }
316
318 lowerToCore = value;
319 return *this;
320 }
321
323 addMuxPragmas = value;
324 return *this;
325 }
326
331
334 return *this;
335 }
336
342
344 ckgModuleName = value;
345 return *this;
346 }
347
348 FirtoolOptions &setCkgInputName(StringRef value) {
349 ckgInputName = value;
350 return *this;
351 }
352
354 ckgOutputName = value;
355 return *this;
356 }
357
359 ckgEnableName = value;
360 return *this;
361 }
362
364 ckgTestEnableName = value;
365 return *this;
366 }
367
369 exportModuleHierarchy = value;
370 return *this;
371 }
372
374 stripFirDebugInfo = value;
375 return *this;
376 }
377
379 stripDebugInfo = value;
380 return *this;
381 }
382
384 fixupEICGWrapper = value;
385 return *this;
386 }
387
389 disableCSEinClasses = value;
390 return *this;
391 }
392
395 return *this;
396 }
397
402
405 return *this;
406 }
407
409 lintStaticAsserts = value;
410 return *this;
411 }
412
414 lintXmrsInDesign = value;
415 return *this;
416 }
417
419 emitAllBindFiles = value;
420 return *this;
421 }
422
425 return *this;
426 }
427
429 domainMode = value;
430 return *this;
431 }
432
434 stripDomain = value;
435 return *this;
436 }
437
438private:
439 std::string outputFilename;
440
441 // LowerFIRRTLAnnotations
445
453 bool vbToBV;
460 std::string blackBoxRootPath;
462 std::string replSeqMemFile;
473 std::string ckgModuleName;
474 std::string ckgInputName;
475 std::string ckgOutputName;
476 std::string ckgEnableName;
477 std::string ckgTestEnableName;
478 std::string ckgInstName;
493 SmallVector<std::string> skippedDomains;
494};
495
497
498LogicalResult populatePreprocessTransforms(mlir::PassManager &pm,
499 const FirtoolOptions &opt);
500
501LogicalResult populateCHIRRTLToLowFIRRTL(mlir::PassManager &pm,
502 const FirtoolOptions &opt);
503
504LogicalResult populateLowFIRRTLToHW(mlir::PassManager &pm,
505 const FirtoolOptions &opt,
506 StringRef inputFilename);
507
508LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt);
509
510LogicalResult populateExportVerilog(mlir::PassManager &pm,
511 const FirtoolOptions &opt,
512 std::unique_ptr<llvm::raw_ostream> os);
513
514LogicalResult populateExportVerilog(mlir::PassManager &pm,
515 const FirtoolOptions &opt,
516 llvm::raw_ostream &os);
517
518LogicalResult populateExportSplitVerilog(mlir::PassManager &pm,
519 const FirtoolOptions &opt,
520 llvm::StringRef directory);
521
522LogicalResult populateFinalizeIR(mlir::PassManager &pm,
523 const FirtoolOptions &opt);
524
525LogicalResult populateHWToBTOR2(mlir::PassManager &pm,
526 const FirtoolOptions &opt,
527 llvm::raw_ostream &os);
528
529} // namespace firtool
530} // namespace circt
531
532#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:383
FirtoolOptions & setPreserveAggregate(firrtl::PreserveAggregate::PreserveMode value)
Definition Firtool.h:216
FirtoolOptions & setAddVivadoRAMAddressConflictSynthesisBugWorkaround(bool value)
Definition Firtool.h:338
bool shouldStripDebugInfo() const
Definition Firtool.h:147
FirtoolOptions & setBuildMode(BuildMode value)
Definition Firtool.h:232
FirtoolOptions & setDisableAggressiveMergeConnections(bool value)
Definition Firtool.h:272
FirtoolOptions & setCkgInputName(StringRef value)
Definition Firtool.h:348
firrtl::PreserveAggregate::PreserveMode getPreserveAggregate() const
Definition Firtool.h:105
FirtoolOptions & setLowerToCore(bool value)
Definition Firtool.h:317
bool shouldAddVivadoRAMAddressConflictSynthesisBugWorkaround() const
Definition Firtool.h:161
bool shouldDisableLayerSink() const
Definition Firtool.h:139
firrtl::PreserveValues::PreserveMode preserveMode
Definition Firtool.h:448
FirtoolOptions & setDisableCSEinClasses(bool value)
Definition Firtool.h:388
auto getVerificationFlavor() const
Definition Firtool.h:156
@ 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:117
FirtoolOptions & setCkgTestEnableName(StringRef value)
Definition Firtool.h:363
FirtoolOptions & mergeDisableRandom(RandomKind kind)
Definition Firtool.h:81
bool isDefaultOutputFilename() const
Definition Firtool.h:127
FirtoolOptions & setStripDomain(bool value)
Definition Firtool.h:433
StringRef getOutputFilename() const
Definition Firtool.h:98
FirtoolOptions & setDedupClasses(bool value)
Definition Firtool.h:257
bool shouldDisableAggressiveMergeConnections() const
Definition Firtool.h:150
bool shouldWarnOnTruncation() const
Definition Firtool.h:154
StringRef getReplaceSequentialMemoriesFile() const
Definition Firtool.h:100
bool addVivadoRAMAddressConflictSynthesisBugWorkaround
Definition Firtool.h:472
FirtoolOptions & setSymbolicValueLowering(verif::SymbolicValueLowering mode)
Definition Firtool.h:398
SmallVector< std::string > skippedDomains
Definition Firtool.h:493
FirtoolOptions & setLowerMemories(bool value)
Definition Firtool.h:277
FirtoolOptions & setNoDedup(bool value)
Definition Firtool.h:252
bool shouldFixupEICGWrapper() const
Definition Firtool.h:164
bool shouldConvertProbesToSignals() const
Definition Firtool.h:137
firrtl::PreserveValues::PreserveMode getPreserveMode() const
Definition Firtool.h:86
FirtoolOptions & setLowerAnnotationsNoRefTypePorts(bool value)
Definition Firtool.h:205
bool shouldDedupClasses() const
Definition Firtool.h:143
StringRef getBlackBoxRootPath() const
Definition Firtool.h:99
bool shouldDisableCSEinClasses() const
Definition Firtool.h:165
bool shouldDisableOptimization() const
Definition Firtool.h:140
firrtl::CompanionMode getCompanionMode() const
Definition Firtool.h:108
bool shouldDisableClasslessAnnotations() const
Definition Firtool.h:131
FirtoolOptions & setAddMuxPragmas(bool value)
Definition Firtool.h:322
FirtoolOptions & setPreserveValues(firrtl::PreserveValues::PreserveMode value)
Definition Firtool.h:222
bool getEmitAllBindFiles() const
Definition Firtool.h:179
bool shouldReplaceSequentialMemories() const
Definition Firtool.h:138
FirtoolOptions & setDomainMode(DomainMode value)
Definition Firtool.h:428
bool shouldIgnoreReadEnableMemories() const
Definition Firtool.h:145
FirtoolOptions & setOutputAnnotationFilename(StringRef value)
Definition Firtool.h:302
FirtoolOptions & setCkgOutputName(StringRef value)
Definition Firtool.h:353
bool isRandomEnabled(RandomKind kind) const
Definition Firtool.h:67
bool shouldDisableUnknownAnnotations() const
Definition Firtool.h:128
FirtoolOptions & setNoViews(bool value)
Definition Firtool.h:267
static RandomKind mergeRandomKind(RandomKind current, RandomKind incoming)
Advance the disabled-randomization lattice.
Definition Firtool.h:73
FirtoolOptions & setVbToBV(bool value)
Definition Firtool.h:247
bool shouldAddMuxPragmas() const
Definition Firtool.h:160
bool shouldEnableAnnotationWarning() const
Definition Firtool.h:153
FirtoolOptions & setEmitAllBindFiles(bool value)
Definition Firtool.h:418
FirtoolOptions & setCkgModuleName(StringRef value)
Definition Firtool.h:343
bool shouldConvertVecOfBundle() const
Definition Firtool.h:146
StringRef getOutputAnnotationFilename() const
Definition Firtool.h:101
bool shouldStripFirDebugInfo() const
Definition Firtool.h:148
FirtoolOptions & setConvertProbesToSignals(bool value)
Definition Firtool.h:210
FirtoolOptions & setIgnoreReadEnableMem(bool value)
Definition Firtool.h:297
FirtoolOptions & setEnableDebugInfo(bool value)
Definition Firtool.h:227
FirtoolOptions & setDisableAnnotationsClassless(bool value)
Definition Firtool.h:200
FirtoolOptions & setDisableLayerSink(bool value)
Definition Firtool.h:237
FirtoolOptions & setEmitSeparateAlwaysBlocks(bool value)
Definition Firtool.h:332
FirtoolOptions & setDisableOptimization(bool value)
Definition Firtool.h:242
std::string outputAnnotationFilename
Definition Firtool.h:465
firrtl::VerificationFlavor verificationFlavor
Definition Firtool.h:470
firrtl::PreserveAggregate::PreserveMode preserveAggregate
Definition Firtool.h:447
FirtoolOptions & setInlineInputOnlyModules(bool value)
Definition Firtool.h:423
FirtoolOptions & setLintXmrsInDesign(bool value)
Definition Firtool.h:413
bool shouldLowerMemories() const
Definition Firtool.h:141
FirtoolOptions & setDisableWireElimination(bool value)
Definition Firtool.h:403
FirtoolOptions & setCompanionMode(firrtl::CompanionMode value)
Definition Firtool.h:262
FirtoolOptions & setWarnOnTruncation(bool value)
Definition Firtool.h:312
FirtoolOptions & setVerificationFlavor(firrtl::VerificationFlavor value)
Definition Firtool.h:327
DomainMode getDomainMode() const
Definition Firtool.h:183
bool getLintStaticAsserts() const
Definition Firtool.h:175
bool shouldLowerNoRefTypePortAnnotations() const
Definition Firtool.h:134
FirtoolOptions & setReplSeqMem(bool value)
Definition Firtool.h:287
verif::SymbolicValueLowering getSymbolicValueLowering() const
Definition Firtool.h:170
FirtoolOptions & setCkgEnableName(StringRef value)
Definition Firtool.h:358
bool shouldExportModuleHierarchy() const
Definition Firtool.h:149
firrtl::CompanionMode companionMode
Definition Firtool.h:456
FirtoolOptions & setStripDebugInfo(bool value)
Definition Firtool.h:378
FirtoolOptions & setExportModuleHierarchy(bool value)
Definition Firtool.h:368
FirtoolOptions & setDisableUnknownAnnotations(bool disable)
Definition Firtool.h:195
bool shouldDisableWireElimination() const
Definition Firtool.h:173
FirtoolOptions & setEnableAnnotationWarning(bool value)
Definition Firtool.h:307
FirtoolOptions & setReplSeqMemFile(StringRef value)
Definition Firtool.h:292
bool shouldSelectDefaultInstanceChoice() const
Definition Firtool.h:166
FirtoolOptions & setLintStaticAsserts(bool value)
Definition Firtool.h:408
bool shouldInlineInputOnlyModules() const
Definition Firtool.h:181
verif::SymbolicValueLowering symbolicValueLowering
Definition Firtool.h:485
bool getLintXmrsInDesign() const
Definition Firtool.h:177
FirtoolOptions & setSelectDefaultInstanceChoice(bool value)
Definition Firtool.h:393
FirtoolOptions & setStripFirDebugInfo(bool value)
Definition Firtool.h:373
seq::ExternalizeClockGateOptions getClockGateOptions() const
Definition Firtool.h:112
bool shouldEnableDebugInfo() const
Definition Firtool.h:144
bool shouldEmitSeparateAlwaysBlocks() const
Definition Firtool.h:157
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
ArrayRef< std::string > getSkippedDomains() const
Definition Firtool.h:187
FirtoolOptions & setOutputFilename(StringRef name)
Definition Firtool.h:190
FirtoolOptions & setBlackBoxRootPath(StringRef value)
Definition Firtool.h:282
@ None
Don't explicitly preserve any named values.
Definition Passes.h:58
@ 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:248
LogicalResult populateHWToBTOR2(mlir::PassManager &pm, const FirtoolOptions &opt, llvm::raw_ostream &os)
BTOR2 emission pipeline, triggered with --btor2 flag.
Definition Firtool.cpp:465
LogicalResult populateExportSplitVerilog(mlir::PassManager &pm, const FirtoolOptions &opt, llvm::StringRef directory)
Definition Firtool.cpp:440
LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:337
LogicalResult populateExportVerilog(mlir::PassManager &pm, const FirtoolOptions &opt, std::unique_ptr< llvm::raw_ostream > os)
Definition Firtool.cpp:421
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:859
LogicalResult populateFinalizeIR(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:450
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.