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// FirtoolOptions
28//===----------------------------------------------------------------------===//
29
30/// Set of options used to control the behavior of the firtool pipeline.
32public:
34
35 // Helper Types
37 enum class RandomKind { None, Mem, Reg, All };
38
39 bool isRandomEnabled(RandomKind kind) const {
40 return disableRandom != RandomKind::All && disableRandom != kind;
41 }
42
44 switch (buildMode) {
45 case BuildModeDebug:
50 return preserveMode;
51 }
52 llvm_unreachable("unknown build mode");
53 }
54
55 StringRef getOutputFilename() const { return outputFilename; }
56 StringRef getBlackBoxRootPath() const { return blackBoxRootPath; }
58 StringRef getOutputAnnotationFilename() const {
60 }
61
66
67 bool getNoViews() const { return noViews; }
68
69 seq::ExternalizeClockGateOptions getClockGateOptions() const {
72 }
73
74 FirtoolOptions &setClockGateOptions(seq::ExternalizeClockGateOptions &opts) {
75 ckgModuleName = opts.moduleName;
76 ckgInputName = opts.inputName;
77 ckgOutputName = opts.outputName;
78 ckgEnableName = opts.enableName;
79 ckgTestEnableName = opts.testEnableName;
80 ckgInstName = opts.instName;
81 return *this;
82 }
83
84 bool isDefaultOutputFilename() const { return outputFilename == "-"; }
98 bool shouldLowerMemories() const { return lowerMemories; }
99 bool shouldDedup() const { return !noDedup; }
100 bool shouldDedupClasses() const { return dedupClasses; }
101 bool shouldEnableDebugInfo() const { return enableDebugInfo; }
103 bool shouldConvertVecOfBundle() const { return vbToBV; }
113 bool shouldStripDebugInfo() const { return stripDebugInfo; }
124 bool shouldAddMuxPragmas() const { return addMuxPragmas; }
128 bool shouldExtractTestCode() const { return extractTestCode; }
134
139
141
142 bool getLintXmrsInDesign() const { return lintXmrsInDesign; }
143
144 bool getEmitAllBindFiles() const { return emitAllBindFiles; }
145
146 // Setters, used by the CAPI
148 outputFilename = name;
149 return *this;
150 }
151
154 return *this;
155 }
156
159 return *this;
160 }
161
164 return *this;
165 }
166
168 probesToSignals = value;
169 return *this;
170 }
171
177
180 preserveMode = value;
181 return *this;
182 }
183
185 enableDebugInfo = value;
186 return *this;
187 }
188
190 buildMode = value;
191 return *this;
192 }
193
195 disableLayerSink = value;
196 return *this;
197 }
198
200 disableOptimization = value;
201 return *this;
202 }
203
205 vbToBV = value;
206 return *this;
207 }
208
210 noDedup = value;
211 return *this;
212 }
213
215 dedupClasses = value;
216 return *this;
217 }
218
220 companionMode = value;
221 return *this;
222 }
223
225 noViews = value;
226 return *this;
227 }
228
233
235 lowerMemories = value;
236 return *this;
237 }
238
240 blackBoxRootPath = value;
241 return *this;
242 }
243
245 replSeqMem = value;
246 return *this;
247 }
248
250 replSeqMemFile = value;
251 return *this;
252 }
253
255 extractTestCode = value;
256 return *this;
257 }
258
260 ignoreReadEnableMem = value;
261 return *this;
262 }
263
265 disableRandom = value;
266 return *this;
267 }
268
271 return *this;
272 }
273
276 return *this;
277 }
278
280 addMuxPragmas = value;
281 return *this;
282 }
283
288
291 return *this;
292 }
293
296 return *this;
297 }
298
301 return *this;
302 }
303
306 return *this;
307 }
308
314
316 ckgModuleName = value;
317 return *this;
318 }
319
320 FirtoolOptions &setCkgInputName(StringRef value) {
321 ckgInputName = value;
322 return *this;
323 }
324
326 ckgOutputName = value;
327 return *this;
328 }
329
331 ckgEnableName = value;
332 return *this;
333 }
334
336 ckgTestEnableName = value;
337 return *this;
338 }
339
341 exportModuleHierarchy = value;
342 return *this;
343 }
344
346 stripFirDebugInfo = value;
347 return *this;
348 }
349
351 stripDebugInfo = value;
352 return *this;
353 }
354
356 fixupEICGWrapper = value;
357 return *this;
358 }
359
361 disableCSEinClasses = value;
362 return *this;
363 }
364
367 return *this;
368 }
369
374
377 return *this;
378 }
379
381 lintStaticAsserts = value;
382 return *this;
383 }
384
386 lintXmrsInDesign = value;
387 return *this;
388 }
389
391 emitAllBindFiles = value;
392 return *this;
393 }
394
395private:
396 std::string outputFilename;
397
398 // LowerFIRRTLAnnotations
402
410 bool vbToBV;
417 std::string blackBoxRootPath;
419 std::string replSeqMemFile;
432 std::string ckgModuleName;
433 std::string ckgInputName;
434 std::string ckgOutputName;
435 std::string ckgEnableName;
436 std::string ckgTestEnableName;
437 std::string ckgInstName;
449};
450
452
453LogicalResult populatePreprocessTransforms(mlir::PassManager &pm,
454 const FirtoolOptions &opt);
455
456LogicalResult populateCHIRRTLToLowFIRRTL(mlir::PassManager &pm,
457 const FirtoolOptions &opt);
458
459LogicalResult populateLowFIRRTLToHW(mlir::PassManager &pm,
460 const FirtoolOptions &opt,
461 StringRef inputFilename);
462
463LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt);
464
465LogicalResult populateExportVerilog(mlir::PassManager &pm,
466 const FirtoolOptions &opt,
467 std::unique_ptr<llvm::raw_ostream> os);
468
469LogicalResult populateExportVerilog(mlir::PassManager &pm,
470 const FirtoolOptions &opt,
471 llvm::raw_ostream &os);
472
473LogicalResult populateExportSplitVerilog(mlir::PassManager &pm,
474 const FirtoolOptions &opt,
475 llvm::StringRef directory);
476
477LogicalResult populateFinalizeIR(mlir::PassManager &pm,
478 const FirtoolOptions &opt);
479
480LogicalResult populateHWToBTOR2(mlir::PassManager &pm,
481 const FirtoolOptions &opt,
482 llvm::raw_ostream &os);
483
484} // namespace firtool
485} // namespace circt
486
487#endif // CIRCT_FIRTOOL_FIRTOOL_H
Set of options used to control the behavior of the firtool pipeline.
Definition Firtool.h:31
FirtoolOptions & setFixupEICGWrapper(bool value)
Definition Firtool.h:355
FirtoolOptions & setPreserveAggregate(firrtl::PreserveAggregate::PreserveMode value)
Definition Firtool.h:173
FirtoolOptions & setAddVivadoRAMAddressConflictSynthesisBugWorkaround(bool value)
Definition Firtool.h:310
bool shouldStripDebugInfo() const
Definition Firtool.h:113
FirtoolOptions & setBuildMode(BuildMode value)
Definition Firtool.h:189
FirtoolOptions & setDisableAggressiveMergeConnections(bool value)
Definition Firtool.h:229
FirtoolOptions & setCkgInputName(StringRef value)
Definition Firtool.h:320
firrtl::PreserveAggregate::PreserveMode getPreserveAggregate() const
Definition Firtool.h:62
bool shouldAddVivadoRAMAddressConflictSynthesisBugWorkaround() const
Definition Firtool.h:125
bool shouldDisableLayerSink() const
Definition Firtool.h:96
firrtl::PreserveValues::PreserveMode preserveMode
Definition Firtool.h:405
FirtoolOptions & setDisableCSEinClasses(bool value)
Definition Firtool.h:360
auto getVerificationFlavor() const
Definition Firtool.h:120
FirtoolOptions & setClockGateOptions(seq::ExternalizeClockGateOptions &opts)
Definition Firtool.h:74
FirtoolOptions & setCkgTestEnableName(StringRef value)
Definition Firtool.h:335
bool isDefaultOutputFilename() const
Definition Firtool.h:84
StringRef getOutputFilename() const
Definition Firtool.h:55
FirtoolOptions & setDedupClasses(bool value)
Definition Firtool.h:214
bool shouldDisableAggressiveMergeConnections() const
Definition Firtool.h:116
StringRef getReplaceSequentialMemoriesFile() const
Definition Firtool.h:57
bool addVivadoRAMAddressConflictSynthesisBugWorkaround
Definition Firtool.h:431
FirtoolOptions & setSymbolicValueLowering(verif::SymbolicValueLowering mode)
Definition Firtool.h:370
FirtoolOptions & setLowerMemories(bool value)
Definition Firtool.h:234
FirtoolOptions & setDisableRandom(RandomKind value)
Definition Firtool.h:264
bool shouldExtractTestCode() const
Definition Firtool.h:128
FirtoolOptions & setNoDedup(bool value)
Definition Firtool.h:209
bool shouldFixupEICGWrapper() const
Definition Firtool.h:129
bool shouldConvertProbesToSignals() const
Definition Firtool.h:94
firrtl::PreserveValues::PreserveMode getPreserveMode() const
Definition Firtool.h:43
FirtoolOptions & setLowerAnnotationsNoRefTypePorts(bool value)
Definition Firtool.h:162
bool shouldDedupClasses() const
Definition Firtool.h:100
StringRef getBlackBoxRootPath() const
Definition Firtool.h:56
bool shouldDisableCSEinClasses() const
Definition Firtool.h:130
bool shouldDisableOptimization() const
Definition Firtool.h:97
firrtl::CompanionMode getCompanionMode() const
Definition Firtool.h:65
bool shouldDisableClasslessAnnotations() const
Definition Firtool.h:88
FirtoolOptions & setAddMuxPragmas(bool value)
Definition Firtool.h:279
FirtoolOptions & setPreserveValues(firrtl::PreserveValues::PreserveMode value)
Definition Firtool.h:179
bool getEmitAllBindFiles() const
Definition Firtool.h:144
bool shouldReplaceSequentialMemories() const
Definition Firtool.h:95
bool shouldIgnoreReadEnableMemories() const
Definition Firtool.h:102
FirtoolOptions & setEtcDisableInstanceExtraction(bool value)
Definition Firtool.h:294
FirtoolOptions & setOutputAnnotationFilename(StringRef value)
Definition Firtool.h:269
FirtoolOptions & setCkgOutputName(StringRef value)
Definition Firtool.h:325
bool isRandomEnabled(RandomKind kind) const
Definition Firtool.h:39
bool shouldDisableUnknownAnnotations() const
Definition Firtool.h:85
FirtoolOptions & setNoViews(bool value)
Definition Firtool.h:224
FirtoolOptions & setVbToBV(bool value)
Definition Firtool.h:204
bool shouldAddMuxPragmas() const
Definition Firtool.h:124
bool shouldEnableAnnotationWarning() const
Definition Firtool.h:119
FirtoolOptions & setEmitAllBindFiles(bool value)
Definition Firtool.h:390
bool shouldEtcDisableInstanceExtraction() const
Definition Firtool.h:104
FirtoolOptions & setCkgModuleName(StringRef value)
Definition Firtool.h:315
bool shouldConvertVecOfBundle() const
Definition Firtool.h:103
StringRef getOutputAnnotationFilename() const
Definition Firtool.h:58
bool shouldStripFirDebugInfo() const
Definition Firtool.h:114
FirtoolOptions & setConvertProbesToSignals(bool value)
Definition Firtool.h:167
bool shouldEtcDisableRegisterExtraction() const
Definition Firtool.h:107
FirtoolOptions & setEtcDisableModuleInlining(bool value)
Definition Firtool.h:304
FirtoolOptions & setIgnoreReadEnableMem(bool value)
Definition Firtool.h:259
FirtoolOptions & setEnableDebugInfo(bool value)
Definition Firtool.h:184
FirtoolOptions & setDisableAnnotationsClassless(bool value)
Definition Firtool.h:157
FirtoolOptions & setDisableLayerSink(bool value)
Definition Firtool.h:194
FirtoolOptions & setEmitSeparateAlwaysBlocks(bool value)
Definition Firtool.h:289
FirtoolOptions & setDisableOptimization(bool value)
Definition Firtool.h:199
FirtoolOptions & setExtractTestCode(bool value)
Definition Firtool.h:254
std::string outputAnnotationFilename
Definition Firtool.h:423
firrtl::VerificationFlavor verificationFlavor
Definition Firtool.h:426
firrtl::PreserveAggregate::PreserveMode preserveAggregate
Definition Firtool.h:404
FirtoolOptions & setLintXmrsInDesign(bool value)
Definition Firtool.h:385
bool shouldLowerMemories() const
Definition Firtool.h:98
FirtoolOptions & setDisableWireElimination(bool value)
Definition Firtool.h:375
bool shouldEtcDisableModuleInlining() const
Definition Firtool.h:110
FirtoolOptions & setCompanionMode(firrtl::CompanionMode value)
Definition Firtool.h:219
FirtoolOptions & setVerificationFlavor(firrtl::VerificationFlavor value)
Definition Firtool.h:284
bool getLintStaticAsserts() const
Definition Firtool.h:140
bool shouldLowerNoRefTypePortAnnotations() const
Definition Firtool.h:91
FirtoolOptions & setReplSeqMem(bool value)
Definition Firtool.h:244
verif::SymbolicValueLowering getSymbolicValueLowering() const
Definition Firtool.h:135
FirtoolOptions & setCkgEnableName(StringRef value)
Definition Firtool.h:330
bool shouldExportModuleHierarchy() const
Definition Firtool.h:115
firrtl::CompanionMode companionMode
Definition Firtool.h:413
FirtoolOptions & setStripDebugInfo(bool value)
Definition Firtool.h:350
FirtoolOptions & setExportModuleHierarchy(bool value)
Definition Firtool.h:340
FirtoolOptions & setDisableUnknownAnnotations(bool disable)
Definition Firtool.h:152
bool shouldDisableWireElimination() const
Definition Firtool.h:138
FirtoolOptions & setEnableAnnotationWarning(bool value)
Definition Firtool.h:274
FirtoolOptions & setEtcDisableRegisterExtraction(bool value)
Definition Firtool.h:299
FirtoolOptions & setReplSeqMemFile(StringRef value)
Definition Firtool.h:249
bool shouldSelectDefaultInstanceChoice() const
Definition Firtool.h:131
FirtoolOptions & setLintStaticAsserts(bool value)
Definition Firtool.h:380
verif::SymbolicValueLowering symbolicValueLowering
Definition Firtool.h:444
bool getLintXmrsInDesign() const
Definition Firtool.h:142
FirtoolOptions & setSelectDefaultInstanceChoice(bool value)
Definition Firtool.h:365
FirtoolOptions & setStripFirDebugInfo(bool value)
Definition Firtool.h:345
seq::ExternalizeClockGateOptions getClockGateOptions() const
Definition Firtool.h:69
bool shouldEnableDebugInfo() const
Definition Firtool.h:101
bool shouldEmitSeparateAlwaysBlocks() const
Definition Firtool.h:121
FirtoolOptions & setOutputFilename(StringRef name)
Definition Firtool.h:147
FirtoolOptions & setBlackBoxRootPath(StringRef value)
Definition Firtool.h:239
@ None
Don't explicitly preserve any named values.
Definition Passes.h:52
LogicalResult populateLowFIRRTLToHW(mlir::PassManager &pm, const FirtoolOptions &opt, StringRef inputFilename)
Definition Firtool.cpp:222
LogicalResult populateHWToBTOR2(mlir::PassManager &pm, const FirtoolOptions &opt, llvm::raw_ostream &os)
Definition Firtool.cpp:442
LogicalResult populateExportSplitVerilog(mlir::PassManager &pm, const FirtoolOptions &opt, llvm::StringRef directory)
Definition Firtool.cpp:424
LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:309
LogicalResult populateExportVerilog(mlir::PassManager &pm, const FirtoolOptions &opt, std::unique_ptr< llvm::raw_ostream > os)
Definition Firtool.cpp:405
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:783
LogicalResult populateFinalizeIR(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:434
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.