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 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
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 vbToBV = value;
211 return *this;
212 }
213
215 noDedup = value;
216 return *this;
217 }
218
220 companionMode = value;
221 return *this;
222 }
223
228
230 lowerMemories = value;
231 return *this;
232 }
233
235 blackBoxRootPath = value;
236 return *this;
237 }
238
240 replSeqMem = value;
241 return *this;
242 }
243
245 replSeqMemFile = value;
246 return *this;
247 }
248
250 extractTestCode = value;
251 return *this;
252 }
253
255 ignoreReadEnableMem = value;
256 return *this;
257 }
258
260 disableRandom = value;
261 return *this;
262 }
263
266 return *this;
267 }
268
271 return *this;
272 }
273
275 addMuxPragmas = value;
276 return *this;
277 }
278
283
286 return *this;
287 }
288
291 return *this;
292 }
293
296 return *this;
297 }
298
301 return *this;
302 }
303
309
311 ckgModuleName = value;
312 return *this;
313 }
314
315 FirtoolOptions &setCkgInputName(StringRef value) {
316 ckgInputName = value;
317 return *this;
318 }
319
321 ckgOutputName = value;
322 return *this;
323 }
324
326 ckgEnableName = value;
327 return *this;
328 }
329
331 ckgTestEnableName = value;
332 return *this;
333 }
334
336 exportModuleHierarchy = value;
337 return *this;
338 }
339
341 stripFirDebugInfo = value;
342 return *this;
343 }
344
346 stripDebugInfo = value;
347 return *this;
348 }
349
351 fixupEICGWrapper = value;
352 return *this;
353 }
354
356 disableCSEinClasses = value;
357 return *this;
358 }
359
362 return *this;
363 }
364
369
372 return *this;
373 }
374
376 lintStaticAsserts = value;
377 return *this;
378 }
379
381 lintXmrsInDesign = value;
382 return *this;
383 }
384
386 emitAllBindFiles = value;
387 return *this;
388 }
389
390private:
391 std::string outputFilename;
392
393 // LowerFIRRTLAnnotations
398
406 bool vbToBV;
411 std::string blackBoxRootPath;
413 std::string replSeqMemFile;
426 std::string ckgModuleName;
427 std::string ckgInputName;
428 std::string ckgOutputName;
429 std::string ckgEnableName;
430 std::string ckgTestEnableName;
431 std::string ckgInstName;
443};
444
446
447LogicalResult populatePreprocessTransforms(mlir::PassManager &pm,
448 const FirtoolOptions &opt);
449
450LogicalResult populateCHIRRTLToLowFIRRTL(mlir::PassManager &pm,
451 const FirtoolOptions &opt);
452
453LogicalResult populateLowFIRRTLToHW(mlir::PassManager &pm,
454 const FirtoolOptions &opt,
455 StringRef inputFilename);
456
457LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt);
458
459LogicalResult populateExportVerilog(mlir::PassManager &pm,
460 const FirtoolOptions &opt,
461 std::unique_ptr<llvm::raw_ostream> os);
462
463LogicalResult populateExportVerilog(mlir::PassManager &pm,
464 const FirtoolOptions &opt,
465 llvm::raw_ostream &os);
466
467LogicalResult populateExportSplitVerilog(mlir::PassManager &pm,
468 const FirtoolOptions &opt,
469 llvm::StringRef directory);
470
471LogicalResult populateFinalizeIR(mlir::PassManager &pm,
472 const FirtoolOptions &opt);
473
474LogicalResult populateHWToBTOR2(mlir::PassManager &pm,
475 const FirtoolOptions &opt,
476 llvm::raw_ostream &os);
477
478} // namespace firtool
479} // namespace circt
480
481#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:350
FirtoolOptions & setPreserveAggregate(firrtl::PreserveAggregate::PreserveMode value)
Definition Firtool.h:178
FirtoolOptions & setAddVivadoRAMAddressConflictSynthesisBugWorkaround(bool value)
Definition Firtool.h:305
bool shouldStripDebugInfo() const
Definition Firtool.h:113
FirtoolOptions & setBuildMode(BuildMode value)
Definition Firtool.h:194
FirtoolOptions & setDisableAggressiveMergeConnections(bool value)
Definition Firtool.h:224
FirtoolOptions & setCkgInputName(StringRef value)
Definition Firtool.h:315
firrtl::PreserveAggregate::PreserveMode getPreserveAggregate() const
Definition Firtool.h:62
bool shouldAddVivadoRAMAddressConflictSynthesisBugWorkaround() const
Definition Firtool.h:125
bool shouldDisableLayerSink() const
Definition Firtool.h:97
firrtl::PreserveValues::PreserveMode preserveMode
Definition Firtool.h:401
FirtoolOptions & setDisableCSEinClasses(bool value)
Definition Firtool.h:355
auto getVerificationFlavor() const
Definition Firtool.h:120
FirtoolOptions & setClockGateOptions(seq::ExternalizeClockGateOptions &opts)
Definition Firtool.h:72
FirtoolOptions & setCkgTestEnableName(StringRef value)
Definition Firtool.h:330
bool isDefaultOutputFilename() const
Definition Firtool.h:82
StringRef getOutputFilename() const
Definition Firtool.h:55
bool shouldDisableAggressiveMergeConnections() const
Definition Firtool.h:116
StringRef getReplaceSequentialMemoriesFile() const
Definition Firtool.h:57
bool addVivadoRAMAddressConflictSynthesisBugWorkaround
Definition Firtool.h:425
FirtoolOptions & setSymbolicValueLowering(verif::SymbolicValueLowering mode)
Definition Firtool.h:365
FirtoolOptions & setLowerMemories(bool value)
Definition Firtool.h:229
FirtoolOptions & setDisableRandom(RandomKind value)
Definition Firtool.h:259
bool shouldExtractTestCode() const
Definition Firtool.h:128
FirtoolOptions & setNoDedup(bool value)
Definition Firtool.h:214
bool shouldFixupEICGWrapper() const
Definition Firtool.h:129
bool shouldConvertProbesToSignals() const
Definition Firtool.h:95
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:130
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:274
FirtoolOptions & setPreserveValues(firrtl::PreserveValues::PreserveMode value)
Definition Firtool.h:184
bool getEmitAllBindFiles() const
Definition Firtool.h:144
bool shouldReplaceSequentialMemories() const
Definition Firtool.h:96
bool shouldIgnoreReadEnableMemories() const
Definition Firtool.h:102
FirtoolOptions & setEtcDisableInstanceExtraction(bool value)
Definition Firtool.h:289
FirtoolOptions & setOutputAnnotationFilename(StringRef value)
Definition Firtool.h:264
FirtoolOptions & setCkgOutputName(StringRef value)
Definition Firtool.h:320
bool isRandomEnabled(RandomKind kind) const
Definition Firtool.h:39
bool shouldDisableUnknownAnnotations() const
Definition Firtool.h:83
FirtoolOptions & setVbToBV(bool value)
Definition Firtool.h:209
bool shouldAddMuxPragmas() const
Definition Firtool.h:124
bool shouldEnableAnnotationWarning() const
Definition Firtool.h:119
FirtoolOptions & setEmitAllBindFiles(bool value)
Definition Firtool.h:385
bool shouldEtcDisableInstanceExtraction() const
Definition Firtool.h:104
FirtoolOptions & setCkgModuleName(StringRef value)
Definition Firtool.h:310
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:172
bool shouldEtcDisableRegisterExtraction() const
Definition Firtool.h:107
FirtoolOptions & setEtcDisableModuleInlining(bool value)
Definition Firtool.h:299
FirtoolOptions & setIgnoreReadEnableMem(bool value)
Definition Firtool.h:254
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:284
FirtoolOptions & setDisableOptimization(bool value)
Definition Firtool.h:204
FirtoolOptions & setExtractTestCode(bool value)
Definition Firtool.h:249
std::string outputAnnotationFilename
Definition Firtool.h:417
firrtl::VerificationFlavor verificationFlavor
Definition Firtool.h:420
firrtl::PreserveAggregate::PreserveMode preserveAggregate
Definition Firtool.h:400
FirtoolOptions & setLintXmrsInDesign(bool value)
Definition Firtool.h:380
bool shouldLowerMemories() const
Definition Firtool.h:99
FirtoolOptions & setDisableWireElimination(bool value)
Definition Firtool.h:370
bool shouldEtcDisableModuleInlining() const
Definition Firtool.h:110
FirtoolOptions & setCompanionMode(firrtl::CompanionMode value)
Definition Firtool.h:219
bool shouldAllowAddingPortsOnPublic() const
Definition Firtool.h:92
FirtoolOptions & setVerificationFlavor(firrtl::VerificationFlavor value)
Definition Firtool.h:279
bool getLintStaticAsserts() const
Definition Firtool.h:140
bool shouldLowerNoRefTypePortAnnotations() const
Definition Firtool.h:89
FirtoolOptions & setReplSeqMem(bool value)
Definition Firtool.h:239
verif::SymbolicValueLowering getSymbolicValueLowering() const
Definition Firtool.h:135
FirtoolOptions & setCkgEnableName(StringRef value)
Definition Firtool.h:325
bool shouldExportModuleHierarchy() const
Definition Firtool.h:115
firrtl::CompanionMode companionMode
Definition Firtool.h:408
FirtoolOptions & setStripDebugInfo(bool value)
Definition Firtool.h:345
FirtoolOptions & setExportModuleHierarchy(bool value)
Definition Firtool.h:335
FirtoolOptions & setDisableUnknownAnnotations(bool disable)
Definition Firtool.h:152
bool shouldDisableWireElimination() const
Definition Firtool.h:138
FirtoolOptions & setEnableAnnotationWarning(bool value)
Definition Firtool.h:269
FirtoolOptions & setEtcDisableRegisterExtraction(bool value)
Definition Firtool.h:294
FirtoolOptions & setReplSeqMemFile(StringRef value)
Definition Firtool.h:244
bool shouldSelectDefaultInstanceChoice() const
Definition Firtool.h:131
FirtoolOptions & setLintStaticAsserts(bool value)
Definition Firtool.h:375
verif::SymbolicValueLowering symbolicValueLowering
Definition Firtool.h:438
bool getLintXmrsInDesign() const
Definition Firtool.h:142
FirtoolOptions & setSelectDefaultInstanceChoice(bool value)
Definition Firtool.h:360
FirtoolOptions & setStripFirDebugInfo(bool value)
Definition Firtool.h:340
seq::ExternalizeClockGateOptions getClockGateOptions() const
Definition Firtool.h:67
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:234
@ 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:220
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 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)
Definition Firtool.cpp:55
SymbolicValueLowering
Ways to lower symbolic values.
Definition VerifPasses.h:29
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.