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 bool getNoViews() const { return noViews; }
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 == "-"; }
98 bool shouldLowerMemories() const { return lowerMemories; }
99 bool shouldDedup() const { return !noDedup; }
100 bool shouldDedupClasses() const { return dedupClasses; }
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
147
148 // Setters, used by the CAPI
150 outputFilename = name;
151 return *this;
152 }
153
156 return *this;
157 }
158
161 return *this;
162 }
163
166 return *this;
167 }
168
170 probesToSignals = value;
171 return *this;
172 }
173
179
182 preserveMode = value;
183 return *this;
184 }
185
187 enableDebugInfo = value;
188 return *this;
189 }
190
192 buildMode = value;
193 return *this;
194 }
195
197 disableLayerSink = value;
198 return *this;
199 }
200
202 disableOptimization = value;
203 return *this;
204 }
205
207 vbToBV = value;
208 return *this;
209 }
210
212 noDedup = value;
213 return *this;
214 }
215
217 dedupClasses = value;
218 return *this;
219 }
220
222 companionMode = value;
223 return *this;
224 }
225
227 noViews = value;
228 return *this;
229 }
230
235
237 lowerMemories = value;
238 return *this;
239 }
240
242 blackBoxRootPath = value;
243 return *this;
244 }
245
247 replSeqMem = value;
248 return *this;
249 }
250
252 replSeqMemFile = value;
253 return *this;
254 }
255
257 extractTestCode = value;
258 return *this;
259 }
260
262 ignoreReadEnableMem = value;
263 return *this;
264 }
265
267 disableRandom = value;
268 return *this;
269 }
270
273 return *this;
274 }
275
278 return *this;
279 }
280
282 addMuxPragmas = value;
283 return *this;
284 }
285
290
293 return *this;
294 }
295
298 return *this;
299 }
300
303 return *this;
304 }
305
308 return *this;
309 }
310
316
318 ckgModuleName = value;
319 return *this;
320 }
321
322 FirtoolOptions &setCkgInputName(StringRef value) {
323 ckgInputName = value;
324 return *this;
325 }
326
328 ckgOutputName = value;
329 return *this;
330 }
331
333 ckgEnableName = value;
334 return *this;
335 }
336
338 ckgTestEnableName = value;
339 return *this;
340 }
341
343 exportModuleHierarchy = value;
344 return *this;
345 }
346
348 stripFirDebugInfo = value;
349 return *this;
350 }
351
353 stripDebugInfo = value;
354 return *this;
355 }
356
358 fixupEICGWrapper = value;
359 return *this;
360 }
361
363 disableCSEinClasses = value;
364 return *this;
365 }
366
369 return *this;
370 }
371
376
379 return *this;
380 }
381
383 lintStaticAsserts = value;
384 return *this;
385 }
386
388 lintXmrsInDesign = value;
389 return *this;
390 }
391
393 emitAllBindFiles = value;
394 return *this;
395 }
396
399 return *this;
400 }
401
402private:
403 std::string outputFilename;
404
405 // LowerFIRRTLAnnotations
409
417 bool vbToBV;
424 std::string blackBoxRootPath;
426 std::string replSeqMemFile;
439 std::string ckgModuleName;
440 std::string ckgInputName;
441 std::string ckgOutputName;
442 std::string ckgEnableName;
443 std::string ckgTestEnableName;
444 std::string ckgInstName;
457};
458
460
461LogicalResult populatePreprocessTransforms(mlir::PassManager &pm,
462 const FirtoolOptions &opt);
463
464LogicalResult populateCHIRRTLToLowFIRRTL(mlir::PassManager &pm,
465 const FirtoolOptions &opt);
466
467LogicalResult populateLowFIRRTLToHW(mlir::PassManager &pm,
468 const FirtoolOptions &opt,
469 StringRef inputFilename);
470
471LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt);
472
473LogicalResult populateExportVerilog(mlir::PassManager &pm,
474 const FirtoolOptions &opt,
475 std::unique_ptr<llvm::raw_ostream> os);
476
477LogicalResult populateExportVerilog(mlir::PassManager &pm,
478 const FirtoolOptions &opt,
479 llvm::raw_ostream &os);
480
481LogicalResult populateExportSplitVerilog(mlir::PassManager &pm,
482 const FirtoolOptions &opt,
483 llvm::StringRef directory);
484
485LogicalResult populateFinalizeIR(mlir::PassManager &pm,
486 const FirtoolOptions &opt);
487
488LogicalResult populateHWToBTOR2(mlir::PassManager &pm,
489 const FirtoolOptions &opt,
490 llvm::raw_ostream &os);
491
492} // namespace firtool
493} // namespace circt
494
495#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:357
FirtoolOptions & setPreserveAggregate(firrtl::PreserveAggregate::PreserveMode value)
Definition Firtool.h:175
FirtoolOptions & setAddVivadoRAMAddressConflictSynthesisBugWorkaround(bool value)
Definition Firtool.h:312
bool shouldStripDebugInfo() const
Definition Firtool.h:113
FirtoolOptions & setBuildMode(BuildMode value)
Definition Firtool.h:191
FirtoolOptions & setDisableAggressiveMergeConnections(bool value)
Definition Firtool.h:231
FirtoolOptions & setCkgInputName(StringRef value)
Definition Firtool.h:322
firrtl::PreserveAggregate::PreserveMode getPreserveAggregate() const
Definition Firtool.h:62
bool shouldAddVivadoRAMAddressConflictSynthesisBugWorkaround() const
Definition Firtool.h:125
bool shouldDisableLayerSink() const
Definition Firtool.h:96
firrtl::PreserveValues::PreserveMode preserveMode
Definition Firtool.h:412
FirtoolOptions & setDisableCSEinClasses(bool value)
Definition Firtool.h:362
auto getVerificationFlavor() const
Definition Firtool.h:120
FirtoolOptions & setClockGateOptions(seq::ExternalizeClockGateOptions &opts)
Definition Firtool.h:74
FirtoolOptions & setCkgTestEnableName(StringRef value)
Definition Firtool.h:337
bool isDefaultOutputFilename() const
Definition Firtool.h:84
StringRef getOutputFilename() const
Definition Firtool.h:55
FirtoolOptions & setDedupClasses(bool value)
Definition Firtool.h:216
bool shouldDisableAggressiveMergeConnections() const
Definition Firtool.h:116
StringRef getReplaceSequentialMemoriesFile() const
Definition Firtool.h:57
bool addVivadoRAMAddressConflictSynthesisBugWorkaround
Definition Firtool.h:438
FirtoolOptions & setSymbolicValueLowering(verif::SymbolicValueLowering mode)
Definition Firtool.h:372
FirtoolOptions & setLowerMemories(bool value)
Definition Firtool.h:236
FirtoolOptions & setDisableRandom(RandomKind value)
Definition Firtool.h:266
bool shouldExtractTestCode() const
Definition Firtool.h:128
FirtoolOptions & setNoDedup(bool value)
Definition Firtool.h:211
bool shouldFixupEICGWrapper() const
Definition Firtool.h:129
bool shouldConvertProbesToSignals() const
Definition Firtool.h:94
firrtl::PreserveValues::PreserveMode getPreserveMode() const
Definition Firtool.h:43
FirtoolOptions & setLowerAnnotationsNoRefTypePorts(bool value)
Definition Firtool.h:164
bool shouldDedupClasses() const
Definition Firtool.h:100
StringRef getBlackBoxRootPath() const
Definition Firtool.h:56
bool shouldDisableCSEinClasses() const
Definition Firtool.h:130
bool shouldDisableOptimization() const
Definition Firtool.h:97
firrtl::CompanionMode getCompanionMode() const
Definition Firtool.h:65
bool shouldDisableClasslessAnnotations() const
Definition Firtool.h:88
FirtoolOptions & setAddMuxPragmas(bool value)
Definition Firtool.h:281
FirtoolOptions & setPreserveValues(firrtl::PreserveValues::PreserveMode value)
Definition Firtool.h:181
bool getEmitAllBindFiles() const
Definition Firtool.h:144
bool shouldReplaceSequentialMemories() const
Definition Firtool.h:95
bool shouldIgnoreReadEnableMemories() const
Definition Firtool.h:102
FirtoolOptions & setEtcDisableInstanceExtraction(bool value)
Definition Firtool.h:296
FirtoolOptions & setOutputAnnotationFilename(StringRef value)
Definition Firtool.h:271
FirtoolOptions & setCkgOutputName(StringRef value)
Definition Firtool.h:327
bool isRandomEnabled(RandomKind kind) const
Definition Firtool.h:39
bool shouldDisableUnknownAnnotations() const
Definition Firtool.h:85
FirtoolOptions & setNoViews(bool value)
Definition Firtool.h:226
FirtoolOptions & setVbToBV(bool value)
Definition Firtool.h:206
bool shouldAddMuxPragmas() const
Definition Firtool.h:124
bool shouldEnableAnnotationWarning() const
Definition Firtool.h:119
FirtoolOptions & setEmitAllBindFiles(bool value)
Definition Firtool.h:392
bool shouldEtcDisableInstanceExtraction() const
Definition Firtool.h:104
FirtoolOptions & setCkgModuleName(StringRef value)
Definition Firtool.h:317
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:169
bool shouldEtcDisableRegisterExtraction() const
Definition Firtool.h:107
FirtoolOptions & setEtcDisableModuleInlining(bool value)
Definition Firtool.h:306
FirtoolOptions & setIgnoreReadEnableMem(bool value)
Definition Firtool.h:261
FirtoolOptions & setEnableDebugInfo(bool value)
Definition Firtool.h:186
FirtoolOptions & setDisableAnnotationsClassless(bool value)
Definition Firtool.h:159
FirtoolOptions & setDisableLayerSink(bool value)
Definition Firtool.h:196
FirtoolOptions & setEmitSeparateAlwaysBlocks(bool value)
Definition Firtool.h:291
FirtoolOptions & setDisableOptimization(bool value)
Definition Firtool.h:201
FirtoolOptions & setExtractTestCode(bool value)
Definition Firtool.h:256
std::string outputAnnotationFilename
Definition Firtool.h:430
firrtl::VerificationFlavor verificationFlavor
Definition Firtool.h:433
firrtl::PreserveAggregate::PreserveMode preserveAggregate
Definition Firtool.h:411
FirtoolOptions & setInlineInputOnlyModules(bool value)
Definition Firtool.h:397
FirtoolOptions & setLintXmrsInDesign(bool value)
Definition Firtool.h:387
bool shouldLowerMemories() const
Definition Firtool.h:98
FirtoolOptions & setDisableWireElimination(bool value)
Definition Firtool.h:377
bool shouldEtcDisableModuleInlining() const
Definition Firtool.h:110
FirtoolOptions & setCompanionMode(firrtl::CompanionMode value)
Definition Firtool.h:221
FirtoolOptions & setVerificationFlavor(firrtl::VerificationFlavor value)
Definition Firtool.h:286
bool getLintStaticAsserts() const
Definition Firtool.h:140
bool shouldLowerNoRefTypePortAnnotations() const
Definition Firtool.h:91
FirtoolOptions & setReplSeqMem(bool value)
Definition Firtool.h:246
verif::SymbolicValueLowering getSymbolicValueLowering() const
Definition Firtool.h:135
FirtoolOptions & setCkgEnableName(StringRef value)
Definition Firtool.h:332
bool shouldExportModuleHierarchy() const
Definition Firtool.h:115
firrtl::CompanionMode companionMode
Definition Firtool.h:420
FirtoolOptions & setStripDebugInfo(bool value)
Definition Firtool.h:352
FirtoolOptions & setExportModuleHierarchy(bool value)
Definition Firtool.h:342
FirtoolOptions & setDisableUnknownAnnotations(bool disable)
Definition Firtool.h:154
bool shouldDisableWireElimination() const
Definition Firtool.h:138
FirtoolOptions & setEnableAnnotationWarning(bool value)
Definition Firtool.h:276
FirtoolOptions & setEtcDisableRegisterExtraction(bool value)
Definition Firtool.h:301
FirtoolOptions & setReplSeqMemFile(StringRef value)
Definition Firtool.h:251
bool shouldSelectDefaultInstanceChoice() const
Definition Firtool.h:131
FirtoolOptions & setLintStaticAsserts(bool value)
Definition Firtool.h:382
bool shouldInlineInputOnlyModules() const
Definition Firtool.h:146
verif::SymbolicValueLowering symbolicValueLowering
Definition Firtool.h:451
bool getLintXmrsInDesign() const
Definition Firtool.h:142
FirtoolOptions & setSelectDefaultInstanceChoice(bool value)
Definition Firtool.h:367
FirtoolOptions & setStripFirDebugInfo(bool value)
Definition Firtool.h:347
seq::ExternalizeClockGateOptions getClockGateOptions() const
Definition Firtool.h:69
bool shouldEnableDebugInfo() const
Definition Firtool.h:101
bool shouldEmitSeparateAlwaysBlocks() const
Definition Firtool.h:121
FirtoolOptions & setOutputFilename(StringRef name)
Definition Firtool.h:149
FirtoolOptions & setBlackBoxRootPath(StringRef value)
Definition Firtool.h:241
@ 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:229
LogicalResult populateHWToBTOR2(mlir::PassManager &pm, const FirtoolOptions &opt, llvm::raw_ostream &os)
Definition Firtool.cpp:449
LogicalResult populateExportSplitVerilog(mlir::PassManager &pm, const FirtoolOptions &opt, llvm::StringRef directory)
Definition Firtool.cpp:431
LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:316
LogicalResult populateExportVerilog(mlir::PassManager &pm, const FirtoolOptions &opt, std::unique_ptr< llvm::raw_ostream > os)
Definition Firtool.cpp:412
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:794
LogicalResult populateFinalizeIR(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:441
LogicalResult populateCHIRRTLToLowFIRRTL(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:54
SymbolicValueLowering
Ways to lower symbolic values.
Definition VerifPasses.h:29
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.