Loading [MathJax]/extensions/tex2jax.js
CIRCT 21.0.0git
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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; }
61 StringRef getOutputAnnotationFilename() const {
63 }
64
69
70 seq::ExternalizeClockGateOptions getClockGateOptions() const {
73 }
74
75 FirtoolOptions &setClockGateOptions(seq::ExternalizeClockGateOptions &opts) {
76 ckgModuleName = opts.moduleName;
77 ckgInputName = opts.inputName;
78 ckgOutputName = opts.outputName;
79 ckgEnableName = opts.enableName;
80 ckgTestEnableName = opts.testEnableName;
81 ckgInstName = opts.instName;
82 return *this;
83 }
84
85 bool isDefaultOutputFilename() const { return outputFilename == "-"; }
103 bool shouldLowerMemories() const { return lowerMemories; }
104 bool shouldDedup() const { return !noDedup; }
105 bool shouldEnableDebugInfo() const { return enableDebugInfo; }
108 bool shouldConvertVecOfBundle() const { return vbToBV; }
118 bool shouldStripDebugInfo() const { return stripDebugInfo; }
129 bool shouldAddMuxPragmas() const { return addMuxPragmas; }
133 bool shouldExtractTestCode() const { return extractTestCode; }
140
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
169 return *this;
170 }
171
173 probesToSignals = value;
174 return *this;
175 }
176
182
185 preserveMode = value;
186 return *this;
187 }
188
190 enableDebugInfo = value;
191 return *this;
192 }
193
195 buildMode = value;
196 return *this;
197 }
198
200 disableLayerSink = value;
201 return *this;
202 }
203
205 disableOptimization = value;
206 return *this;
207 }
208
210 exportChiselInterface = value;
211 return *this;
212 }
213
216 return *this;
217 }
218
220 vbToBV = value;
221 return *this;
222 }
223
225 noDedup = value;
226 return *this;
227 }
228
230 companionMode = value;
231 return *this;
232 }
233
238
240 advancedLayerSink = value;
241 return *this;
242 }
243
245 lowerMemories = value;
246 return *this;
247 }
248
250 blackBoxRootPath = value;
251 return *this;
252 }
253
255 replSeqMem = value;
256 return *this;
257 }
258
260 replSeqMemFile = value;
261 return *this;
262 }
263
265 extractTestCode = value;
266 return *this;
267 }
268
270 ignoreReadEnableMem = value;
271 return *this;
272 }
273
275 disableRandom = value;
276 return *this;
277 }
278
281 return *this;
282 }
283
286 return *this;
287 }
288
290 addMuxPragmas = value;
291 return *this;
292 }
293
298
301 return *this;
302 }
303
306 return *this;
307 }
308
311 return *this;
312 }
313
316 return *this;
317 }
318
324
326 ckgModuleName = value;
327 return *this;
328 }
329
330 FirtoolOptions &setCkgInputName(StringRef value) {
331 ckgInputName = value;
332 return *this;
333 }
334
336 ckgOutputName = value;
337 return *this;
338 }
339
341 ckgEnableName = value;
342 return *this;
343 }
344
346 ckgTestEnableName = value;
347 return *this;
348 }
349
351 exportModuleHierarchy = value;
352 return *this;
353 }
354
356 stripFirDebugInfo = value;
357 return *this;
358 }
359
361 stripDebugInfo = value;
362 return *this;
363 }
364
366 fixupEICGWrapper = value;
367 return *this;
368 }
369
371 addCompanionAssume = value;
372 return *this;
373 }
374
376 disableCSEinClasses = value;
377 return *this;
378 }
379
382 return *this;
383 }
384
389
392 return *this;
393 }
394
395private:
396 std::string outputFilename;
410 bool vbToBV;
416 std::string blackBoxRootPath;
418 std::string replSeqMemFile;
431 std::string ckgModuleName;
432 std::string ckgInputName;
433 std::string ckgOutputName;
434 std::string ckgEnableName;
435 std::string ckgTestEnableName;
436 std::string ckgInstName;
446};
447
449
450LogicalResult populatePreprocessTransforms(mlir::PassManager &pm,
451 const FirtoolOptions &opt);
452
453LogicalResult populateCHIRRTLToLowFIRRTL(mlir::PassManager &pm,
454 const FirtoolOptions &opt);
455
456LogicalResult populateLowFIRRTLToHW(mlir::PassManager &pm,
457 const FirtoolOptions &opt,
458 StringRef inputFilename);
459
460LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt);
461
462LogicalResult populateExportVerilog(mlir::PassManager &pm,
463 const FirtoolOptions &opt,
464 std::unique_ptr<llvm::raw_ostream> os);
465
466LogicalResult populateExportVerilog(mlir::PassManager &pm,
467 const FirtoolOptions &opt,
468 llvm::raw_ostream &os);
469
470LogicalResult populateExportSplitVerilog(mlir::PassManager &pm,
471 const FirtoolOptions &opt,
472 llvm::StringRef directory);
473
474LogicalResult populateFinalizeIR(mlir::PassManager &pm,
475 const FirtoolOptions &opt);
476
477LogicalResult populateHWToBTOR2(mlir::PassManager &pm,
478 const FirtoolOptions &opt,
479 llvm::raw_ostream &os);
480
481} // namespace firtool
482} // namespace circt
483
484#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:365
FirtoolOptions & setPreserveAggregate(firrtl::PreserveAggregate::PreserveMode value)
Definition Firtool.h:178
FirtoolOptions & setAddVivadoRAMAddressConflictSynthesisBugWorkaround(bool value)
Definition Firtool.h:320
bool shouldStripDebugInfo() const
Definition Firtool.h:118
FirtoolOptions & setBuildMode(BuildMode value)
Definition Firtool.h:194
FirtoolOptions & setAdvancedLayerSink(bool value)
Definition Firtool.h:239
FirtoolOptions & setDisableAggressiveMergeConnections(bool value)
Definition Firtool.h:234
FirtoolOptions & setCkgInputName(StringRef value)
Definition Firtool.h:330
firrtl::PreserveAggregate::PreserveMode getPreserveAggregate() const
Definition Firtool.h:65
bool shouldAddVivadoRAMAddressConflictSynthesisBugWorkaround() const
Definition Firtool.h:130
bool shouldDisableLayerSink() const
Definition Firtool.h:100
FirtoolOptions & setExportChiselInterface(bool value)
Definition Firtool.h:209
firrtl::PreserveValues::PreserveMode preserveMode
Definition Firtool.h:403
bool shouldAddCompanionAssume() const
Definition Firtool.h:135
FirtoolOptions & setDisableCSEinClasses(bool value)
Definition Firtool.h:375
auto getVerificationFlavor() const
Definition Firtool.h:125
FirtoolOptions & setClockGateOptions(seq::ExternalizeClockGateOptions &opts)
Definition Firtool.h:75
FirtoolOptions & setCkgTestEnableName(StringRef value)
Definition Firtool.h:345
bool isDefaultOutputFilename() const
Definition Firtool.h:85
StringRef getOutputFilename() const
Definition Firtool.h:55
bool shouldDisableAggressiveMergeConnections() const
Definition Firtool.h:121
StringRef getReplaceSequentialMemoriesFile() const
Definition Firtool.h:60
bool addVivadoRAMAddressConflictSynthesisBugWorkaround
Definition Firtool.h:430
FirtoolOptions & setSymbolicValueLowering(verif::SymbolicValueLowering mode)
Definition Firtool.h:385
FirtoolOptions & setLowerMemories(bool value)
Definition Firtool.h:244
FirtoolOptions & setDisableRandom(RandomKind value)
Definition Firtool.h:274
bool shouldExportChiselInterface() const
Definition Firtool.h:107
bool shouldAdvancedLayerSink() const
Definition Firtool.h:102
FirtoolOptions & setAddCompanionAssume(bool value)
Definition Firtool.h:370
bool shouldExtractTestCode() const
Definition Firtool.h:133
FirtoolOptions & setNoDedup(bool value)
Definition Firtool.h:224
std::string chiselInterfaceOutDirectory
Definition Firtool.h:409
bool shouldFixupEICGWrapper() const
Definition Firtool.h:134
bool shouldConvertProbesToSignals() const
Definition Firtool.h:98
firrtl::PreserveValues::PreserveMode getPreserveMode() const
Definition Firtool.h:43
FirtoolOptions & setLowerAnnotationsNoRefTypePorts(bool value)
Definition Firtool.h:162
FirtoolOptions & setAllowAddingPortsOnPublic(bool value)
Definition Firtool.h:167
StringRef getBlackBoxRootPath() const
Definition Firtool.h:56
bool shouldDisableCSEinClasses() const
Definition Firtool.h:136
bool shouldDisableOptimization() const
Definition Firtool.h:101
firrtl::CompanionMode getCompanionMode() const
Definition Firtool.h:68
bool shouldDisableClasslessAnnotations() const
Definition Firtool.h:89
FirtoolOptions & setAddMuxPragmas(bool value)
Definition Firtool.h:289
FirtoolOptions & setPreserveValues(firrtl::PreserveValues::PreserveMode value)
Definition Firtool.h:184
bool shouldReplaceSequentialMemories() const
Definition Firtool.h:99
bool shouldIgnoreReadEnableMemories() const
Definition Firtool.h:106
FirtoolOptions & setEtcDisableInstanceExtraction(bool value)
Definition Firtool.h:304
FirtoolOptions & setOutputAnnotationFilename(StringRef value)
Definition Firtool.h:279
FirtoolOptions & setCkgOutputName(StringRef value)
Definition Firtool.h:335
bool isRandomEnabled(RandomKind kind) const
Definition Firtool.h:39
bool shouldDisableUnknownAnnotations() const
Definition Firtool.h:86
FirtoolOptions & setVbToBV(bool value)
Definition Firtool.h:219
bool shouldAddMuxPragmas() const
Definition Firtool.h:129
bool shouldEnableAnnotationWarning() const
Definition Firtool.h:124
bool shouldEtcDisableInstanceExtraction() const
Definition Firtool.h:109
FirtoolOptions & setCkgModuleName(StringRef value)
Definition Firtool.h:325
bool shouldConvertVecOfBundle() const
Definition Firtool.h:108
StringRef getOutputAnnotationFilename() const
Definition Firtool.h:61
bool shouldStripFirDebugInfo() const
Definition Firtool.h:119
FirtoolOptions & setConvertProbesToSignals(bool value)
Definition Firtool.h:172
bool shouldEtcDisableRegisterExtraction() const
Definition Firtool.h:112
FirtoolOptions & setEtcDisableModuleInlining(bool value)
Definition Firtool.h:314
FirtoolOptions & setIgnoreReadEnableMem(bool value)
Definition Firtool.h:269
FirtoolOptions & setEnableDebugInfo(bool value)
Definition Firtool.h:189
FirtoolOptions & setDisableAnnotationsClassless(bool value)
Definition Firtool.h:157
FirtoolOptions & setDisableLayerSink(bool value)
Definition Firtool.h:199
FirtoolOptions & setEmitSeparateAlwaysBlocks(bool value)
Definition Firtool.h:299
FirtoolOptions & setDisableOptimization(bool value)
Definition Firtool.h:204
FirtoolOptions & setExtractTestCode(bool value)
Definition Firtool.h:264
std::string outputAnnotationFilename
Definition Firtool.h:422
firrtl::VerificationFlavor verificationFlavor
Definition Firtool.h:425
firrtl::PreserveAggregate::PreserveMode preserveAggregate
Definition Firtool.h:402
bool shouldLowerMemories() const
Definition Firtool.h:103
FirtoolOptions & setDisableWireElimination(bool value)
Definition Firtool.h:390
bool shouldEtcDisableModuleInlining() const
Definition Firtool.h:115
FirtoolOptions & setCompanionMode(firrtl::CompanionMode value)
Definition Firtool.h:229
bool shouldAllowAddingPortsOnPublic() const
Definition Firtool.h:95
FirtoolOptions & setChiselInterfaceOutDirectory(StringRef value)
Definition Firtool.h:214
FirtoolOptions & setVerificationFlavor(firrtl::VerificationFlavor value)
Definition Firtool.h:294
bool shouldLowerNoRefTypePortAnnotations() const
Definition Firtool.h:92
FirtoolOptions & setReplSeqMem(bool value)
Definition Firtool.h:254
verif::SymbolicValueLowering getSymbolicValueLowering() const
Definition Firtool.h:141
FirtoolOptions & setCkgEnableName(StringRef value)
Definition Firtool.h:340
bool shouldExportModuleHierarchy() const
Definition Firtool.h:120
firrtl::CompanionMode companionMode
Definition Firtool.h:412
FirtoolOptions & setStripDebugInfo(bool value)
Definition Firtool.h:360
FirtoolOptions & setExportModuleHierarchy(bool value)
Definition Firtool.h:350
FirtoolOptions & setDisableUnknownAnnotations(bool disable)
Definition Firtool.h:152
bool shouldDisableWireElimination() const
Definition Firtool.h:144
FirtoolOptions & setEnableAnnotationWarning(bool value)
Definition Firtool.h:284
FirtoolOptions & setEtcDisableRegisterExtraction(bool value)
Definition Firtool.h:309
FirtoolOptions & setReplSeqMemFile(StringRef value)
Definition Firtool.h:259
bool shouldSelectDefaultInstanceChoice() const
Definition Firtool.h:137
verif::SymbolicValueLowering symbolicValueLowering
Definition Firtool.h:444
FirtoolOptions & setSelectDefaultInstanceChoice(bool value)
Definition Firtool.h:380
FirtoolOptions & setStripFirDebugInfo(bool value)
Definition Firtool.h:355
seq::ExternalizeClockGateOptions getClockGateOptions() const
Definition Firtool.h:70
bool shouldEnableDebugInfo() const
Definition Firtool.h:105
bool shouldEmitSeparateAlwaysBlocks() const
Definition Firtool.h:126
FirtoolOptions & setOutputFilename(StringRef name)
Definition Firtool.h:147
StringRef getChiselInterfaceOutputDirectory() const
Definition Firtool.h:57
FirtoolOptions & setBlackBoxRootPath(StringRef value)
Definition Firtool.h:249
@ None
Don't explicitly preserve any named values.
Definition Passes.h:54
LogicalResult populateLowFIRRTLToHW(mlir::PassManager &pm, const FirtoolOptions &opt, StringRef inputFilename)
Definition Firtool.cpp:232
LogicalResult populateHWToBTOR2(mlir::PassManager &pm, const FirtoolOptions &opt, llvm::raw_ostream &os)
Definition Firtool.cpp:454
LogicalResult populateExportSplitVerilog(mlir::PassManager &pm, const FirtoolOptions &opt, llvm::StringRef directory)
Definition Firtool.cpp:436
LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:321
LogicalResult populateExportVerilog(mlir::PassManager &pm, const FirtoolOptions &opt, std::unique_ptr< llvm::raw_ostream > os)
Definition Firtool.cpp:417
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:791
LogicalResult populateFinalizeIR(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:446
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.