CIRCT 23.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//===----------------------------------------------------------------------===//
28// FirtoolOptions
29//===----------------------------------------------------------------------===//
30
31/// Set of options used to control the behavior of the firtool pipeline.
33public:
35
36 // Helper Types
38 enum class RandomKind { None, Mem, Reg, All };
39
40 enum class DomainMode {
41 /// Erase domains from the input circuit.
42 Strip,
43 /// Disable domain checking.
44 Disable,
45 /// Check domains without inference.
46 Check,
47 /// Check domains with inference for private modules.
48 Infer,
49 /// Check domains with inference for both public and private modules.
51 };
52
53 /// Convert the "domain mode" firtool option to a "firrtl::InferDomainsMode",
54 /// the configuration for a pass.
55 static constexpr std::optional<firrtl::InferDomainsMode>
70
71 bool isRandomEnabled(RandomKind kind) const {
72 return disableRandom != RandomKind::All && disableRandom != kind;
73 }
74
76 switch (buildMode) {
77 case BuildModeDebug:
82 return preserveMode;
83 }
84 llvm_unreachable("unknown build mode");
85 }
86
87 StringRef getOutputFilename() const { return outputFilename; }
88 StringRef getBlackBoxRootPath() const { return blackBoxRootPath; }
90 StringRef getOutputAnnotationFilename() const {
92 }
93
98
99 bool getNoViews() const { return noViews; }
100
101 seq::ExternalizeClockGateOptions getClockGateOptions() const {
104 }
105
106 FirtoolOptions &setClockGateOptions(seq::ExternalizeClockGateOptions &opts) {
107 ckgModuleName = opts.moduleName;
108 ckgInputName = opts.inputName;
109 ckgOutputName = opts.outputName;
110 ckgEnableName = opts.enableName;
111 ckgTestEnableName = opts.testEnableName;
112 ckgInstName = opts.instName;
113 return *this;
114 }
115
116 bool isDefaultOutputFilename() const { return outputFilename == "-"; }
130 bool shouldLowerMemories() const { return lowerMemories; }
131 bool shouldDedup() const { return !noDedup; }
132 bool shouldDedupClasses() const { return dedupClasses; }
133 bool shouldEnableDebugInfo() const { return enableDebugInfo; }
135 bool shouldConvertVecOfBundle() const { return vbToBV; }
136 bool shouldStripDebugInfo() const { return stripDebugInfo; }
147 bool shouldAddMuxPragmas() const { return addMuxPragmas; }
156
161
163
164 bool getLintXmrsInDesign() const { return lintXmrsInDesign; }
165
166 bool getEmitAllBindFiles() const { return emitAllBindFiles; }
167
169
171
172 // Setters, used by the CAPI
174 outputFilename = name;
175 return *this;
176 }
177
180 return *this;
181 }
182
185 return *this;
186 }
187
190 return *this;
191 }
192
194 probesToSignals = value;
195 return *this;
196 }
197
203
206 preserveMode = value;
207 return *this;
208 }
209
211 enableDebugInfo = value;
212 return *this;
213 }
214
216 buildMode = value;
217 return *this;
218 }
219
221 disableLayerSink = value;
222 return *this;
223 }
224
226 disableOptimization = value;
227 return *this;
228 }
229
231 vbToBV = value;
232 return *this;
233 }
234
236 noDedup = value;
237 return *this;
238 }
239
241 dedupClasses = value;
242 return *this;
243 }
244
246 companionMode = value;
247 return *this;
248 }
249
251 noViews = value;
252 return *this;
253 }
254
259
261 lowerMemories = value;
262 return *this;
263 }
264
266 blackBoxRootPath = value;
267 return *this;
268 }
269
271 replSeqMem = value;
272 return *this;
273 }
274
276 replSeqMemFile = value;
277 return *this;
278 }
279
281 ignoreReadEnableMem = value;
282 return *this;
283 }
284
286 disableRandom = value;
287 return *this;
288 }
289
292 return *this;
293 }
294
297 return *this;
298 }
299
301 addMuxPragmas = value;
302 return *this;
303 }
304
309
312 return *this;
313 }
314
320
322 ckgModuleName = value;
323 return *this;
324 }
325
326 FirtoolOptions &setCkgInputName(StringRef value) {
327 ckgInputName = value;
328 return *this;
329 }
330
332 ckgOutputName = value;
333 return *this;
334 }
335
337 ckgEnableName = value;
338 return *this;
339 }
340
342 ckgTestEnableName = value;
343 return *this;
344 }
345
347 exportModuleHierarchy = value;
348 return *this;
349 }
350
352 stripFirDebugInfo = value;
353 return *this;
354 }
355
357 stripDebugInfo = value;
358 return *this;
359 }
360
362 fixupEICGWrapper = value;
363 return *this;
364 }
365
367 disableCSEinClasses = value;
368 return *this;
369 }
370
373 return *this;
374 }
375
380
383 return *this;
384 }
385
387 lintStaticAsserts = value;
388 return *this;
389 }
390
392 lintXmrsInDesign = value;
393 return *this;
394 }
395
397 emitAllBindFiles = value;
398 return *this;
399 }
400
403 return *this;
404 }
405
407 domainMode = value;
408 return *this;
409 }
410
411private:
412 std::string outputFilename;
413
414 // LowerFIRRTLAnnotations
418
426 bool vbToBV;
433 std::string blackBoxRootPath;
435 std::string replSeqMemFile;
444 std::string ckgModuleName;
445 std::string ckgInputName;
446 std::string ckgOutputName;
447 std::string ckgEnableName;
448 std::string ckgTestEnableName;
449 std::string ckgInstName;
463};
464
466
467LogicalResult populatePreprocessTransforms(mlir::PassManager &pm,
468 const FirtoolOptions &opt);
469
470LogicalResult populateCHIRRTLToLowFIRRTL(mlir::PassManager &pm,
471 const FirtoolOptions &opt);
472
473LogicalResult populateLowFIRRTLToHW(mlir::PassManager &pm,
474 const FirtoolOptions &opt,
475 StringRef inputFilename);
476
477LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt);
478
479LogicalResult populateExportVerilog(mlir::PassManager &pm,
480 const FirtoolOptions &opt,
481 std::unique_ptr<llvm::raw_ostream> os);
482
483LogicalResult populateExportVerilog(mlir::PassManager &pm,
484 const FirtoolOptions &opt,
485 llvm::raw_ostream &os);
486
487LogicalResult populateExportSplitVerilog(mlir::PassManager &pm,
488 const FirtoolOptions &opt,
489 llvm::StringRef directory);
490
491LogicalResult populateFinalizeIR(mlir::PassManager &pm,
492 const FirtoolOptions &opt);
493
494LogicalResult populateHWToBTOR2(mlir::PassManager &pm,
495 const FirtoolOptions &opt,
496 llvm::raw_ostream &os);
497
498} // namespace firtool
499} // namespace circt
500
501#endif // CIRCT_FIRTOOL_FIRTOOL_H
Set of options used to control the behavior of the firtool pipeline.
Definition Firtool.h:32
FirtoolOptions & setFixupEICGWrapper(bool value)
Definition Firtool.h:361
FirtoolOptions & setPreserveAggregate(firrtl::PreserveAggregate::PreserveMode value)
Definition Firtool.h:199
FirtoolOptions & setAddVivadoRAMAddressConflictSynthesisBugWorkaround(bool value)
Definition Firtool.h:316
bool shouldStripDebugInfo() const
Definition Firtool.h:136
FirtoolOptions & setBuildMode(BuildMode value)
Definition Firtool.h:215
FirtoolOptions & setDisableAggressiveMergeConnections(bool value)
Definition Firtool.h:255
FirtoolOptions & setCkgInputName(StringRef value)
Definition Firtool.h:326
firrtl::PreserveAggregate::PreserveMode getPreserveAggregate() const
Definition Firtool.h:94
bool shouldAddVivadoRAMAddressConflictSynthesisBugWorkaround() const
Definition Firtool.h:148
bool shouldDisableLayerSink() const
Definition Firtool.h:128
firrtl::PreserveValues::PreserveMode preserveMode
Definition Firtool.h:421
FirtoolOptions & setDisableCSEinClasses(bool value)
Definition Firtool.h:366
auto getVerificationFlavor() const
Definition Firtool.h:143
@ Strip
Erase domains from the input circuit.
@ Check
Check domains without inference.
@ Infer
Check domains with inference for private modules.
@ InferAll
Check domains with inference for both public and private modules.
FirtoolOptions & setClockGateOptions(seq::ExternalizeClockGateOptions &opts)
Definition Firtool.h:106
FirtoolOptions & setCkgTestEnableName(StringRef value)
Definition Firtool.h:341
bool isDefaultOutputFilename() const
Definition Firtool.h:116
StringRef getOutputFilename() const
Definition Firtool.h:87
FirtoolOptions & setDedupClasses(bool value)
Definition Firtool.h:240
bool shouldDisableAggressiveMergeConnections() const
Definition Firtool.h:139
StringRef getReplaceSequentialMemoriesFile() const
Definition Firtool.h:89
bool addVivadoRAMAddressConflictSynthesisBugWorkaround
Definition Firtool.h:443
FirtoolOptions & setSymbolicValueLowering(verif::SymbolicValueLowering mode)
Definition Firtool.h:376
FirtoolOptions & setLowerMemories(bool value)
Definition Firtool.h:260
FirtoolOptions & setDisableRandom(RandomKind value)
Definition Firtool.h:285
FirtoolOptions & setNoDedup(bool value)
Definition Firtool.h:235
bool shouldFixupEICGWrapper() const
Definition Firtool.h:151
bool shouldConvertProbesToSignals() const
Definition Firtool.h:126
firrtl::PreserveValues::PreserveMode getPreserveMode() const
Definition Firtool.h:75
FirtoolOptions & setLowerAnnotationsNoRefTypePorts(bool value)
Definition Firtool.h:188
bool shouldDedupClasses() const
Definition Firtool.h:132
StringRef getBlackBoxRootPath() const
Definition Firtool.h:88
bool shouldDisableCSEinClasses() const
Definition Firtool.h:152
bool shouldDisableOptimization() const
Definition Firtool.h:129
firrtl::CompanionMode getCompanionMode() const
Definition Firtool.h:97
bool shouldDisableClasslessAnnotations() const
Definition Firtool.h:120
FirtoolOptions & setAddMuxPragmas(bool value)
Definition Firtool.h:300
FirtoolOptions & setPreserveValues(firrtl::PreserveValues::PreserveMode value)
Definition Firtool.h:205
bool getEmitAllBindFiles() const
Definition Firtool.h:166
bool shouldReplaceSequentialMemories() const
Definition Firtool.h:127
FirtoolOptions & setDomainMode(DomainMode value)
Definition Firtool.h:406
bool shouldIgnoreReadEnableMemories() const
Definition Firtool.h:134
FirtoolOptions & setOutputAnnotationFilename(StringRef value)
Definition Firtool.h:290
FirtoolOptions & setCkgOutputName(StringRef value)
Definition Firtool.h:331
bool isRandomEnabled(RandomKind kind) const
Definition Firtool.h:71
bool shouldDisableUnknownAnnotations() const
Definition Firtool.h:117
FirtoolOptions & setNoViews(bool value)
Definition Firtool.h:250
FirtoolOptions & setVbToBV(bool value)
Definition Firtool.h:230
bool shouldAddMuxPragmas() const
Definition Firtool.h:147
bool shouldEnableAnnotationWarning() const
Definition Firtool.h:142
FirtoolOptions & setEmitAllBindFiles(bool value)
Definition Firtool.h:396
FirtoolOptions & setCkgModuleName(StringRef value)
Definition Firtool.h:321
bool shouldConvertVecOfBundle() const
Definition Firtool.h:135
StringRef getOutputAnnotationFilename() const
Definition Firtool.h:90
bool shouldStripFirDebugInfo() const
Definition Firtool.h:137
FirtoolOptions & setConvertProbesToSignals(bool value)
Definition Firtool.h:193
FirtoolOptions & setIgnoreReadEnableMem(bool value)
Definition Firtool.h:280
FirtoolOptions & setEnableDebugInfo(bool value)
Definition Firtool.h:210
FirtoolOptions & setDisableAnnotationsClassless(bool value)
Definition Firtool.h:183
FirtoolOptions & setDisableLayerSink(bool value)
Definition Firtool.h:220
FirtoolOptions & setEmitSeparateAlwaysBlocks(bool value)
Definition Firtool.h:310
FirtoolOptions & setDisableOptimization(bool value)
Definition Firtool.h:225
std::string outputAnnotationFilename
Definition Firtool.h:438
firrtl::VerificationFlavor verificationFlavor
Definition Firtool.h:441
firrtl::PreserveAggregate::PreserveMode preserveAggregate
Definition Firtool.h:420
FirtoolOptions & setInlineInputOnlyModules(bool value)
Definition Firtool.h:401
FirtoolOptions & setLintXmrsInDesign(bool value)
Definition Firtool.h:391
bool shouldLowerMemories() const
Definition Firtool.h:130
FirtoolOptions & setDisableWireElimination(bool value)
Definition Firtool.h:381
FirtoolOptions & setCompanionMode(firrtl::CompanionMode value)
Definition Firtool.h:245
FirtoolOptions & setVerificationFlavor(firrtl::VerificationFlavor value)
Definition Firtool.h:305
DomainMode getDomainMode() const
Definition Firtool.h:170
bool getLintStaticAsserts() const
Definition Firtool.h:162
bool shouldLowerNoRefTypePortAnnotations() const
Definition Firtool.h:123
FirtoolOptions & setReplSeqMem(bool value)
Definition Firtool.h:270
verif::SymbolicValueLowering getSymbolicValueLowering() const
Definition Firtool.h:157
FirtoolOptions & setCkgEnableName(StringRef value)
Definition Firtool.h:336
bool shouldExportModuleHierarchy() const
Definition Firtool.h:138
firrtl::CompanionMode companionMode
Definition Firtool.h:429
FirtoolOptions & setStripDebugInfo(bool value)
Definition Firtool.h:356
FirtoolOptions & setExportModuleHierarchy(bool value)
Definition Firtool.h:346
FirtoolOptions & setDisableUnknownAnnotations(bool disable)
Definition Firtool.h:178
bool shouldDisableWireElimination() const
Definition Firtool.h:160
FirtoolOptions & setEnableAnnotationWarning(bool value)
Definition Firtool.h:295
FirtoolOptions & setReplSeqMemFile(StringRef value)
Definition Firtool.h:275
bool shouldSelectDefaultInstanceChoice() const
Definition Firtool.h:153
FirtoolOptions & setLintStaticAsserts(bool value)
Definition Firtool.h:386
bool shouldInlineInputOnlyModules() const
Definition Firtool.h:168
verif::SymbolicValueLowering symbolicValueLowering
Definition Firtool.h:456
bool getLintXmrsInDesign() const
Definition Firtool.h:164
FirtoolOptions & setSelectDefaultInstanceChoice(bool value)
Definition Firtool.h:371
FirtoolOptions & setStripFirDebugInfo(bool value)
Definition Firtool.h:351
seq::ExternalizeClockGateOptions getClockGateOptions() const
Definition Firtool.h:101
bool shouldEnableDebugInfo() const
Definition Firtool.h:133
bool shouldEmitSeparateAlwaysBlocks() const
Definition Firtool.h:144
static constexpr std::optional< firrtl::InferDomainsMode > toInferDomainsPassMode(DomainMode mode)
Convert the "domain mode" firtool option to a "firrtl::InferDomainsMode", the configuration for a pas...
Definition Firtool.h:56
FirtoolOptions & setOutputFilename(StringRef name)
Definition Firtool.h:173
FirtoolOptions & setBlackBoxRootPath(StringRef value)
Definition Firtool.h:265
@ None
Don't explicitly preserve any named values.
Definition Passes.h:52
@ Strip
Erase domains from the input circuit.
@ Check
Check domains without inference.
@ Infer
Check domains with inference for private modules.
@ InferAll
Check domains with inference for both public and private modules.
LogicalResult populateLowFIRRTLToHW(mlir::PassManager &pm, const FirtoolOptions &opt, StringRef inputFilename)
Definition Firtool.cpp:232
LogicalResult populateHWToBTOR2(mlir::PassManager &pm, const FirtoolOptions &opt, llvm::raw_ostream &os)
BTOR2 emission pipeline, triggered with --btor2 flag.
Definition Firtool.cpp:452
LogicalResult populateExportSplitVerilog(mlir::PassManager &pm, const FirtoolOptions &opt, llvm::StringRef directory)
Definition Firtool.cpp:433
LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:324
LogicalResult populateExportVerilog(mlir::PassManager &pm, const FirtoolOptions &opt, std::unique_ptr< llvm::raw_ostream > os)
Definition Firtool.cpp:414
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:801
LogicalResult populateFinalizeIR(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:443
LogicalResult populateCHIRRTLToLowFIRRTL(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:57
SymbolicValueLowering
Ways to lower symbolic values.
Definition VerifPasses.h:29
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.