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
144
145 // Setters, used by the CAPI
147 outputFilename = name;
148 return *this;
149 }
150
153 return *this;
154 }
155
158 return *this;
159 }
160
163 return *this;
164 }
165
168 return *this;
169 }
170
172 probesToSignals = value;
173 return *this;
174 }
175
181
184 preserveMode = value;
185 return *this;
186 }
187
189 enableDebugInfo = value;
190 return *this;
191 }
192
194 buildMode = value;
195 return *this;
196 }
197
199 disableLayerSink = value;
200 return *this;
201 }
202
204 disableOptimization = value;
205 return *this;
206 }
207
209 exportChiselInterface = value;
210 return *this;
211 }
212
215 return *this;
216 }
217
219 vbToBV = value;
220 return *this;
221 }
222
224 noDedup = value;
225 return *this;
226 }
227
229 companionMode = value;
230 return *this;
231 }
232
237
239 advancedLayerSink = value;
240 return *this;
241 }
242
244 lowerMemories = value;
245 return *this;
246 }
247
249 blackBoxRootPath = value;
250 return *this;
251 }
252
254 replSeqMem = value;
255 return *this;
256 }
257
259 replSeqMemFile = value;
260 return *this;
261 }
262
264 extractTestCode = value;
265 return *this;
266 }
267
269 ignoreReadEnableMem = value;
270 return *this;
271 }
272
274 disableRandom = value;
275 return *this;
276 }
277
280 return *this;
281 }
282
285 return *this;
286 }
287
289 addMuxPragmas = value;
290 return *this;
291 }
292
297
300 return *this;
301 }
302
305 return *this;
306 }
307
310 return *this;
311 }
312
315 return *this;
316 }
317
323
325 ckgModuleName = value;
326 return *this;
327 }
328
329 FirtoolOptions &setCkgInputName(StringRef value) {
330 ckgInputName = value;
331 return *this;
332 }
333
335 ckgOutputName = value;
336 return *this;
337 }
338
340 ckgEnableName = value;
341 return *this;
342 }
343
345 ckgTestEnableName = value;
346 return *this;
347 }
348
350 exportModuleHierarchy = value;
351 return *this;
352 }
353
355 stripFirDebugInfo = value;
356 return *this;
357 }
358
360 stripDebugInfo = value;
361 return *this;
362 }
363
365 fixupEICGWrapper = value;
366 return *this;
367 }
368
370 addCompanionAssume = value;
371 return *this;
372 }
373
375 disableCSEinClasses = value;
376 return *this;
377 }
378
381 return *this;
382 }
383
388
389private:
390 std::string outputFilename;
404 bool vbToBV;
410 std::string blackBoxRootPath;
412 std::string replSeqMemFile;
425 std::string ckgModuleName;
426 std::string ckgInputName;
427 std::string ckgOutputName;
428 std::string ckgEnableName;
429 std::string ckgTestEnableName;
430 std::string ckgInstName;
439};
440
442
443LogicalResult populatePreprocessTransforms(mlir::PassManager &pm,
444 const FirtoolOptions &opt);
445
446LogicalResult populateCHIRRTLToLowFIRRTL(mlir::PassManager &pm,
447 const FirtoolOptions &opt,
448 StringRef inputFilename);
449
450LogicalResult populateLowFIRRTLToHW(mlir::PassManager &pm,
451 const FirtoolOptions &opt);
452
453LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt);
454
455LogicalResult populateExportVerilog(mlir::PassManager &pm,
456 const FirtoolOptions &opt,
457 std::unique_ptr<llvm::raw_ostream> os);
458
459LogicalResult populateExportVerilog(mlir::PassManager &pm,
460 const FirtoolOptions &opt,
461 llvm::raw_ostream &os);
462
463LogicalResult populateExportSplitVerilog(mlir::PassManager &pm,
464 const FirtoolOptions &opt,
465 llvm::StringRef directory);
466
467LogicalResult populateFinalizeIR(mlir::PassManager &pm,
468 const FirtoolOptions &opt);
469
470LogicalResult populateHWToBTOR2(mlir::PassManager &pm,
471 const FirtoolOptions &opt,
472 llvm::raw_ostream &os);
473
474} // namespace firtool
475} // namespace circt
476
477#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:364
FirtoolOptions & setPreserveAggregate(firrtl::PreserveAggregate::PreserveMode value)
Definition Firtool.h:177
FirtoolOptions & setAddVivadoRAMAddressConflictSynthesisBugWorkaround(bool value)
Definition Firtool.h:319
bool shouldStripDebugInfo() const
Definition Firtool.h:118
FirtoolOptions & setBuildMode(BuildMode value)
Definition Firtool.h:193
FirtoolOptions & setAdvancedLayerSink(bool value)
Definition Firtool.h:238
FirtoolOptions & setDisableAggressiveMergeConnections(bool value)
Definition Firtool.h:233
FirtoolOptions & setCkgInputName(StringRef value)
Definition Firtool.h:329
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:208
firrtl::PreserveValues::PreserveMode preserveMode
Definition Firtool.h:397
bool shouldAddCompanionAssume() const
Definition Firtool.h:135
FirtoolOptions & setDisableCSEinClasses(bool value)
Definition Firtool.h:374
auto getVerificationFlavor() const
Definition Firtool.h:125
FirtoolOptions & setClockGateOptions(seq::ExternalizeClockGateOptions &opts)
Definition Firtool.h:75
FirtoolOptions & setCkgTestEnableName(StringRef value)
Definition Firtool.h:344
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:424
FirtoolOptions & setSymbolicValueLowering(verif::SymbolicValueLowering mode)
Definition Firtool.h:384
FirtoolOptions & setLowerMemories(bool value)
Definition Firtool.h:243
FirtoolOptions & setDisableRandom(RandomKind value)
Definition Firtool.h:273
bool shouldExportChiselInterface() const
Definition Firtool.h:107
bool shouldAdvancedLayerSink() const
Definition Firtool.h:102
FirtoolOptions & setAddCompanionAssume(bool value)
Definition Firtool.h:369
bool shouldExtractTestCode() const
Definition Firtool.h:133
FirtoolOptions & setNoDedup(bool value)
Definition Firtool.h:223
std::string chiselInterfaceOutDirectory
Definition Firtool.h:403
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:161
FirtoolOptions & setAllowAddingPortsOnPublic(bool value)
Definition Firtool.h:166
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:288
FirtoolOptions & setPreserveValues(firrtl::PreserveValues::PreserveMode value)
Definition Firtool.h:183
bool shouldReplaceSequentialMemories() const
Definition Firtool.h:99
bool shouldIgnoreReadEnableMemories() const
Definition Firtool.h:106
FirtoolOptions & setEtcDisableInstanceExtraction(bool value)
Definition Firtool.h:303
FirtoolOptions & setOutputAnnotationFilename(StringRef value)
Definition Firtool.h:278
FirtoolOptions & setCkgOutputName(StringRef value)
Definition Firtool.h:334
bool isRandomEnabled(RandomKind kind) const
Definition Firtool.h:39
bool shouldDisableUnknownAnnotations() const
Definition Firtool.h:86
FirtoolOptions & setVbToBV(bool value)
Definition Firtool.h:218
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:324
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:171
bool shouldEtcDisableRegisterExtraction() const
Definition Firtool.h:112
FirtoolOptions & setEtcDisableModuleInlining(bool value)
Definition Firtool.h:313
FirtoolOptions & setIgnoreReadEnableMem(bool value)
Definition Firtool.h:268
FirtoolOptions & setEnableDebugInfo(bool value)
Definition Firtool.h:188
FirtoolOptions & setDisableAnnotationsClassless(bool value)
Definition Firtool.h:156
FirtoolOptions & setDisableLayerSink(bool value)
Definition Firtool.h:198
FirtoolOptions & setEmitSeparateAlwaysBlocks(bool value)
Definition Firtool.h:298
FirtoolOptions & setDisableOptimization(bool value)
Definition Firtool.h:203
FirtoolOptions & setExtractTestCode(bool value)
Definition Firtool.h:263
std::string outputAnnotationFilename
Definition Firtool.h:416
firrtl::VerificationFlavor verificationFlavor
Definition Firtool.h:419
firrtl::PreserveAggregate::PreserveMode preserveAggregate
Definition Firtool.h:396
bool shouldLowerMemories() const
Definition Firtool.h:103
bool shouldEtcDisableModuleInlining() const
Definition Firtool.h:115
FirtoolOptions & setCompanionMode(firrtl::CompanionMode value)
Definition Firtool.h:228
bool shouldAllowAddingPortsOnPublic() const
Definition Firtool.h:95
FirtoolOptions & setChiselInterfaceOutDirectory(StringRef value)
Definition Firtool.h:213
FirtoolOptions & setVerificationFlavor(firrtl::VerificationFlavor value)
Definition Firtool.h:293
bool shouldLowerNoRefTypePortAnnotations() const
Definition Firtool.h:92
FirtoolOptions & setReplSeqMem(bool value)
Definition Firtool.h:253
verif::SymbolicValueLowering getSymbolicValueLowering() const
Definition Firtool.h:141
FirtoolOptions & setCkgEnableName(StringRef value)
Definition Firtool.h:339
bool shouldExportModuleHierarchy() const
Definition Firtool.h:120
firrtl::CompanionMode companionMode
Definition Firtool.h:406
FirtoolOptions & setStripDebugInfo(bool value)
Definition Firtool.h:359
FirtoolOptions & setExportModuleHierarchy(bool value)
Definition Firtool.h:349
FirtoolOptions & setDisableUnknownAnnotations(bool disable)
Definition Firtool.h:151
FirtoolOptions & setEnableAnnotationWarning(bool value)
Definition Firtool.h:283
FirtoolOptions & setEtcDisableRegisterExtraction(bool value)
Definition Firtool.h:308
FirtoolOptions & setReplSeqMemFile(StringRef value)
Definition Firtool.h:258
bool shouldSelectDefaultInstanceChoice() const
Definition Firtool.h:137
verif::SymbolicValueLowering symbolicValueLowering
Definition Firtool.h:438
FirtoolOptions & setSelectDefaultInstanceChoice(bool value)
Definition Firtool.h:379
FirtoolOptions & setStripFirDebugInfo(bool value)
Definition Firtool.h:354
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:146
StringRef getChiselInterfaceOutputDirectory() const
Definition Firtool.h:57
FirtoolOptions & setBlackBoxRootPath(StringRef value)
Definition Firtool.h:248
@ None
Don't explicitly preserve any named values.
Definition Passes.h:54
LogicalResult populateHWToBTOR2(mlir::PassManager &pm, const FirtoolOptions &opt, llvm::raw_ostream &os)
Definition Firtool.cpp:438
LogicalResult populateExportSplitVerilog(mlir::PassManager &pm, const FirtoolOptions &opt, llvm::StringRef directory)
Definition Firtool.cpp:420
LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:305
LogicalResult populateLowFIRRTLToHW(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:264
LogicalResult populateExportVerilog(mlir::PassManager &pm, const FirtoolOptions &opt, std::unique_ptr< llvm::raw_ostream > os)
Definition Firtool.cpp:401
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:771
LogicalResult populateFinalizeIR(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:430
LogicalResult populateCHIRRTLToLowFIRRTL(mlir::PassManager &pm, const FirtoolOptions &opt, StringRef inputFilename)
Definition Firtool.cpp:55
SymbolicValueLowering
Ways to lower symbolic values.
Definition VerifPasses.h:29
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.