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
75 /// Advance the disabled-randomization lattice. Calling this twice with
76 /// the two individual kinds is equivalent to calling it once with All.
77 static RandomKind mergeRandomKind(RandomKind current, RandomKind incoming) {
78 if (current == RandomKind::None)
79 return incoming;
80 if (current == incoming)
81 return current;
82 return RandomKind::All;
83 }
84
89
91 switch (buildMode) {
92 case BuildModeDebug:
97 return preserveMode;
98 }
99 llvm_unreachable("unknown build mode");
100 }
101
102 StringRef getOutputFilename() const { return outputFilename; }
103 StringRef getBlackBoxRootPath() const { return blackBoxRootPath; }
105 StringRef getOutputAnnotationFilename() const {
107 }
108
113
114 bool getNoViews() const { return noViews; }
115
116 seq::ExternalizeClockGateOptions getClockGateOptions() const {
119 }
120
121 FirtoolOptions &setClockGateOptions(seq::ExternalizeClockGateOptions &opts) {
122 ckgModuleName = opts.moduleName;
123 ckgInputName = opts.inputName;
124 ckgOutputName = opts.outputName;
125 ckgEnableName = opts.enableName;
126 ckgTestEnableName = opts.testEnableName;
127 ckgInstName = opts.instName;
128 return *this;
129 }
130
131 bool isDefaultOutputFilename() const { return outputFilename == "-"; }
145 bool shouldLowerMemories() const { return lowerMemories; }
146 bool shouldDedup() const { return !noDedup; }
147 bool shouldDedupClasses() const { return dedupClasses; }
148 bool shouldEnableDebugInfo() const { return enableDebugInfo; }
150 bool shouldConvertVecOfBundle() const { return vbToBV; }
151 bool shouldStripDebugInfo() const { return stripDebugInfo; }
158 bool shouldLowerToCore() const { return lowerToCore; }
163 bool shouldAddMuxPragmas() const { return addMuxPragmas; }
172
177
179
180 bool getLintXmrsInDesign() const { return lintXmrsInDesign; }
181
182 bool getEmitAllBindFiles() const { return emitAllBindFiles; }
183
185
187
188 // Setters, used by the CAPI
190 outputFilename = name;
191 return *this;
192 }
193
196 return *this;
197 }
198
201 return *this;
202 }
203
206 return *this;
207 }
208
210 probesToSignals = value;
211 return *this;
212 }
213
219
222 preserveMode = value;
223 return *this;
224 }
225
227 enableDebugInfo = value;
228 return *this;
229 }
230
232 buildMode = value;
233 return *this;
234 }
235
237 disableLayerSink = value;
238 return *this;
239 }
240
242 disableOptimization = value;
243 return *this;
244 }
245
247 vbToBV = value;
248 return *this;
249 }
250
252 noDedup = value;
253 return *this;
254 }
255
257 dedupClasses = value;
258 return *this;
259 }
260
262 companionMode = value;
263 return *this;
264 }
265
267 noViews = value;
268 return *this;
269 }
270
275
277 lowerMemories = value;
278 return *this;
279 }
280
282 blackBoxRootPath = value;
283 return *this;
284 }
285
287 replSeqMem = value;
288 return *this;
289 }
290
292 replSeqMemFile = value;
293 return *this;
294 }
295
297 ignoreReadEnableMem = value;
298 return *this;
299 }
300
303 return *this;
304 }
305
308 return *this;
309 }
310
312 lowerToCore = value;
313 return *this;
314 }
315
317 addMuxPragmas = value;
318 return *this;
319 }
320
325
328 return *this;
329 }
330
336
338 ckgModuleName = value;
339 return *this;
340 }
341
342 FirtoolOptions &setCkgInputName(StringRef value) {
343 ckgInputName = value;
344 return *this;
345 }
346
348 ckgOutputName = value;
349 return *this;
350 }
351
353 ckgEnableName = value;
354 return *this;
355 }
356
358 ckgTestEnableName = value;
359 return *this;
360 }
361
363 exportModuleHierarchy = value;
364 return *this;
365 }
366
368 stripFirDebugInfo = value;
369 return *this;
370 }
371
373 stripDebugInfo = value;
374 return *this;
375 }
376
378 fixupEICGWrapper = value;
379 return *this;
380 }
381
383 disableCSEinClasses = value;
384 return *this;
385 }
386
389 return *this;
390 }
391
396
399 return *this;
400 }
401
403 lintStaticAsserts = value;
404 return *this;
405 }
406
408 lintXmrsInDesign = value;
409 return *this;
410 }
411
413 emitAllBindFiles = value;
414 return *this;
415 }
416
419 return *this;
420 }
421
423 domainMode = value;
424 return *this;
425 }
426
427private:
428 std::string outputFilename;
429
430 // LowerFIRRTLAnnotations
434
442 bool vbToBV;
449 std::string blackBoxRootPath;
451 std::string replSeqMemFile;
461 std::string ckgModuleName;
462 std::string ckgInputName;
463 std::string ckgOutputName;
464 std::string ckgEnableName;
465 std::string ckgTestEnableName;
466 std::string ckgInstName;
480};
481
483
484LogicalResult populatePreprocessTransforms(mlir::PassManager &pm,
485 const FirtoolOptions &opt);
486
487LogicalResult populateCHIRRTLToLowFIRRTL(mlir::PassManager &pm,
488 const FirtoolOptions &opt);
489
490LogicalResult populateLowFIRRTLToHW(mlir::PassManager &pm,
491 const FirtoolOptions &opt,
492 StringRef inputFilename);
493
494LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt);
495
496LogicalResult populateExportVerilog(mlir::PassManager &pm,
497 const FirtoolOptions &opt,
498 std::unique_ptr<llvm::raw_ostream> os);
499
500LogicalResult populateExportVerilog(mlir::PassManager &pm,
501 const FirtoolOptions &opt,
502 llvm::raw_ostream &os);
503
504LogicalResult populateExportSplitVerilog(mlir::PassManager &pm,
505 const FirtoolOptions &opt,
506 llvm::StringRef directory);
507
508LogicalResult populateFinalizeIR(mlir::PassManager &pm,
509 const FirtoolOptions &opt);
510
511LogicalResult populateHWToBTOR2(mlir::PassManager &pm,
512 const FirtoolOptions &opt,
513 llvm::raw_ostream &os);
514
515} // namespace firtool
516} // namespace circt
517
518#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:377
FirtoolOptions & setPreserveAggregate(firrtl::PreserveAggregate::PreserveMode value)
Definition Firtool.h:215
FirtoolOptions & setAddVivadoRAMAddressConflictSynthesisBugWorkaround(bool value)
Definition Firtool.h:332
bool shouldStripDebugInfo() const
Definition Firtool.h:151
FirtoolOptions & setBuildMode(BuildMode value)
Definition Firtool.h:231
FirtoolOptions & setDisableAggressiveMergeConnections(bool value)
Definition Firtool.h:271
FirtoolOptions & setCkgInputName(StringRef value)
Definition Firtool.h:342
firrtl::PreserveAggregate::PreserveMode getPreserveAggregate() const
Definition Firtool.h:109
FirtoolOptions & setLowerToCore(bool value)
Definition Firtool.h:311
bool shouldAddVivadoRAMAddressConflictSynthesisBugWorkaround() const
Definition Firtool.h:164
bool shouldDisableLayerSink() const
Definition Firtool.h:143
firrtl::PreserveValues::PreserveMode preserveMode
Definition Firtool.h:437
FirtoolOptions & setDisableCSEinClasses(bool value)
Definition Firtool.h:382
auto getVerificationFlavor() const
Definition Firtool.h:159
@ 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:121
FirtoolOptions & setCkgTestEnableName(StringRef value)
Definition Firtool.h:357
FirtoolOptions & mergeDisableRandom(RandomKind kind)
Definition Firtool.h:85
bool isDefaultOutputFilename() const
Definition Firtool.h:131
StringRef getOutputFilename() const
Definition Firtool.h:102
FirtoolOptions & setDedupClasses(bool value)
Definition Firtool.h:256
bool shouldDisableAggressiveMergeConnections() const
Definition Firtool.h:154
StringRef getReplaceSequentialMemoriesFile() const
Definition Firtool.h:104
bool addVivadoRAMAddressConflictSynthesisBugWorkaround
Definition Firtool.h:460
FirtoolOptions & setSymbolicValueLowering(verif::SymbolicValueLowering mode)
Definition Firtool.h:392
FirtoolOptions & setLowerMemories(bool value)
Definition Firtool.h:276
FirtoolOptions & setNoDedup(bool value)
Definition Firtool.h:251
bool shouldFixupEICGWrapper() const
Definition Firtool.h:167
bool shouldConvertProbesToSignals() const
Definition Firtool.h:141
firrtl::PreserveValues::PreserveMode getPreserveMode() const
Definition Firtool.h:90
FirtoolOptions & setLowerAnnotationsNoRefTypePorts(bool value)
Definition Firtool.h:204
bool shouldDedupClasses() const
Definition Firtool.h:147
StringRef getBlackBoxRootPath() const
Definition Firtool.h:103
bool shouldDisableCSEinClasses() const
Definition Firtool.h:168
bool shouldDisableOptimization() const
Definition Firtool.h:144
firrtl::CompanionMode getCompanionMode() const
Definition Firtool.h:112
bool shouldDisableClasslessAnnotations() const
Definition Firtool.h:135
FirtoolOptions & setAddMuxPragmas(bool value)
Definition Firtool.h:316
FirtoolOptions & setPreserveValues(firrtl::PreserveValues::PreserveMode value)
Definition Firtool.h:221
bool getEmitAllBindFiles() const
Definition Firtool.h:182
bool shouldReplaceSequentialMemories() const
Definition Firtool.h:142
FirtoolOptions & setDomainMode(DomainMode value)
Definition Firtool.h:422
bool shouldIgnoreReadEnableMemories() const
Definition Firtool.h:149
FirtoolOptions & setOutputAnnotationFilename(StringRef value)
Definition Firtool.h:301
FirtoolOptions & setCkgOutputName(StringRef value)
Definition Firtool.h:347
bool isRandomEnabled(RandomKind kind) const
Definition Firtool.h:71
bool shouldDisableUnknownAnnotations() const
Definition Firtool.h:132
FirtoolOptions & setNoViews(bool value)
Definition Firtool.h:266
static RandomKind mergeRandomKind(RandomKind current, RandomKind incoming)
Advance the disabled-randomization lattice.
Definition Firtool.h:77
FirtoolOptions & setVbToBV(bool value)
Definition Firtool.h:246
bool shouldAddMuxPragmas() const
Definition Firtool.h:163
bool shouldEnableAnnotationWarning() const
Definition Firtool.h:157
FirtoolOptions & setEmitAllBindFiles(bool value)
Definition Firtool.h:412
FirtoolOptions & setCkgModuleName(StringRef value)
Definition Firtool.h:337
bool shouldConvertVecOfBundle() const
Definition Firtool.h:150
StringRef getOutputAnnotationFilename() const
Definition Firtool.h:105
bool shouldStripFirDebugInfo() const
Definition Firtool.h:152
FirtoolOptions & setConvertProbesToSignals(bool value)
Definition Firtool.h:209
FirtoolOptions & setIgnoreReadEnableMem(bool value)
Definition Firtool.h:296
FirtoolOptions & setEnableDebugInfo(bool value)
Definition Firtool.h:226
FirtoolOptions & setDisableAnnotationsClassless(bool value)
Definition Firtool.h:199
FirtoolOptions & setDisableLayerSink(bool value)
Definition Firtool.h:236
FirtoolOptions & setEmitSeparateAlwaysBlocks(bool value)
Definition Firtool.h:326
FirtoolOptions & setDisableOptimization(bool value)
Definition Firtool.h:241
std::string outputAnnotationFilename
Definition Firtool.h:454
firrtl::VerificationFlavor verificationFlavor
Definition Firtool.h:458
firrtl::PreserveAggregate::PreserveMode preserveAggregate
Definition Firtool.h:436
FirtoolOptions & setInlineInputOnlyModules(bool value)
Definition Firtool.h:417
FirtoolOptions & setLintXmrsInDesign(bool value)
Definition Firtool.h:407
bool shouldLowerMemories() const
Definition Firtool.h:145
FirtoolOptions & setDisableWireElimination(bool value)
Definition Firtool.h:397
FirtoolOptions & setCompanionMode(firrtl::CompanionMode value)
Definition Firtool.h:261
FirtoolOptions & setVerificationFlavor(firrtl::VerificationFlavor value)
Definition Firtool.h:321
DomainMode getDomainMode() const
Definition Firtool.h:186
bool getLintStaticAsserts() const
Definition Firtool.h:178
bool shouldLowerNoRefTypePortAnnotations() const
Definition Firtool.h:138
FirtoolOptions & setReplSeqMem(bool value)
Definition Firtool.h:286
verif::SymbolicValueLowering getSymbolicValueLowering() const
Definition Firtool.h:173
FirtoolOptions & setCkgEnableName(StringRef value)
Definition Firtool.h:352
bool shouldExportModuleHierarchy() const
Definition Firtool.h:153
firrtl::CompanionMode companionMode
Definition Firtool.h:445
FirtoolOptions & setStripDebugInfo(bool value)
Definition Firtool.h:372
FirtoolOptions & setExportModuleHierarchy(bool value)
Definition Firtool.h:362
FirtoolOptions & setDisableUnknownAnnotations(bool disable)
Definition Firtool.h:194
bool shouldDisableWireElimination() const
Definition Firtool.h:176
FirtoolOptions & setEnableAnnotationWarning(bool value)
Definition Firtool.h:306
FirtoolOptions & setReplSeqMemFile(StringRef value)
Definition Firtool.h:291
bool shouldSelectDefaultInstanceChoice() const
Definition Firtool.h:169
FirtoolOptions & setLintStaticAsserts(bool value)
Definition Firtool.h:402
bool shouldInlineInputOnlyModules() const
Definition Firtool.h:184
verif::SymbolicValueLowering symbolicValueLowering
Definition Firtool.h:473
bool getLintXmrsInDesign() const
Definition Firtool.h:180
FirtoolOptions & setSelectDefaultInstanceChoice(bool value)
Definition Firtool.h:387
FirtoolOptions & setStripFirDebugInfo(bool value)
Definition Firtool.h:367
seq::ExternalizeClockGateOptions getClockGateOptions() const
Definition Firtool.h:116
bool shouldEnableDebugInfo() const
Definition Firtool.h:148
bool shouldEmitSeparateAlwaysBlocks() const
Definition Firtool.h:160
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:189
FirtoolOptions & setBlackBoxRootPath(StringRef value)
Definition Firtool.h:281
@ 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:236
LogicalResult populateHWToBTOR2(mlir::PassManager &pm, const FirtoolOptions &opt, llvm::raw_ostream &os)
BTOR2 emission pipeline, triggered with --btor2 flag.
Definition Firtool.cpp:447
LogicalResult populateExportSplitVerilog(mlir::PassManager &pm, const FirtoolOptions &opt, llvm::StringRef directory)
Definition Firtool.cpp:428
LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:325
LogicalResult populateExportVerilog(mlir::PassManager &pm, const FirtoolOptions &opt, std::unique_ptr< llvm::raw_ostream > os)
Definition Firtool.cpp:409
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:826
LogicalResult populateFinalizeIR(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition Firtool.cpp:438
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.