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