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; }
150 bool shouldConvertVecOfBundle() const { return vbToBV; }
151 bool shouldStripDebugInfo() const { return stripDebugInfo; }
159 bool shouldLowerToCore() const { return lowerToCore; }
164 bool shouldAddMuxPragmas() const { return addMuxPragmas; }
173
178
180
181 bool getLintXmrsInDesign() const { return lintXmrsInDesign; }
182
183 bool getEmitAllBindFiles() const { return emitAllBindFiles; }
184
186
188
189 ArrayRef<std::string> getSkippedDomains() const { return skippedDomains; }
190
191 // Setters, used by the CAPI
193 outputFilename = name;
194 return *this;
195 }
196
199 return *this;
200 }
201
204 return *this;
205 }
206
209 return *this;
210 }
211
213 probesToSignals = value;
214 return *this;
215 }
216
222
225 preserveMode = value;
226 return *this;
227 }
228
230 enableDebugInfo = value;
231 return *this;
232 }
233
235 buildMode = value;
236 return *this;
237 }
238
240 disableLayerSink = value;
241 return *this;
242 }
243
245 disableOptimization = value;
246 return *this;
247 }
248
250 vbToBV = value;
251 return *this;
252 }
253
255 noDedup = value;
256 return *this;
257 }
258
260 dedupClasses = value;
261 return *this;
262 }
263
265 companionMode = value;
266 return *this;
267 }
268
270 noViews = value;
271 return *this;
272 }
273
278
280 lowerMemories = value;
281 return *this;
282 }
283
285 blackBoxRootPath = value;
286 return *this;
287 }
288
290 replSeqMem = value;
291 return *this;
292 }
293
295 replSeqMemFile = value;
296 return *this;
297 }
298
300 ignoreReadEnableMem = value;
301 return *this;
302 }
303
306 return *this;
307 }
308
311 return *this;
312 }
313
315 warnOnTruncation = value;
316 return *this;
317 }
318
320 lowerToCore = value;
321 return *this;
322 }
323
325 addMuxPragmas = value;
326 return *this;
327 }
328
333
336 return *this;
337 }
338
344
346 ckgModuleName = value;
347 return *this;
348 }
349
350 FirtoolOptions &setCkgInputName(StringRef value) {
351 ckgInputName = value;
352 return *this;
353 }
354
356 ckgOutputName = value;
357 return *this;
358 }
359
361 ckgEnableName = value;
362 return *this;
363 }
364
366 ckgTestEnableName = value;
367 return *this;
368 }
369
371 exportModuleHierarchy = value;
372 return *this;
373 }
374
376 stripFirDebugInfo = value;
377 return *this;
378 }
379
381 stripDebugInfo = value;
382 return *this;
383 }
384
386 fixupEICGWrapper = value;
387 return *this;
388 }
389
391 disableCSEinClasses = value;
392 return *this;
393 }
394
397 return *this;
398 }
399
404
407 return *this;
408 }
409
411 lintStaticAsserts = value;
412 return *this;
413 }
414
416 lintXmrsInDesign = value;
417 return *this;
418 }
419
421 emitAllBindFiles = value;
422 return *this;
423 }
424
427 return *this;
428 }
429
431 domainMode = value;
432 return *this;
433 }
434
435private:
436 std::string outputFilename;
437
438 // LowerFIRRTLAnnotations
442
450 bool vbToBV;
457 std::string blackBoxRootPath;
459 std::string replSeqMemFile;
470 std::string ckgModuleName;
471 std::string ckgInputName;
472 std::string ckgOutputName;
473 std::string ckgEnableName;
474 std::string ckgTestEnableName;
475 std::string ckgInstName;
489 SmallVector<std::string> skippedDomains;
490};
491
493
494LogicalResult populatePreprocessTransforms(mlir::PassManager &pm,
495 const FirtoolOptions &opt);
496
497LogicalResult populateCHIRRTLToLowFIRRTL(mlir::PassManager &pm,
498 const FirtoolOptions &opt);
499
500LogicalResult populateLowFIRRTLToHW(mlir::PassManager &pm,
501 const FirtoolOptions &opt,
502 StringRef inputFilename);
503
504LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt);
505
506LogicalResult populateExportVerilog(mlir::PassManager &pm,
507 const FirtoolOptions &opt,
508 std::unique_ptr<llvm::raw_ostream> os);
509
510LogicalResult populateExportVerilog(mlir::PassManager &pm,
511 const FirtoolOptions &opt,
512 llvm::raw_ostream &os);
513
514LogicalResult populateExportSplitVerilog(mlir::PassManager &pm,
515 const FirtoolOptions &opt,
516 llvm::StringRef directory);
517
518LogicalResult populateFinalizeIR(mlir::PassManager &pm,
519 const FirtoolOptions &opt);
520
521LogicalResult populateHWToBTOR2(mlir::PassManager &pm,
522 const FirtoolOptions &opt,
523 llvm::raw_ostream &os);
524
525} // namespace firtool
526} // namespace circt
527
528#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:385
FirtoolOptions & setPreserveAggregate(firrtl::PreserveAggregate::PreserveMode value)
Definition Firtool.h:218
FirtoolOptions & setAddVivadoRAMAddressConflictSynthesisBugWorkaround(bool value)
Definition Firtool.h:340
bool shouldStripDebugInfo() const
Definition Firtool.h:151
FirtoolOptions & setBuildMode(BuildMode value)
Definition Firtool.h:234
FirtoolOptions & setDisableAggressiveMergeConnections(bool value)
Definition Firtool.h:274
FirtoolOptions & setCkgInputName(StringRef value)
Definition Firtool.h:350
firrtl::PreserveAggregate::PreserveMode getPreserveAggregate() const
Definition Firtool.h:109
FirtoolOptions & setLowerToCore(bool value)
Definition Firtool.h:319
bool shouldAddVivadoRAMAddressConflictSynthesisBugWorkaround() const
Definition Firtool.h:165
bool shouldDisableLayerSink() const
Definition Firtool.h:143
firrtl::PreserveValues::PreserveMode preserveMode
Definition Firtool.h:445
FirtoolOptions & setDisableCSEinClasses(bool value)
Definition Firtool.h:390
auto getVerificationFlavor() const
Definition Firtool.h:160
@ 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:365
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:259
bool shouldDisableAggressiveMergeConnections() const
Definition Firtool.h:154
bool shouldWarnOnTruncation() const
Definition Firtool.h:158
StringRef getReplaceSequentialMemoriesFile() const
Definition Firtool.h:104
bool addVivadoRAMAddressConflictSynthesisBugWorkaround
Definition Firtool.h:469
FirtoolOptions & setSymbolicValueLowering(verif::SymbolicValueLowering mode)
Definition Firtool.h:400
SmallVector< std::string > skippedDomains
Definition Firtool.h:489
FirtoolOptions & setLowerMemories(bool value)
Definition Firtool.h:279
FirtoolOptions & setNoDedup(bool value)
Definition Firtool.h:254
bool shouldFixupEICGWrapper() const
Definition Firtool.h:168
bool shouldConvertProbesToSignals() const
Definition Firtool.h:141
firrtl::PreserveValues::PreserveMode getPreserveMode() const
Definition Firtool.h:90
FirtoolOptions & setLowerAnnotationsNoRefTypePorts(bool value)
Definition Firtool.h:207
bool shouldDedupClasses() const
Definition Firtool.h:147
StringRef getBlackBoxRootPath() const
Definition Firtool.h:103
bool shouldDisableCSEinClasses() const
Definition Firtool.h:169
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:324
FirtoolOptions & setPreserveValues(firrtl::PreserveValues::PreserveMode value)
Definition Firtool.h:224
bool getEmitAllBindFiles() const
Definition Firtool.h:183
bool shouldReplaceSequentialMemories() const
Definition Firtool.h:142
FirtoolOptions & setDomainMode(DomainMode value)
Definition Firtool.h:430
bool shouldIgnoreReadEnableMemories() const
Definition Firtool.h:149
FirtoolOptions & setOutputAnnotationFilename(StringRef value)
Definition Firtool.h:304
FirtoolOptions & setCkgOutputName(StringRef value)
Definition Firtool.h:355
bool isRandomEnabled(RandomKind kind) const
Definition Firtool.h:71
bool shouldDisableUnknownAnnotations() const
Definition Firtool.h:132
FirtoolOptions & setNoViews(bool value)
Definition Firtool.h:269
static RandomKind mergeRandomKind(RandomKind current, RandomKind incoming)
Advance the disabled-randomization lattice.
Definition Firtool.h:77
FirtoolOptions & setVbToBV(bool value)
Definition Firtool.h:249
bool shouldAddMuxPragmas() const
Definition Firtool.h:164
bool shouldEnableAnnotationWarning() const
Definition Firtool.h:157
FirtoolOptions & setEmitAllBindFiles(bool value)
Definition Firtool.h:420
FirtoolOptions & setCkgModuleName(StringRef value)
Definition Firtool.h:345
bool shouldConvertVecOfBundle() const
Definition Firtool.h:150
StringRef getOutputAnnotationFilename() const
Definition Firtool.h:105
bool shouldStripFirDebugInfo() const
Definition Firtool.h:152
FirtoolOptions & setConvertProbesToSignals(bool value)
Definition Firtool.h:212
FirtoolOptions & setIgnoreReadEnableMem(bool value)
Definition Firtool.h:299
FirtoolOptions & setEnableDebugInfo(bool value)
Definition Firtool.h:229
FirtoolOptions & setDisableAnnotationsClassless(bool value)
Definition Firtool.h:202
FirtoolOptions & setDisableLayerSink(bool value)
Definition Firtool.h:239
FirtoolOptions & setEmitSeparateAlwaysBlocks(bool value)
Definition Firtool.h:334
FirtoolOptions & setDisableOptimization(bool value)
Definition Firtool.h:244
std::string outputAnnotationFilename
Definition Firtool.h:462
firrtl::VerificationFlavor verificationFlavor
Definition Firtool.h:467
firrtl::PreserveAggregate::PreserveMode preserveAggregate
Definition Firtool.h:444
FirtoolOptions & setInlineInputOnlyModules(bool value)
Definition Firtool.h:425
FirtoolOptions & setLintXmrsInDesign(bool value)
Definition Firtool.h:415
bool shouldLowerMemories() const
Definition Firtool.h:145
FirtoolOptions & setDisableWireElimination(bool value)
Definition Firtool.h:405
FirtoolOptions & setCompanionMode(firrtl::CompanionMode value)
Definition Firtool.h:264
FirtoolOptions & setWarnOnTruncation(bool value)
Definition Firtool.h:314
FirtoolOptions & setVerificationFlavor(firrtl::VerificationFlavor value)
Definition Firtool.h:329
DomainMode getDomainMode() const
Definition Firtool.h:187
bool getLintStaticAsserts() const
Definition Firtool.h:179
bool shouldLowerNoRefTypePortAnnotations() const
Definition Firtool.h:138
FirtoolOptions & setReplSeqMem(bool value)
Definition Firtool.h:289
verif::SymbolicValueLowering getSymbolicValueLowering() const
Definition Firtool.h:174
FirtoolOptions & setCkgEnableName(StringRef value)
Definition Firtool.h:360
bool shouldExportModuleHierarchy() const
Definition Firtool.h:153
firrtl::CompanionMode companionMode
Definition Firtool.h:453
FirtoolOptions & setStripDebugInfo(bool value)
Definition Firtool.h:380
FirtoolOptions & setExportModuleHierarchy(bool value)
Definition Firtool.h:370
FirtoolOptions & setDisableUnknownAnnotations(bool disable)
Definition Firtool.h:197
bool shouldDisableWireElimination() const
Definition Firtool.h:177
FirtoolOptions & setEnableAnnotationWarning(bool value)
Definition Firtool.h:309
FirtoolOptions & setReplSeqMemFile(StringRef value)
Definition Firtool.h:294
bool shouldSelectDefaultInstanceChoice() const
Definition Firtool.h:170
FirtoolOptions & setLintStaticAsserts(bool value)
Definition Firtool.h:410
bool shouldInlineInputOnlyModules() const
Definition Firtool.h:185
verif::SymbolicValueLowering symbolicValueLowering
Definition Firtool.h:482
bool getLintXmrsInDesign() const
Definition Firtool.h:181
FirtoolOptions & setSelectDefaultInstanceChoice(bool value)
Definition Firtool.h:395
FirtoolOptions & setStripFirDebugInfo(bool value)
Definition Firtool.h:375
seq::ExternalizeClockGateOptions getClockGateOptions() const
Definition Firtool.h:116
bool shouldEnableDebugInfo() const
Definition Firtool.h:148
bool shouldEmitSeparateAlwaysBlocks() const
Definition Firtool.h:161
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:189
FirtoolOptions & setOutputFilename(StringRef name)
Definition Firtool.h:192
FirtoolOptions & setBlackBoxRootPath(StringRef value)
Definition Firtool.h:284
@ 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:243
LogicalResult populateHWToBTOR2(mlir::PassManager &pm, const FirtoolOptions &opt, llvm::raw_ostream &os)
BTOR2 emission pipeline, triggered with --btor2 flag.
Definition Firtool.cpp:460
LogicalResult populateExportSplitVerilog(mlir::PassManager &pm, const FirtoolOptions &opt, llvm::StringRef directory)
Definition Firtool.cpp:435
LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:332
LogicalResult populateExportVerilog(mlir::PassManager &pm, const FirtoolOptions &opt, std::unique_ptr< llvm::raw_ostream > os)
Definition Firtool.cpp:416
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:850
LogicalResult populateFinalizeIR(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:445
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.