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 seq::ExternalizeClockGateOptions getClockGateOptions() const {
70 }
71
72 FirtoolOptions &setClockGateOptions(seq::ExternalizeClockGateOptions &opts) {
73 ckgModuleName = opts.moduleName;
74 ckgInputName = opts.inputName;
75 ckgOutputName = opts.outputName;
76 ckgEnableName = opts.enableName;
77 ckgTestEnableName = opts.testEnableName;
78 ckgInstName = opts.instName;
79 return *this;
80 }
81
82 bool isDefaultOutputFilename() const { return outputFilename == "-"; }
99 bool shouldLowerMemories() const { return lowerMemories; }
100 bool shouldDedup() const { return !noDedup; }
101 bool shouldDedupClasses() const { return dedupClasses; }
102 bool shouldEnableDebugInfo() const { return enableDebugInfo; }
104 bool shouldConvertVecOfBundle() const { return vbToBV; }
114 bool shouldStripDebugInfo() const { return stripDebugInfo; }
125 bool shouldAddMuxPragmas() const { return addMuxPragmas; }
129 bool shouldExtractTestCode() const { return extractTestCode; }
135
140
142
143 bool getLintXmrsInDesign() const { return lintXmrsInDesign; }
144
145 bool getEmitAllBindFiles() const { return emitAllBindFiles; }
146
147 // Setters, used by the CAPI
149 outputFilename = name;
150 return *this;
151 }
152
155 return *this;
156 }
157
160 return *this;
161 }
162
165 return *this;
166 }
167
170 return *this;
171 }
172
174 probesToSignals = value;
175 return *this;
176 }
177
183
186 preserveMode = value;
187 return *this;
188 }
189
191 enableDebugInfo = value;
192 return *this;
193 }
194
196 buildMode = value;
197 return *this;
198 }
199
201 disableLayerSink = value;
202 return *this;
203 }
204
206 disableOptimization = value;
207 return *this;
208 }
209
211 vbToBV = value;
212 return *this;
213 }
214
216 noDedup = value;
217 return *this;
218 }
219
221 dedupClasses = value;
222 return *this;
223 }
224
226 companionMode = value;
227 return *this;
228 }
229
234
236 lowerMemories = value;
237 return *this;
238 }
239
241 blackBoxRootPath = value;
242 return *this;
243 }
244
246 replSeqMem = value;
247 return *this;
248 }
249
251 replSeqMemFile = value;
252 return *this;
253 }
254
256 extractTestCode = value;
257 return *this;
258 }
259
261 ignoreReadEnableMem = value;
262 return *this;
263 }
264
266 disableRandom = value;
267 return *this;
268 }
269
272 return *this;
273 }
274
277 return *this;
278 }
279
281 addMuxPragmas = value;
282 return *this;
283 }
284
289
292 return *this;
293 }
294
297 return *this;
298 }
299
302 return *this;
303 }
304
307 return *this;
308 }
309
315
317 ckgModuleName = value;
318 return *this;
319 }
320
321 FirtoolOptions &setCkgInputName(StringRef value) {
322 ckgInputName = value;
323 return *this;
324 }
325
327 ckgOutputName = value;
328 return *this;
329 }
330
332 ckgEnableName = value;
333 return *this;
334 }
335
337 ckgTestEnableName = value;
338 return *this;
339 }
340
342 exportModuleHierarchy = value;
343 return *this;
344 }
345
347 stripFirDebugInfo = value;
348 return *this;
349 }
350
352 stripDebugInfo = value;
353 return *this;
354 }
355
357 fixupEICGWrapper = value;
358 return *this;
359 }
360
362 disableCSEinClasses = value;
363 return *this;
364 }
365
368 return *this;
369 }
370
375
378 return *this;
379 }
380
382 lintStaticAsserts = value;
383 return *this;
384 }
385
387 lintXmrsInDesign = value;
388 return *this;
389 }
390
392 emitAllBindFiles = value;
393 return *this;
394 }
395
396private:
397 std::string outputFilename;
398
399 // LowerFIRRTLAnnotations
404
412 bool vbToBV;
418 std::string blackBoxRootPath;
420 std::string replSeqMemFile;
433 std::string ckgModuleName;
434 std::string ckgInputName;
435 std::string ckgOutputName;
436 std::string ckgEnableName;
437 std::string ckgTestEnableName;
438 std::string ckgInstName;
450};
451
453
454LogicalResult populatePreprocessTransforms(mlir::PassManager &pm,
455 const FirtoolOptions &opt);
456
457LogicalResult populateCHIRRTLToLowFIRRTL(mlir::PassManager &pm,
458 const FirtoolOptions &opt);
459
460LogicalResult populateLowFIRRTLToHW(mlir::PassManager &pm,
461 const FirtoolOptions &opt,
462 StringRef inputFilename);
463
464LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt);
465
466LogicalResult populateExportVerilog(mlir::PassManager &pm,
467 const FirtoolOptions &opt,
468 std::unique_ptr<llvm::raw_ostream> os);
469
470LogicalResult populateExportVerilog(mlir::PassManager &pm,
471 const FirtoolOptions &opt,
472 llvm::raw_ostream &os);
473
474LogicalResult populateExportSplitVerilog(mlir::PassManager &pm,
475 const FirtoolOptions &opt,
476 llvm::StringRef directory);
477
478LogicalResult populateFinalizeIR(mlir::PassManager &pm,
479 const FirtoolOptions &opt);
480
481LogicalResult populateHWToBTOR2(mlir::PassManager &pm,
482 const FirtoolOptions &opt,
483 llvm::raw_ostream &os);
484
485} // namespace firtool
486} // namespace circt
487
488#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:356
FirtoolOptions & setPreserveAggregate(firrtl::PreserveAggregate::PreserveMode value)
Definition Firtool.h:179
FirtoolOptions & setAddVivadoRAMAddressConflictSynthesisBugWorkaround(bool value)
Definition Firtool.h:311
bool shouldStripDebugInfo() const
Definition Firtool.h:114
FirtoolOptions & setBuildMode(BuildMode value)
Definition Firtool.h:195
FirtoolOptions & setDisableAggressiveMergeConnections(bool value)
Definition Firtool.h:230
FirtoolOptions & setCkgInputName(StringRef value)
Definition Firtool.h:321
firrtl::PreserveAggregate::PreserveMode getPreserveAggregate() const
Definition Firtool.h:62
bool shouldAddVivadoRAMAddressConflictSynthesisBugWorkaround() const
Definition Firtool.h:126
bool shouldDisableLayerSink() const
Definition Firtool.h:97
firrtl::PreserveValues::PreserveMode preserveMode
Definition Firtool.h:407
FirtoolOptions & setDisableCSEinClasses(bool value)
Definition Firtool.h:361
auto getVerificationFlavor() const
Definition Firtool.h:121
FirtoolOptions & setClockGateOptions(seq::ExternalizeClockGateOptions &opts)
Definition Firtool.h:72
FirtoolOptions & setCkgTestEnableName(StringRef value)
Definition Firtool.h:336
bool isDefaultOutputFilename() const
Definition Firtool.h:82
StringRef getOutputFilename() const
Definition Firtool.h:55
FirtoolOptions & setDedupClasses(bool value)
Definition Firtool.h:220
bool shouldDisableAggressiveMergeConnections() const
Definition Firtool.h:117
StringRef getReplaceSequentialMemoriesFile() const
Definition Firtool.h:57
bool addVivadoRAMAddressConflictSynthesisBugWorkaround
Definition Firtool.h:432
FirtoolOptions & setSymbolicValueLowering(verif::SymbolicValueLowering mode)
Definition Firtool.h:371
FirtoolOptions & setLowerMemories(bool value)
Definition Firtool.h:235
FirtoolOptions & setDisableRandom(RandomKind value)
Definition Firtool.h:265
bool shouldExtractTestCode() const
Definition Firtool.h:129
FirtoolOptions & setNoDedup(bool value)
Definition Firtool.h:215
bool shouldFixupEICGWrapper() const
Definition Firtool.h:130
bool shouldConvertProbesToSignals() const
Definition Firtool.h:95
firrtl::PreserveValues::PreserveMode getPreserveMode() const
Definition Firtool.h:43
FirtoolOptions & setLowerAnnotationsNoRefTypePorts(bool value)
Definition Firtool.h:163
bool shouldDedupClasses() const
Definition Firtool.h:101
FirtoolOptions & setAllowAddingPortsOnPublic(bool value)
Definition Firtool.h:168
StringRef getBlackBoxRootPath() const
Definition Firtool.h:56
bool shouldDisableCSEinClasses() const
Definition Firtool.h:131
bool shouldDisableOptimization() const
Definition Firtool.h:98
firrtl::CompanionMode getCompanionMode() const
Definition Firtool.h:65
bool shouldDisableClasslessAnnotations() const
Definition Firtool.h:86
FirtoolOptions & setAddMuxPragmas(bool value)
Definition Firtool.h:280
FirtoolOptions & setPreserveValues(firrtl::PreserveValues::PreserveMode value)
Definition Firtool.h:185
bool getEmitAllBindFiles() const
Definition Firtool.h:145
bool shouldReplaceSequentialMemories() const
Definition Firtool.h:96
bool shouldIgnoreReadEnableMemories() const
Definition Firtool.h:103
FirtoolOptions & setEtcDisableInstanceExtraction(bool value)
Definition Firtool.h:295
FirtoolOptions & setOutputAnnotationFilename(StringRef value)
Definition Firtool.h:270
FirtoolOptions & setCkgOutputName(StringRef value)
Definition Firtool.h:326
bool isRandomEnabled(RandomKind kind) const
Definition Firtool.h:39
bool shouldDisableUnknownAnnotations() const
Definition Firtool.h:83
FirtoolOptions & setVbToBV(bool value)
Definition Firtool.h:210
bool shouldAddMuxPragmas() const
Definition Firtool.h:125
bool shouldEnableAnnotationWarning() const
Definition Firtool.h:120
FirtoolOptions & setEmitAllBindFiles(bool value)
Definition Firtool.h:391
bool shouldEtcDisableInstanceExtraction() const
Definition Firtool.h:105
FirtoolOptions & setCkgModuleName(StringRef value)
Definition Firtool.h:316
bool shouldConvertVecOfBundle() const
Definition Firtool.h:104
StringRef getOutputAnnotationFilename() const
Definition Firtool.h:58
bool shouldStripFirDebugInfo() const
Definition Firtool.h:115
FirtoolOptions & setConvertProbesToSignals(bool value)
Definition Firtool.h:173
bool shouldEtcDisableRegisterExtraction() const
Definition Firtool.h:108
FirtoolOptions & setEtcDisableModuleInlining(bool value)
Definition Firtool.h:305
FirtoolOptions & setIgnoreReadEnableMem(bool value)
Definition Firtool.h:260
FirtoolOptions & setEnableDebugInfo(bool value)
Definition Firtool.h:190
FirtoolOptions & setDisableAnnotationsClassless(bool value)
Definition Firtool.h:158
FirtoolOptions & setDisableLayerSink(bool value)
Definition Firtool.h:200
FirtoolOptions & setEmitSeparateAlwaysBlocks(bool value)
Definition Firtool.h:290
FirtoolOptions & setDisableOptimization(bool value)
Definition Firtool.h:205
FirtoolOptions & setExtractTestCode(bool value)
Definition Firtool.h:255
std::string outputAnnotationFilename
Definition Firtool.h:424
firrtl::VerificationFlavor verificationFlavor
Definition Firtool.h:427
firrtl::PreserveAggregate::PreserveMode preserveAggregate
Definition Firtool.h:406
FirtoolOptions & setLintXmrsInDesign(bool value)
Definition Firtool.h:386
bool shouldLowerMemories() const
Definition Firtool.h:99
FirtoolOptions & setDisableWireElimination(bool value)
Definition Firtool.h:376
bool shouldEtcDisableModuleInlining() const
Definition Firtool.h:111
FirtoolOptions & setCompanionMode(firrtl::CompanionMode value)
Definition Firtool.h:225
bool shouldAllowAddingPortsOnPublic() const
Definition Firtool.h:92
FirtoolOptions & setVerificationFlavor(firrtl::VerificationFlavor value)
Definition Firtool.h:285
bool getLintStaticAsserts() const
Definition Firtool.h:141
bool shouldLowerNoRefTypePortAnnotations() const
Definition Firtool.h:89
FirtoolOptions & setReplSeqMem(bool value)
Definition Firtool.h:245
verif::SymbolicValueLowering getSymbolicValueLowering() const
Definition Firtool.h:136
FirtoolOptions & setCkgEnableName(StringRef value)
Definition Firtool.h:331
bool shouldExportModuleHierarchy() const
Definition Firtool.h:116
firrtl::CompanionMode companionMode
Definition Firtool.h:415
FirtoolOptions & setStripDebugInfo(bool value)
Definition Firtool.h:351
FirtoolOptions & setExportModuleHierarchy(bool value)
Definition Firtool.h:341
FirtoolOptions & setDisableUnknownAnnotations(bool disable)
Definition Firtool.h:153
bool shouldDisableWireElimination() const
Definition Firtool.h:139
FirtoolOptions & setEnableAnnotationWarning(bool value)
Definition Firtool.h:275
FirtoolOptions & setEtcDisableRegisterExtraction(bool value)
Definition Firtool.h:300
FirtoolOptions & setReplSeqMemFile(StringRef value)
Definition Firtool.h:250
bool shouldSelectDefaultInstanceChoice() const
Definition Firtool.h:132
FirtoolOptions & setLintStaticAsserts(bool value)
Definition Firtool.h:381
verif::SymbolicValueLowering symbolicValueLowering
Definition Firtool.h:445
bool getLintXmrsInDesign() const
Definition Firtool.h:143
FirtoolOptions & setSelectDefaultInstanceChoice(bool value)
Definition Firtool.h:366
FirtoolOptions & setStripFirDebugInfo(bool value)
Definition Firtool.h:346
seq::ExternalizeClockGateOptions getClockGateOptions() const
Definition Firtool.h:67
bool shouldEnableDebugInfo() const
Definition Firtool.h:102
bool shouldEmitSeparateAlwaysBlocks() const
Definition Firtool.h:122
FirtoolOptions & setOutputFilename(StringRef name)
Definition Firtool.h:148
FirtoolOptions & setBlackBoxRootPath(StringRef value)
Definition Firtool.h:240
@ 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:223
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:781
LogicalResult populateFinalizeIR(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:434
LogicalResult populateCHIRRTLToLowFIRRTL(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:55
SymbolicValueLowering
Ways to lower symbolic values.
Definition VerifPasses.h:29
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.