CIRCT 20.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
19#include "circt/Support/LLVM.h"
20#include "mlir/Pass/PassManager.h"
21#include "llvm/Support/CommandLine.h"
22
23namespace circt {
24namespace firtool {
25//===----------------------------------------------------------------------===//
26// FirtoolOptions
27//===----------------------------------------------------------------------===//
28
29/// Set of options used to control the behavior of the firtool pipeline.
31public:
33
34 // Helper Types
36 enum class RandomKind { None, Mem, Reg, All };
37
38 bool isRandomEnabled(RandomKind kind) const {
39 return disableRandom != RandomKind::All && disableRandom != kind;
40 }
41
43 switch (buildMode) {
44 case BuildModeDebug:
49 return preserveMode;
50 }
51 llvm_unreachable("unknown build mode");
52 }
53
54 StringRef getOutputFilename() const { return outputFilename; }
55 StringRef getBlackBoxRootPath() const { return blackBoxRootPath; }
60 StringRef getOutputAnnotationFilename() const {
62 }
63
68
69 seq::ExternalizeClockGateOptions getClockGateOptions() const {
72 }
73
74 FirtoolOptions &setClockGateOptions(seq::ExternalizeClockGateOptions &opts) {
75 ckgModuleName = opts.moduleName;
76 ckgInputName = opts.inputName;
77 ckgOutputName = opts.outputName;
78 ckgEnableName = opts.enableName;
79 ckgTestEnableName = opts.testEnableName;
80 ckgInstName = opts.instName;
81 return *this;
82 }
83
84 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
140 // Setters, used by the CAPI
142 outputFilename = name;
143 return *this;
144 }
145
148 return *this;
149 }
150
153 return *this;
154 }
155
158 return *this;
159 }
160
163 return *this;
164 }
165
167 probesToSignals = value;
168 return *this;
169 }
170
176
179 preserveMode = value;
180 return *this;
181 }
182
184 enableDebugInfo = value;
185 return *this;
186 }
187
189 buildMode = value;
190 return *this;
191 }
192
194 disableLayerSink = value;
195 return *this;
196 }
197
199 disableOptimization = value;
200 return *this;
201 }
202
204 exportChiselInterface = value;
205 return *this;
206 }
207
210 return *this;
211 }
212
214 vbToBV = value;
215 return *this;
216 }
217
219 noDedup = value;
220 return *this;
221 }
222
224 companionMode = value;
225 return *this;
226 }
227
232
234 advancedLayerSink = value;
235 return *this;
236 }
237
239 lowerMemories = value;
240 return *this;
241 }
242
244 blackBoxRootPath = value;
245 return *this;
246 }
247
249 replSeqMem = value;
250 return *this;
251 }
252
254 replSeqMemFile = value;
255 return *this;
256 }
257
259 extractTestCode = value;
260 return *this;
261 }
262
264 ignoreReadEnableMem = value;
265 return *this;
266 }
267
269 disableRandom = value;
270 return *this;
271 }
272
275 return *this;
276 }
277
280 return *this;
281 }
282
284 addMuxPragmas = value;
285 return *this;
286 }
287
292
295 return *this;
296 }
297
300 return *this;
301 }
302
305 return *this;
306 }
307
310 return *this;
311 }
312
318
320 ckgModuleName = value;
321 return *this;
322 }
323
324 FirtoolOptions &setCkgInputName(StringRef value) {
325 ckgInputName = value;
326 return *this;
327 }
328
330 ckgOutputName = value;
331 return *this;
332 }
333
335 ckgEnableName = value;
336 return *this;
337 }
338
340 ckgTestEnableName = value;
341 return *this;
342 }
343
345 exportModuleHierarchy = value;
346 return *this;
347 }
348
350 stripFirDebugInfo = value;
351 return *this;
352 }
353
355 stripDebugInfo = value;
356 return *this;
357 }
358
360 fixupEICGWrapper = value;
361 return *this;
362 }
363
365 addCompanionAssume = value;
366 return *this;
367 }
368
370 disableCSEinClasses = value;
371 return *this;
372 }
373
376 return *this;
377 }
378
379private:
380 std::string outputFilename;
394 bool vbToBV;
400 std::string blackBoxRootPath;
402 std::string replSeqMemFile;
415 std::string ckgModuleName;
416 std::string ckgInputName;
417 std::string ckgOutputName;
418 std::string ckgEnableName;
419 std::string ckgTestEnableName;
420 std::string ckgInstName;
428};
429
431
432LogicalResult populatePreprocessTransforms(mlir::PassManager &pm,
433 const FirtoolOptions &opt);
434
435LogicalResult populateCHIRRTLToLowFIRRTL(mlir::PassManager &pm,
436 const FirtoolOptions &opt,
437 StringRef inputFilename);
438
439LogicalResult populateLowFIRRTLToHW(mlir::PassManager &pm,
440 const FirtoolOptions &opt);
441
442LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt);
443
444LogicalResult populateExportVerilog(mlir::PassManager &pm,
445 const FirtoolOptions &opt,
446 std::unique_ptr<llvm::raw_ostream> os);
447
448LogicalResult populateExportVerilog(mlir::PassManager &pm,
449 const FirtoolOptions &opt,
450 llvm::raw_ostream &os);
451
452LogicalResult populateExportSplitVerilog(mlir::PassManager &pm,
453 const FirtoolOptions &opt,
454 llvm::StringRef directory);
455
456LogicalResult populateFinalizeIR(mlir::PassManager &pm,
457 const FirtoolOptions &opt);
458
459LogicalResult populateHWToBTOR2(mlir::PassManager &pm,
460 const FirtoolOptions &opt,
461 llvm::raw_ostream &os);
462
463} // namespace firtool
464} // namespace circt
465
466#endif // CIRCT_FIRTOOL_FIRTOOL_H
Set of options used to control the behavior of the firtool pipeline.
Definition Firtool.h:30
FirtoolOptions & setFixupEICGWrapper(bool value)
Definition Firtool.h:359
FirtoolOptions & setPreserveAggregate(firrtl::PreserveAggregate::PreserveMode value)
Definition Firtool.h:172
FirtoolOptions & setAddVivadoRAMAddressConflictSynthesisBugWorkaround(bool value)
Definition Firtool.h:314
bool shouldStripDebugInfo() const
Definition Firtool.h:117
FirtoolOptions & setBuildMode(BuildMode value)
Definition Firtool.h:188
FirtoolOptions & setAdvancedLayerSink(bool value)
Definition Firtool.h:233
FirtoolOptions & setDisableAggressiveMergeConnections(bool value)
Definition Firtool.h:228
FirtoolOptions & setCkgInputName(StringRef value)
Definition Firtool.h:324
firrtl::PreserveAggregate::PreserveMode getPreserveAggregate() const
Definition Firtool.h:64
bool shouldAddVivadoRAMAddressConflictSynthesisBugWorkaround() const
Definition Firtool.h:129
bool shouldDisableLayerSink() const
Definition Firtool.h:99
FirtoolOptions & setExportChiselInterface(bool value)
Definition Firtool.h:203
firrtl::PreserveValues::PreserveMode preserveMode
Definition Firtool.h:387
bool shouldAddCompanionAssume() const
Definition Firtool.h:134
FirtoolOptions & setDisableCSEinClasses(bool value)
Definition Firtool.h:369
auto getVerificationFlavor() const
Definition Firtool.h:124
FirtoolOptions & setClockGateOptions(seq::ExternalizeClockGateOptions &opts)
Definition Firtool.h:74
FirtoolOptions & setCkgTestEnableName(StringRef value)
Definition Firtool.h:339
bool isDefaultOutputFilename() const
Definition Firtool.h:84
StringRef getOutputFilename() const
Definition Firtool.h:54
bool shouldDisableAggressiveMergeConnections() const
Definition Firtool.h:120
StringRef getReplaceSequentialMemoriesFile() const
Definition Firtool.h:59
bool addVivadoRAMAddressConflictSynthesisBugWorkaround
Definition Firtool.h:414
FirtoolOptions & setLowerMemories(bool value)
Definition Firtool.h:238
FirtoolOptions & setDisableRandom(RandomKind value)
Definition Firtool.h:268
bool shouldExportChiselInterface() const
Definition Firtool.h:106
bool shouldAdvancedLayerSink() const
Definition Firtool.h:101
FirtoolOptions & setAddCompanionAssume(bool value)
Definition Firtool.h:364
bool shouldExtractTestCode() const
Definition Firtool.h:132
FirtoolOptions & setNoDedup(bool value)
Definition Firtool.h:218
std::string chiselInterfaceOutDirectory
Definition Firtool.h:393
bool shouldFixupEICGWrapper() const
Definition Firtool.h:133
bool shouldConvertProbesToSignals() const
Definition Firtool.h:97
firrtl::PreserveValues::PreserveMode getPreserveMode() const
Definition Firtool.h:42
FirtoolOptions & setLowerAnnotationsNoRefTypePorts(bool value)
Definition Firtool.h:156
FirtoolOptions & setAllowAddingPortsOnPublic(bool value)
Definition Firtool.h:161
StringRef getBlackBoxRootPath() const
Definition Firtool.h:55
bool shouldDisableCSEinClasses() const
Definition Firtool.h:135
bool shouldDisableOptimization() const
Definition Firtool.h:100
firrtl::CompanionMode getCompanionMode() const
Definition Firtool.h:67
bool shouldDisableClasslessAnnotations() const
Definition Firtool.h:88
FirtoolOptions & setAddMuxPragmas(bool value)
Definition Firtool.h:283
FirtoolOptions & setPreserveValues(firrtl::PreserveValues::PreserveMode value)
Definition Firtool.h:178
bool shouldReplaceSequentialMemories() const
Definition Firtool.h:98
bool shouldIgnoreReadEnableMemories() const
Definition Firtool.h:105
FirtoolOptions & setEtcDisableInstanceExtraction(bool value)
Definition Firtool.h:298
FirtoolOptions & setOutputAnnotationFilename(StringRef value)
Definition Firtool.h:273
FirtoolOptions & setCkgOutputName(StringRef value)
Definition Firtool.h:329
bool isRandomEnabled(RandomKind kind) const
Definition Firtool.h:38
bool shouldDisableUnknownAnnotations() const
Definition Firtool.h:85
FirtoolOptions & setVbToBV(bool value)
Definition Firtool.h:213
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:319
bool shouldConvertVecOfBundle() const
Definition Firtool.h:107
StringRef getOutputAnnotationFilename() const
Definition Firtool.h:60
bool shouldStripFirDebugInfo() const
Definition Firtool.h:118
FirtoolOptions & setConvertProbesToSignals(bool value)
Definition Firtool.h:166
bool shouldEtcDisableRegisterExtraction() const
Definition Firtool.h:111
FirtoolOptions & setEtcDisableModuleInlining(bool value)
Definition Firtool.h:308
FirtoolOptions & setIgnoreReadEnableMem(bool value)
Definition Firtool.h:263
FirtoolOptions & setEnableDebugInfo(bool value)
Definition Firtool.h:183
FirtoolOptions & setDisableAnnotationsClassless(bool value)
Definition Firtool.h:151
FirtoolOptions & setDisableLayerSink(bool value)
Definition Firtool.h:193
FirtoolOptions & setEmitSeparateAlwaysBlocks(bool value)
Definition Firtool.h:293
FirtoolOptions & setDisableOptimization(bool value)
Definition Firtool.h:198
FirtoolOptions & setExtractTestCode(bool value)
Definition Firtool.h:258
std::string outputAnnotationFilename
Definition Firtool.h:406
firrtl::VerificationFlavor verificationFlavor
Definition Firtool.h:409
firrtl::PreserveAggregate::PreserveMode preserveAggregate
Definition Firtool.h:386
bool shouldLowerMemories() const
Definition Firtool.h:102
bool shouldEtcDisableModuleInlining() const
Definition Firtool.h:114
FirtoolOptions & setCompanionMode(firrtl::CompanionMode value)
Definition Firtool.h:223
bool shouldAllowAddingPortsOnPublic() const
Definition Firtool.h:94
FirtoolOptions & setChiselInterfaceOutDirectory(StringRef value)
Definition Firtool.h:208
FirtoolOptions & setVerificationFlavor(firrtl::VerificationFlavor value)
Definition Firtool.h:288
bool shouldLowerNoRefTypePortAnnotations() const
Definition Firtool.h:91
FirtoolOptions & setReplSeqMem(bool value)
Definition Firtool.h:248
FirtoolOptions & setCkgEnableName(StringRef value)
Definition Firtool.h:334
bool shouldExportModuleHierarchy() const
Definition Firtool.h:119
firrtl::CompanionMode companionMode
Definition Firtool.h:396
FirtoolOptions & setStripDebugInfo(bool value)
Definition Firtool.h:354
FirtoolOptions & setExportModuleHierarchy(bool value)
Definition Firtool.h:344
FirtoolOptions & setDisableUnknownAnnotations(bool disable)
Definition Firtool.h:146
FirtoolOptions & setEnableAnnotationWarning(bool value)
Definition Firtool.h:278
FirtoolOptions & setEtcDisableRegisterExtraction(bool value)
Definition Firtool.h:303
FirtoolOptions & setReplSeqMemFile(StringRef value)
Definition Firtool.h:253
bool shouldSelectDefaultInstanceChoice() const
Definition Firtool.h:136
FirtoolOptions & setSelectDefaultInstanceChoice(bool value)
Definition Firtool.h:374
FirtoolOptions & setStripFirDebugInfo(bool value)
Definition Firtool.h:349
seq::ExternalizeClockGateOptions getClockGateOptions() const
Definition Firtool.h:69
bool shouldEnableDebugInfo() const
Definition Firtool.h:104
bool shouldEmitSeparateAlwaysBlocks() const
Definition Firtool.h:125
FirtoolOptions & setOutputFilename(StringRef name)
Definition Firtool.h:141
StringRef getChiselInterfaceOutputDirectory() const
Definition Firtool.h:56
FirtoolOptions & setBlackBoxRootPath(StringRef value)
Definition Firtool.h:243
@ 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:433
LogicalResult populateExportSplitVerilog(mlir::PassManager &pm, const FirtoolOptions &opt, llvm::StringRef directory)
Definition Firtool.cpp:415
LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:303
LogicalResult populateLowFIRRTLToHW(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:262
LogicalResult populateExportVerilog(mlir::PassManager &pm, const FirtoolOptions &opt, std::unique_ptr< llvm::raw_ostream > os)
Definition Firtool.cpp:396
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:760
LogicalResult populateFinalizeIR(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:425
LogicalResult populateCHIRRTLToLowFIRRTL(mlir::PassManager &pm, const FirtoolOptions &opt, StringRef inputFilename)
Definition Firtool.cpp:55
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.