Loading [MathJax]/extensions/tex2jax.js
CIRCT 22.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 == "-"; }
102 bool shouldLowerMemories() const { return lowerMemories; }
103 bool shouldDedup() const { return !noDedup; }
104 bool shouldEnableDebugInfo() const { return enableDebugInfo; }
107 bool shouldConvertVecOfBundle() const { return vbToBV; }
117 bool shouldStripDebugInfo() const { return stripDebugInfo; }
128 bool shouldAddMuxPragmas() const { return addMuxPragmas; }
132 bool shouldExtractTestCode() const { return extractTestCode; }
139
144
146
147 bool getLintXmrsInDesign() const { return lintXmrsInDesign; }
148
149 // Setters, used by the CAPI
151 outputFilename = name;
152 return *this;
153 }
154
157 return *this;
158 }
159
162 return *this;
163 }
164
167 return *this;
168 }
169
172 return *this;
173 }
174
176 probesToSignals = value;
177 return *this;
178 }
179
185
188 preserveMode = value;
189 return *this;
190 }
191
193 enableDebugInfo = value;
194 return *this;
195 }
196
198 buildMode = value;
199 return *this;
200 }
201
203 disableLayerSink = value;
204 return *this;
205 }
206
208 disableOptimization = value;
209 return *this;
210 }
211
213 exportChiselInterface = value;
214 return *this;
215 }
216
219 return *this;
220 }
221
223 vbToBV = value;
224 return *this;
225 }
226
228 noDedup = value;
229 return *this;
230 }
231
233 companionMode = value;
234 return *this;
235 }
236
241
243 lowerMemories = value;
244 return *this;
245 }
246
248 blackBoxRootPath = value;
249 return *this;
250 }
251
253 replSeqMem = value;
254 return *this;
255 }
256
258 replSeqMemFile = value;
259 return *this;
260 }
261
263 extractTestCode = value;
264 return *this;
265 }
266
268 ignoreReadEnableMem = value;
269 return *this;
270 }
271
273 disableRandom = value;
274 return *this;
275 }
276
279 return *this;
280 }
281
284 return *this;
285 }
286
288 addMuxPragmas = value;
289 return *this;
290 }
291
296
299 return *this;
300 }
301
304 return *this;
305 }
306
309 return *this;
310 }
311
314 return *this;
315 }
316
322
324 ckgModuleName = value;
325 return *this;
326 }
327
328 FirtoolOptions &setCkgInputName(StringRef value) {
329 ckgInputName = value;
330 return *this;
331 }
332
334 ckgOutputName = value;
335 return *this;
336 }
337
339 ckgEnableName = value;
340 return *this;
341 }
342
344 ckgTestEnableName = value;
345 return *this;
346 }
347
349 exportModuleHierarchy = value;
350 return *this;
351 }
352
354 stripFirDebugInfo = value;
355 return *this;
356 }
357
359 stripDebugInfo = value;
360 return *this;
361 }
362
364 fixupEICGWrapper = value;
365 return *this;
366 }
367
369 addCompanionAssume = value;
370 return *this;
371 }
372
374 disableCSEinClasses = value;
375 return *this;
376 }
377
380 return *this;
381 }
382
387
390 return *this;
391 }
392
394 lintStaticAsserts = value;
395 return *this;
396 }
397
399 lintXmrsInDesign = value;
400 return *this;
401 }
402
403private:
404 std::string outputFilename;
405
406 // LowerFIRRTLAnnotations
411
421 bool vbToBV;
426 std::string blackBoxRootPath;
428 std::string replSeqMemFile;
441 std::string ckgModuleName;
442 std::string ckgInputName;
443 std::string ckgOutputName;
444 std::string ckgEnableName;
445 std::string ckgTestEnableName;
446 std::string ckgInstName;
458};
459
461
462LogicalResult populatePreprocessTransforms(mlir::PassManager &pm,
463 const FirtoolOptions &opt);
464
465LogicalResult populateCHIRRTLToLowFIRRTL(mlir::PassManager &pm,
466 const FirtoolOptions &opt);
467
468LogicalResult populateLowFIRRTLToHW(mlir::PassManager &pm,
469 const FirtoolOptions &opt,
470 StringRef inputFilename);
471
472LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt);
473
474LogicalResult populateExportVerilog(mlir::PassManager &pm,
475 const FirtoolOptions &opt,
476 std::unique_ptr<llvm::raw_ostream> os);
477
478LogicalResult populateExportVerilog(mlir::PassManager &pm,
479 const FirtoolOptions &opt,
480 llvm::raw_ostream &os);
481
482LogicalResult populateExportSplitVerilog(mlir::PassManager &pm,
483 const FirtoolOptions &opt,
484 llvm::StringRef directory);
485
486LogicalResult populateFinalizeIR(mlir::PassManager &pm,
487 const FirtoolOptions &opt);
488
489LogicalResult populateHWToBTOR2(mlir::PassManager &pm,
490 const FirtoolOptions &opt,
491 llvm::raw_ostream &os);
492
493} // namespace firtool
494} // namespace circt
495
496#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:363
FirtoolOptions & setPreserveAggregate(firrtl::PreserveAggregate::PreserveMode value)
Definition Firtool.h:181
FirtoolOptions & setAddVivadoRAMAddressConflictSynthesisBugWorkaround(bool value)
Definition Firtool.h:318
bool shouldStripDebugInfo() const
Definition Firtool.h:117
FirtoolOptions & setBuildMode(BuildMode value)
Definition Firtool.h:197
FirtoolOptions & setDisableAggressiveMergeConnections(bool value)
Definition Firtool.h:237
FirtoolOptions & setCkgInputName(StringRef value)
Definition Firtool.h:328
firrtl::PreserveAggregate::PreserveMode getPreserveAggregate() const
Definition Firtool.h:65
bool shouldAddVivadoRAMAddressConflictSynthesisBugWorkaround() const
Definition Firtool.h:129
bool shouldDisableLayerSink() const
Definition Firtool.h:100
FirtoolOptions & setExportChiselInterface(bool value)
Definition Firtool.h:212
firrtl::PreserveValues::PreserveMode preserveMode
Definition Firtool.h:414
bool shouldAddCompanionAssume() const
Definition Firtool.h:134
FirtoolOptions & setDisableCSEinClasses(bool value)
Definition Firtool.h:373
auto getVerificationFlavor() const
Definition Firtool.h:124
FirtoolOptions & setClockGateOptions(seq::ExternalizeClockGateOptions &opts)
Definition Firtool.h:75
FirtoolOptions & setCkgTestEnableName(StringRef value)
Definition Firtool.h:343
bool isDefaultOutputFilename() const
Definition Firtool.h:85
StringRef getOutputFilename() const
Definition Firtool.h:55
bool shouldDisableAggressiveMergeConnections() const
Definition Firtool.h:120
StringRef getReplaceSequentialMemoriesFile() const
Definition Firtool.h:60
bool addVivadoRAMAddressConflictSynthesisBugWorkaround
Definition Firtool.h:440
FirtoolOptions & setSymbolicValueLowering(verif::SymbolicValueLowering mode)
Definition Firtool.h:383
FirtoolOptions & setLowerMemories(bool value)
Definition Firtool.h:242
FirtoolOptions & setDisableRandom(RandomKind value)
Definition Firtool.h:272
bool shouldExportChiselInterface() const
Definition Firtool.h:106
FirtoolOptions & setAddCompanionAssume(bool value)
Definition Firtool.h:368
bool shouldExtractTestCode() const
Definition Firtool.h:132
FirtoolOptions & setNoDedup(bool value)
Definition Firtool.h:227
std::string chiselInterfaceOutDirectory
Definition Firtool.h:420
bool shouldFixupEICGWrapper() const
Definition Firtool.h:133
bool shouldConvertProbesToSignals() const
Definition Firtool.h:98
firrtl::PreserveValues::PreserveMode getPreserveMode() const
Definition Firtool.h:43
FirtoolOptions & setLowerAnnotationsNoRefTypePorts(bool value)
Definition Firtool.h:165
FirtoolOptions & setAllowAddingPortsOnPublic(bool value)
Definition Firtool.h:170
StringRef getBlackBoxRootPath() const
Definition Firtool.h:56
bool shouldDisableCSEinClasses() const
Definition Firtool.h:135
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:287
FirtoolOptions & setPreserveValues(firrtl::PreserveValues::PreserveMode value)
Definition Firtool.h:187
bool shouldReplaceSequentialMemories() const
Definition Firtool.h:99
bool shouldIgnoreReadEnableMemories() const
Definition Firtool.h:105
FirtoolOptions & setEtcDisableInstanceExtraction(bool value)
Definition Firtool.h:302
FirtoolOptions & setOutputAnnotationFilename(StringRef value)
Definition Firtool.h:277
FirtoolOptions & setCkgOutputName(StringRef value)
Definition Firtool.h:333
bool isRandomEnabled(RandomKind kind) const
Definition Firtool.h:39
bool shouldDisableUnknownAnnotations() const
Definition Firtool.h:86
FirtoolOptions & setVbToBV(bool value)
Definition Firtool.h:222
bool shouldAddMuxPragmas() const
Definition Firtool.h:128
bool shouldEnableAnnotationWarning() const
Definition Firtool.h:123
bool shouldEtcDisableInstanceExtraction() const
Definition Firtool.h:108
FirtoolOptions & setCkgModuleName(StringRef value)
Definition Firtool.h:323
bool shouldConvertVecOfBundle() const
Definition Firtool.h:107
StringRef getOutputAnnotationFilename() const
Definition Firtool.h:61
bool shouldStripFirDebugInfo() const
Definition Firtool.h:118
FirtoolOptions & setConvertProbesToSignals(bool value)
Definition Firtool.h:175
bool shouldEtcDisableRegisterExtraction() const
Definition Firtool.h:111
FirtoolOptions & setEtcDisableModuleInlining(bool value)
Definition Firtool.h:312
FirtoolOptions & setIgnoreReadEnableMem(bool value)
Definition Firtool.h:267
FirtoolOptions & setEnableDebugInfo(bool value)
Definition Firtool.h:192
FirtoolOptions & setDisableAnnotationsClassless(bool value)
Definition Firtool.h:160
FirtoolOptions & setDisableLayerSink(bool value)
Definition Firtool.h:202
FirtoolOptions & setEmitSeparateAlwaysBlocks(bool value)
Definition Firtool.h:297
FirtoolOptions & setDisableOptimization(bool value)
Definition Firtool.h:207
FirtoolOptions & setExtractTestCode(bool value)
Definition Firtool.h:262
std::string outputAnnotationFilename
Definition Firtool.h:432
firrtl::VerificationFlavor verificationFlavor
Definition Firtool.h:435
firrtl::PreserveAggregate::PreserveMode preserveAggregate
Definition Firtool.h:413
FirtoolOptions & setLintXmrsInDesign(bool value)
Definition Firtool.h:398
bool shouldLowerMemories() const
Definition Firtool.h:102
FirtoolOptions & setDisableWireElimination(bool value)
Definition Firtool.h:388
bool shouldEtcDisableModuleInlining() const
Definition Firtool.h:114
FirtoolOptions & setCompanionMode(firrtl::CompanionMode value)
Definition Firtool.h:232
bool shouldAllowAddingPortsOnPublic() const
Definition Firtool.h:95
FirtoolOptions & setChiselInterfaceOutDirectory(StringRef value)
Definition Firtool.h:217
FirtoolOptions & setVerificationFlavor(firrtl::VerificationFlavor value)
Definition Firtool.h:292
bool getLintStaticAsserts() const
Definition Firtool.h:145
bool shouldLowerNoRefTypePortAnnotations() const
Definition Firtool.h:92
FirtoolOptions & setReplSeqMem(bool value)
Definition Firtool.h:252
verif::SymbolicValueLowering getSymbolicValueLowering() const
Definition Firtool.h:140
FirtoolOptions & setCkgEnableName(StringRef value)
Definition Firtool.h:338
bool shouldExportModuleHierarchy() const
Definition Firtool.h:119
firrtl::CompanionMode companionMode
Definition Firtool.h:423
FirtoolOptions & setStripDebugInfo(bool value)
Definition Firtool.h:358
FirtoolOptions & setExportModuleHierarchy(bool value)
Definition Firtool.h:348
FirtoolOptions & setDisableUnknownAnnotations(bool disable)
Definition Firtool.h:155
bool shouldDisableWireElimination() const
Definition Firtool.h:143
FirtoolOptions & setEnableAnnotationWarning(bool value)
Definition Firtool.h:282
FirtoolOptions & setEtcDisableRegisterExtraction(bool value)
Definition Firtool.h:307
FirtoolOptions & setReplSeqMemFile(StringRef value)
Definition Firtool.h:257
bool shouldSelectDefaultInstanceChoice() const
Definition Firtool.h:136
FirtoolOptions & setLintStaticAsserts(bool value)
Definition Firtool.h:393
verif::SymbolicValueLowering symbolicValueLowering
Definition Firtool.h:454
bool getLintXmrsInDesign() const
Definition Firtool.h:147
FirtoolOptions & setSelectDefaultInstanceChoice(bool value)
Definition Firtool.h:378
FirtoolOptions & setStripFirDebugInfo(bool value)
Definition Firtool.h:353
seq::ExternalizeClockGateOptions getClockGateOptions() const
Definition Firtool.h:70
bool shouldEnableDebugInfo() const
Definition Firtool.h:104
bool shouldEmitSeparateAlwaysBlocks() const
Definition Firtool.h:125
FirtoolOptions & setOutputFilename(StringRef name)
Definition Firtool.h:150
StringRef getChiselInterfaceOutputDirectory() const
Definition Firtool.h:57
FirtoolOptions & setBlackBoxRootPath(StringRef value)
Definition Firtool.h:247
@ 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:236
LogicalResult populateHWToBTOR2(mlir::PassManager &pm, const FirtoolOptions &opt, llvm::raw_ostream &os)
Definition Firtool.cpp:453
LogicalResult populateExportSplitVerilog(mlir::PassManager &pm, const FirtoolOptions &opt, llvm::StringRef directory)
Definition Firtool.cpp:435
LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:320
LogicalResult populateExportVerilog(mlir::PassManager &pm, const FirtoolOptions &opt, std::unique_ptr< llvm::raw_ostream > os)
Definition Firtool.cpp:416
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:798
LogicalResult populateFinalizeIR(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:445
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.