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.
43 /// Check domains without inference.
45 /// Check domains with inference for private modules.
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 shouldEnableDebugInfo() const { return enableDebugInfo; }
145 bool shouldConvertVecOfBundle() const { return vbToBV; }
146 bool shouldStripDebugInfo() const { return stripDebugInfo; }
154 bool shouldLowerToCore() const { return lowerToCore; }
159 bool shouldAddMuxPragmas() const { return addMuxPragmas; }
168
173
175
176 bool getLintXmrsInDesign() const { return lintXmrsInDesign; }
177
178 bool getEmitAllBindFiles() const { return emitAllBindFiles; }
179
181
183
184 bool shouldStripDomain() const { return stripDomain; }
185
186 ArrayRef<std::string> getSkippedDomains() const { return skippedDomains; }
187
188 // Setters, used by the CAPI
190 outputFilename = name;
191 return *this;
192 }
193
196 return *this;
197 }
198
201 return *this;
202 }
203
206 return *this;
207 }
208
210 probesToSignals = value;
211 return *this;
212 }
213
219
222 preserveMode = value;
223 return *this;
224 }
225
227 enableDebugInfo = value;
228 return *this;
229 }
230
232 buildMode = value;
233 return *this;
234 }
235
237 disableLayerSink = value;
238 return *this;
239 }
240
242 disableOptimization = value;
243 return *this;
244 }
245
247 vbToBV = value;
248 return *this;
249 }
250
252 noDedup = value;
253 return *this;
254 }
255
257 companionMode = value;
258 return *this;
259 }
260
262 noViews = value;
263 return *this;
264 }
265
270
272 lowerMemories = value;
273 return *this;
274 }
275
277 blackBoxRootPath = value;
278 return *this;
279 }
280
282 replSeqMem = value;
283 return *this;
284 }
285
287 replSeqMemFile = value;
288 return *this;
289 }
290
292 ignoreReadEnableMem = value;
293 return *this;
294 }
295
298 return *this;
299 }
300
303 return *this;
304 }
305
307 warnOnTruncation = value;
308 return *this;
309 }
310
312 lowerToCore = value;
313 return *this;
314 }
315
317 addMuxPragmas = value;
318 return *this;
319 }
320
325
328 return *this;
329 }
330
336
338 ckgModuleName = value;
339 return *this;
340 }
341
342 FirtoolOptions &setCkgInputName(StringRef value) {
343 ckgInputName = value;
344 return *this;
345 }
346
348 ckgOutputName = value;
349 return *this;
350 }
351
353 ckgEnableName = value;
354 return *this;
355 }
356
358 ckgTestEnableName = value;
359 return *this;
360 }
361
363 exportModuleHierarchy = value;
364 return *this;
365 }
366
368 stripFirDebugInfo = value;
369 return *this;
370 }
371
373 stripDebugInfo = value;
374 return *this;
375 }
376
378 fixupEICGWrapper = value;
379 return *this;
380 }
381
383 disableCSEinClasses = value;
384 return *this;
385 }
386
389 return *this;
390 }
391
396
399 return *this;
400 }
401
403 lintStaticAsserts = value;
404 return *this;
405 }
406
408 lintXmrsInDesign = value;
409 return *this;
410 }
411
413 emitAllBindFiles = value;
414 return *this;
415 }
416
419 return *this;
420 }
421
423 domainMode = value;
424 return *this;
425 }
426
428 stripDomain = value;
429 return *this;
430 }
431
432private:
433 std::string outputFilename;
434
435 // LowerFIRRTLAnnotations
439
447 bool vbToBV;
453 std::string blackBoxRootPath;
455 std::string replSeqMemFile;
466 std::string ckgModuleName;
467 std::string ckgInputName;
468 std::string ckgOutputName;
469 std::string ckgEnableName;
470 std::string ckgTestEnableName;
471 std::string ckgInstName;
486 SmallVector<std::string> skippedDomains;
487};
488
490
491LogicalResult populatePreprocessTransforms(mlir::PassManager &pm,
492 const FirtoolOptions &opt);
493
494LogicalResult populateCHIRRTLToLowFIRRTL(mlir::PassManager &pm,
495 const FirtoolOptions &opt);
496
497LogicalResult populateLowFIRRTLToHW(mlir::PassManager &pm,
498 const FirtoolOptions &opt,
499 StringRef inputFilename);
500
501LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt);
502
503LogicalResult populateExportVerilog(mlir::PassManager &pm,
504 const FirtoolOptions &opt,
505 std::unique_ptr<llvm::raw_ostream> os);
506
507LogicalResult populateExportVerilog(mlir::PassManager &pm,
508 const FirtoolOptions &opt,
509 llvm::raw_ostream &os);
510
511LogicalResult populateExportSplitVerilog(mlir::PassManager &pm,
512 const FirtoolOptions &opt,
513 llvm::StringRef directory);
514
515LogicalResult populateFinalizeIR(mlir::PassManager &pm,
516 const FirtoolOptions &opt);
517
518LogicalResult populateHWToBTOR2(mlir::PassManager &pm,
519 const FirtoolOptions &opt,
520 llvm::raw_ostream &os);
521
522} // namespace firtool
523} // namespace circt
524
525#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:377
FirtoolOptions & setPreserveAggregate(firrtl::PreserveAggregate::PreserveMode value)
Definition Firtool.h:215
FirtoolOptions & setAddVivadoRAMAddressConflictSynthesisBugWorkaround(bool value)
Definition Firtool.h:332
bool shouldStripDebugInfo() const
Definition Firtool.h:146
FirtoolOptions & setBuildMode(BuildMode value)
Definition Firtool.h:231
FirtoolOptions & setDisableAggressiveMergeConnections(bool value)
Definition Firtool.h:266
FirtoolOptions & setCkgInputName(StringRef value)
Definition Firtool.h:342
firrtl::PreserveAggregate::PreserveMode getPreserveAggregate() const
Definition Firtool.h:105
FirtoolOptions & setLowerToCore(bool value)
Definition Firtool.h:311
bool shouldAddVivadoRAMAddressConflictSynthesisBugWorkaround() const
Definition Firtool.h:160
bool shouldDisableLayerSink() const
Definition Firtool.h:139
firrtl::PreserveValues::PreserveMode preserveMode
Definition Firtool.h:442
FirtoolOptions & setDisableCSEinClasses(bool value)
Definition Firtool.h:382
auto getVerificationFlavor() const
Definition Firtool.h:155
@ Check
Check domains without inference.
Definition Firtool.h:44
@ Infer
Check domains with inference for private modules.
Definition Firtool.h:46
@ Disable
Disable domain checking.
Definition Firtool.h:42
@ InferAll
Check domains with inference for both public and private modules.
Definition Firtool.h:48
FirtoolOptions & setClockGateOptions(seq::ExternalizeClockGateOptions &opts)
Definition Firtool.h:117
FirtoolOptions & setCkgTestEnableName(StringRef value)
Definition Firtool.h:357
FirtoolOptions & mergeDisableRandom(RandomKind kind)
Definition Firtool.h:81
bool isDefaultOutputFilename() const
Definition Firtool.h:127
FirtoolOptions & setStripDomain(bool value)
Definition Firtool.h:427
StringRef getOutputFilename() const
Definition Firtool.h:98
bool shouldDisableAggressiveMergeConnections() const
Definition Firtool.h:149
bool shouldWarnOnTruncation() const
Definition Firtool.h:153
StringRef getReplaceSequentialMemoriesFile() const
Definition Firtool.h:100
bool addVivadoRAMAddressConflictSynthesisBugWorkaround
Definition Firtool.h:465
FirtoolOptions & setSymbolicValueLowering(verif::SymbolicValueLowering mode)
Definition Firtool.h:392
SmallVector< std::string > skippedDomains
Definition Firtool.h:486
FirtoolOptions & setLowerMemories(bool value)
Definition Firtool.h:271
FirtoolOptions & setNoDedup(bool value)
Definition Firtool.h:251
bool shouldFixupEICGWrapper() const
Definition Firtool.h:163
bool shouldConvertProbesToSignals() const
Definition Firtool.h:137
firrtl::PreserveValues::PreserveMode getPreserveMode() const
Definition Firtool.h:86
FirtoolOptions & setLowerAnnotationsNoRefTypePorts(bool value)
Definition Firtool.h:204
StringRef getBlackBoxRootPath() const
Definition Firtool.h:99
bool shouldDisableCSEinClasses() const
Definition Firtool.h:164
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:316
FirtoolOptions & setPreserveValues(firrtl::PreserveValues::PreserveMode value)
Definition Firtool.h:221
bool getEmitAllBindFiles() const
Definition Firtool.h:178
bool shouldReplaceSequentialMemories() const
Definition Firtool.h:138
FirtoolOptions & setDomainMode(DomainMode value)
Definition Firtool.h:422
bool shouldIgnoreReadEnableMemories() const
Definition Firtool.h:144
FirtoolOptions & setOutputAnnotationFilename(StringRef value)
Definition Firtool.h:296
FirtoolOptions & setCkgOutputName(StringRef value)
Definition Firtool.h:347
bool isRandomEnabled(RandomKind kind) const
Definition Firtool.h:67
bool shouldDisableUnknownAnnotations() const
Definition Firtool.h:128
FirtoolOptions & setNoViews(bool value)
Definition Firtool.h:261
static RandomKind mergeRandomKind(RandomKind current, RandomKind incoming)
Advance the disabled-randomization lattice.
Definition Firtool.h:73
FirtoolOptions & setVbToBV(bool value)
Definition Firtool.h:246
bool shouldAddMuxPragmas() const
Definition Firtool.h:159
bool shouldEnableAnnotationWarning() const
Definition Firtool.h:152
FirtoolOptions & setEmitAllBindFiles(bool value)
Definition Firtool.h:412
FirtoolOptions & setCkgModuleName(StringRef value)
Definition Firtool.h:337
bool shouldConvertVecOfBundle() const
Definition Firtool.h:145
StringRef getOutputAnnotationFilename() const
Definition Firtool.h:101
bool shouldStripFirDebugInfo() const
Definition Firtool.h:147
FirtoolOptions & setConvertProbesToSignals(bool value)
Definition Firtool.h:209
FirtoolOptions & setIgnoreReadEnableMem(bool value)
Definition Firtool.h:291
FirtoolOptions & setEnableDebugInfo(bool value)
Definition Firtool.h:226
FirtoolOptions & setDisableAnnotationsClassless(bool value)
Definition Firtool.h:199
FirtoolOptions & setDisableLayerSink(bool value)
Definition Firtool.h:236
FirtoolOptions & setEmitSeparateAlwaysBlocks(bool value)
Definition Firtool.h:326
FirtoolOptions & setDisableOptimization(bool value)
Definition Firtool.h:241
std::string outputAnnotationFilename
Definition Firtool.h:458
firrtl::VerificationFlavor verificationFlavor
Definition Firtool.h:463
firrtl::PreserveAggregate::PreserveMode preserveAggregate
Definition Firtool.h:441
FirtoolOptions & setInlineInputOnlyModules(bool value)
Definition Firtool.h:417
FirtoolOptions & setLintXmrsInDesign(bool value)
Definition Firtool.h:407
bool shouldLowerMemories() const
Definition Firtool.h:141
FirtoolOptions & setDisableWireElimination(bool value)
Definition Firtool.h:397
FirtoolOptions & setCompanionMode(firrtl::CompanionMode value)
Definition Firtool.h:256
FirtoolOptions & setWarnOnTruncation(bool value)
Definition Firtool.h:306
FirtoolOptions & setVerificationFlavor(firrtl::VerificationFlavor value)
Definition Firtool.h:321
DomainMode getDomainMode() const
Definition Firtool.h:182
bool getLintStaticAsserts() const
Definition Firtool.h:174
bool shouldLowerNoRefTypePortAnnotations() const
Definition Firtool.h:134
FirtoolOptions & setReplSeqMem(bool value)
Definition Firtool.h:281
verif::SymbolicValueLowering getSymbolicValueLowering() const
Definition Firtool.h:169
FirtoolOptions & setCkgEnableName(StringRef value)
Definition Firtool.h:352
bool shouldExportModuleHierarchy() const
Definition Firtool.h:148
firrtl::CompanionMode companionMode
Definition Firtool.h:449
FirtoolOptions & setStripDebugInfo(bool value)
Definition Firtool.h:372
FirtoolOptions & setExportModuleHierarchy(bool value)
Definition Firtool.h:362
FirtoolOptions & setDisableUnknownAnnotations(bool disable)
Definition Firtool.h:194
bool shouldDisableWireElimination() const
Definition Firtool.h:172
FirtoolOptions & setEnableAnnotationWarning(bool value)
Definition Firtool.h:301
FirtoolOptions & setReplSeqMemFile(StringRef value)
Definition Firtool.h:286
bool shouldSelectDefaultInstanceChoice() const
Definition Firtool.h:165
FirtoolOptions & setLintStaticAsserts(bool value)
Definition Firtool.h:402
bool shouldInlineInputOnlyModules() const
Definition Firtool.h:180
verif::SymbolicValueLowering symbolicValueLowering
Definition Firtool.h:478
bool getLintXmrsInDesign() const
Definition Firtool.h:176
FirtoolOptions & setSelectDefaultInstanceChoice(bool value)
Definition Firtool.h:387
FirtoolOptions & setStripFirDebugInfo(bool value)
Definition Firtool.h:367
seq::ExternalizeClockGateOptions getClockGateOptions() const
Definition Firtool.h:112
bool shouldEnableDebugInfo() const
Definition Firtool.h:143
bool shouldEmitSeparateAlwaysBlocks() const
Definition Firtool.h:156
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:186
FirtoolOptions & setOutputFilename(StringRef name)
Definition Firtool.h:189
FirtoolOptions & setBlackBoxRootPath(StringRef value)
Definition Firtool.h:276
@ None
Don't explicitly preserve any named values.
Definition Passes.h:58
@ Check
Check domains without inference.
Definition Passes.h:81
@ Infer
Check domains with inference for private modules.
Definition Passes.h:83
@ InferAll
Check domains with inference for both public and private modules.
Definition Passes.h:85
LogicalResult populateLowFIRRTLToHW(mlir::PassManager &pm, const FirtoolOptions &opt, StringRef inputFilename)
Definition Firtool.cpp:241
LogicalResult populateHWToBTOR2(mlir::PassManager &pm, const FirtoolOptions &opt, llvm::raw_ostream &os)
BTOR2 emission pipeline, triggered with --btor2 flag.
Definition Firtool.cpp:458
LogicalResult populateExportSplitVerilog(mlir::PassManager &pm, const FirtoolOptions &opt, llvm::StringRef directory)
Definition Firtool.cpp:433
LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:330
LogicalResult populateExportVerilog(mlir::PassManager &pm, const FirtoolOptions &opt, std::unique_ptr< llvm::raw_ostream > os)
Definition Firtool.cpp:414
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:855
LogicalResult populateFinalizeIR(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:443
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.