CIRCT  20.0.0git
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 
23 namespace circt {
24 namespace firtool {
25 //===----------------------------------------------------------------------===//
26 // FirtoolOptions
27 //===----------------------------------------------------------------------===//
28 
29 /// Set of options used to control the behavior of the firtool pipeline.
31 public:
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:
46  case BuildModeRelease:
48  case BuildModeDefault:
49  return preserveMode;
50  }
51  llvm_unreachable("unknown build mode");
52  }
53 
54  StringRef getOutputFilename() const { return outputFilename; }
55  StringRef getBlackBoxRootPath() const { return blackBoxRootPath; }
58  }
59  StringRef getReplaceSequentialMemoriesFile() const { return replSeqMemFile; }
60  StringRef getOutputAnnotationFilename() const {
62  }
63 
65  return preserveAggregate;
66  }
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 == "-"; }
87  }
90  }
93  }
96  }
99  bool shouldDisableLayerSink() const { return disableLayerSink; }
102  bool shouldLowerMemories() const { return lowerMemories; }
103  bool shouldDedup() const { return !noDedup; }
104  bool shouldEnableDebugInfo() const { return enableDebugInfo; }
107  bool shouldConvertVecOfBundle() const { return vbToBV; }
110  }
113  }
116  }
117  bool shouldStripDebugInfo() const { return stripDebugInfo; }
122  }
124  auto getVerificationFlavor() const { return verificationFlavor; }
127  }
128  bool shouldAddMuxPragmas() const { return addMuxPragmas; }
131  }
132  bool shouldExtractTestCode() const { return extractTestCode; }
133  bool shouldFixupEICGWrapper() const { return fixupEICGWrapper; }
138  }
139 
140  // Setters, used by the CAPI
142  outputFilename = name;
143  return *this;
144  }
145 
147  disableAnnotationsUnknown = disable;
148  return *this;
149  }
150 
153  return *this;
154  }
155 
158  return *this;
159  }
160 
162  allowAddingPortsOnPublic = value;
163  return *this;
164  }
165 
167  probesToSignals = value;
168  return *this;
169  }
170 
173  preserveAggregate = value;
174  return *this;
175  }
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 
213  FirtoolOptions &setVbToBV(bool value) {
214  vbToBV = value;
215  return *this;
216  }
217 
218  FirtoolOptions &setNoDedup(bool value) {
219  noDedup = value;
220  return *this;
221  }
222 
224  companionMode = value;
225  return *this;
226  }
227 
230  return *this;
231  }
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 
253  FirtoolOptions &setReplSeqMemFile(StringRef value) {
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 
274  outputAnnotationFilename = value;
275  return *this;
276  }
277 
279  enableAnnotationWarning = value;
280  return *this;
281  }
282 
284  addMuxPragmas = value;
285  return *this;
286  }
287 
289  verificationFlavor = value;
290  return *this;
291  }
292 
294  emitSeparateAlwaysBlocks = value;
295  return *this;
296  }
297 
300  return *this;
301  }
302 
305  return *this;
306  }
307 
309  etcDisableModuleInlining = value;
310  return *this;
311  }
312 
316  return *this;
317  }
318 
319  FirtoolOptions &setCkgModuleName(StringRef value) {
320  ckgModuleName = value;
321  return *this;
322  }
323 
324  FirtoolOptions &setCkgInputName(StringRef value) {
325  ckgInputName = value;
326  return *this;
327  }
328 
329  FirtoolOptions &setCkgOutputName(StringRef value) {
330  ckgOutputName = value;
331  return *this;
332  }
333 
334  FirtoolOptions &setCkgEnableName(StringRef value) {
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 
379 private:
380  std::string outputFilename;
394  bool vbToBV;
395  bool noDedup;
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 
432 LogicalResult populatePreprocessTransforms(mlir::PassManager &pm,
433  const FirtoolOptions &opt);
434 
435 LogicalResult populateCHIRRTLToLowFIRRTL(mlir::PassManager &pm,
436  const FirtoolOptions &opt,
437  StringRef inputFilename);
438 
439 LogicalResult populateLowFIRRTLToHW(mlir::PassManager &pm,
440  const FirtoolOptions &opt);
441 
442 LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt);
443 
444 LogicalResult populateExportVerilog(mlir::PassManager &pm,
445  const FirtoolOptions &opt,
446  std::unique_ptr<llvm::raw_ostream> os);
447 
448 LogicalResult populateExportVerilog(mlir::PassManager &pm,
449  const FirtoolOptions &opt,
450  llvm::raw_ostream &os);
451 
452 LogicalResult populateExportSplitVerilog(mlir::PassManager &pm,
453  const FirtoolOptions &opt,
454  llvm::StringRef directory);
455 
456 LogicalResult populateFinalizeIR(mlir::PassManager &pm,
457  const FirtoolOptions &opt);
458 
459 LogicalResult 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 & setCkgTestEnableName(StringRef value)
Definition: Firtool.h:339
FirtoolOptions & setOutputFilename(StringRef name)
Definition: Firtool.h:141
FirtoolOptions & setCkgModuleName(StringRef value)
Definition: Firtool.h:319
bool shouldStripDebugInfo() const
Definition: Firtool.h:117
FirtoolOptions & setChiselInterfaceOutDirectory(StringRef value)
Definition: Firtool.h:208
FirtoolOptions & setIgnoreReadEnableMem(bool value)
Definition: Firtool.h:263
firrtl::PreserveAggregate::PreserveMode getPreserveAggregate() const
Definition: Firtool.h:64
FirtoolOptions & setLowerAnnotationsNoRefTypePorts(bool value)
Definition: Firtool.h:156
bool shouldAddVivadoRAMAddressConflictSynthesisBugWorkaround() const
Definition: Firtool.h:129
bool shouldDisableLayerSink() const
Definition: Firtool.h:99
firrtl::PreserveValues::PreserveMode preserveMode
Definition: Firtool.h:387
FirtoolOptions & setExportChiselInterface(bool value)
Definition: Firtool.h:203
FirtoolOptions & setDisableLayerSink(bool value)
Definition: Firtool.h:193
bool shouldAddCompanionAssume() const
Definition: Firtool.h:134
auto getVerificationFlavor() const
Definition: Firtool.h:124
bool isDefaultOutputFilename() const
Definition: Firtool.h:84
FirtoolOptions & setFixupEICGWrapper(bool value)
Definition: Firtool.h:359
StringRef getOutputFilename() const
Definition: Firtool.h:54
bool shouldDisableAggressiveMergeConnections() const
Definition: Firtool.h:120
FirtoolOptions & setDisableUnknownAnnotations(bool disable)
Definition: Firtool.h:146
StringRef getReplaceSequentialMemoriesFile() const
Definition: Firtool.h:59
FirtoolOptions & setPreserveAggregate(firrtl::PreserveAggregate::PreserveMode value)
Definition: Firtool.h:172
bool addVivadoRAMAddressConflictSynthesisBugWorkaround
Definition: Firtool.h:414
FirtoolOptions & setCkgEnableName(StringRef value)
Definition: Firtool.h:334
FirtoolOptions & setReplSeqMemFile(StringRef value)
Definition: Firtool.h:253
bool shouldExportChiselInterface() const
Definition: Firtool.h:106
bool shouldAdvancedLayerSink() const
Definition: Firtool.h:101
bool shouldExtractTestCode() const
Definition: Firtool.h:132
FirtoolOptions & setEtcDisableModuleInlining(bool value)
Definition: Firtool.h:308
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
StringRef getBlackBoxRootPath() const
Definition: Firtool.h:55
bool shouldDisableCSEinClasses() const
Definition: Firtool.h:135
bool shouldDisableOptimization() const
Definition: Firtool.h:100
FirtoolOptions & setCkgOutputName(StringRef value)
Definition: Firtool.h:329
FirtoolOptions & setExtractTestCode(bool value)
Definition: Firtool.h:258
firrtl::CompanionMode getCompanionMode() const
Definition: Firtool.h:67
bool shouldDisableClasslessAnnotations() const
Definition: Firtool.h:88
FirtoolOptions & setSelectDefaultInstanceChoice(bool value)
Definition: Firtool.h:374
FirtoolOptions & setEtcDisableInstanceExtraction(bool value)
Definition: Firtool.h:298
bool shouldReplaceSequentialMemories() const
Definition: Firtool.h:98
FirtoolOptions & setStripDebugInfo(bool value)
Definition: Firtool.h:354
FirtoolOptions & setAddCompanionAssume(bool value)
Definition: Firtool.h:364
bool shouldIgnoreReadEnableMemories() const
Definition: Firtool.h:105
FirtoolOptions & setVbToBV(bool value)
Definition: Firtool.h:213
FirtoolOptions & setDisableAnnotationsClassless(bool value)
Definition: Firtool.h:151
FirtoolOptions & setLowerMemories(bool value)
Definition: Firtool.h:238
bool isRandomEnabled(RandomKind kind) const
Definition: Firtool.h:38
FirtoolOptions & setReplSeqMem(bool value)
Definition: Firtool.h:248
bool shouldDisableUnknownAnnotations() const
Definition: Firtool.h:85
FirtoolOptions & setDisableRandom(RandomKind value)
Definition: Firtool.h:268
bool shouldAddMuxPragmas() const
Definition: Firtool.h:128
bool shouldEnableAnnotationWarning() const
Definition: Firtool.h:123
FirtoolOptions & setVerificationFlavor(firrtl::VerificationFlavor value)
Definition: Firtool.h:288
bool shouldEtcDisableInstanceExtraction() const
Definition: Firtool.h:108
bool shouldConvertVecOfBundle() const
Definition: Firtool.h:107
StringRef getOutputAnnotationFilename() const
Definition: Firtool.h:60
FirtoolOptions & setCompanionMode(firrtl::CompanionMode value)
Definition: Firtool.h:223
bool shouldStripFirDebugInfo() const
Definition: Firtool.h:118
bool shouldEtcDisableRegisterExtraction() const
Definition: Firtool.h:111
FirtoolOptions & setBuildMode(BuildMode value)
Definition: Firtool.h:188
std::string outputAnnotationFilename
Definition: Firtool.h:406
firrtl::VerificationFlavor verificationFlavor
Definition: Firtool.h:409
FirtoolOptions & setNoDedup(bool value)
Definition: Firtool.h:218
firrtl::PreserveAggregate::PreserveMode preserveAggregate
Definition: Firtool.h:386
bool shouldLowerMemories() const
Definition: Firtool.h:102
FirtoolOptions & setClockGateOptions(seq::ExternalizeClockGateOptions &opts)
Definition: Firtool.h:74
bool shouldEtcDisableModuleInlining() const
Definition: Firtool.h:114
FirtoolOptions & setAddVivadoRAMAddressConflictSynthesisBugWorkaround(bool value)
Definition: Firtool.h:314
bool shouldAllowAddingPortsOnPublic() const
Definition: Firtool.h:94
FirtoolOptions & setConvertProbesToSignals(bool value)
Definition: Firtool.h:166
FirtoolOptions & setDisableCSEinClasses(bool value)
Definition: Firtool.h:369
FirtoolOptions & setEnableDebugInfo(bool value)
Definition: Firtool.h:183
FirtoolOptions & setEmitSeparateAlwaysBlocks(bool value)
Definition: Firtool.h:293
bool shouldLowerNoRefTypePortAnnotations() const
Definition: Firtool.h:91
bool shouldExportModuleHierarchy() const
Definition: Firtool.h:119
FirtoolOptions & setPreserveValues(firrtl::PreserveValues::PreserveMode value)
Definition: Firtool.h:178
firrtl::CompanionMode companionMode
Definition: Firtool.h:396
FirtoolOptions & setCkgInputName(StringRef value)
Definition: Firtool.h:324
FirtoolOptions & setStripFirDebugInfo(bool value)
Definition: Firtool.h:349
FirtoolOptions & setOutputAnnotationFilename(StringRef value)
Definition: Firtool.h:273
FirtoolOptions & setEnableAnnotationWarning(bool value)
Definition: Firtool.h:278
FirtoolOptions & setBlackBoxRootPath(StringRef value)
Definition: Firtool.h:243
bool shouldSelectDefaultInstanceChoice() const
Definition: Firtool.h:136
FirtoolOptions & setDisableAggressiveMergeConnections(bool value)
Definition: Firtool.h:228
FirtoolOptions & setAllowAddingPortsOnPublic(bool value)
Definition: Firtool.h:161
FirtoolOptions & setAddMuxPragmas(bool value)
Definition: Firtool.h:283
seq::ExternalizeClockGateOptions getClockGateOptions() const
Definition: Firtool.h:69
bool shouldEnableDebugInfo() const
Definition: Firtool.h:104
bool shouldEmitSeparateAlwaysBlocks() const
Definition: Firtool.h:125
FirtoolOptions & setDisableOptimization(bool value)
Definition: Firtool.h:198
FirtoolOptions & setEtcDisableRegisterExtraction(bool value)
Definition: Firtool.h:303
StringRef getChiselInterfaceOutputDirectory() const
Definition: Firtool.h:56
FirtoolOptions & setAdvancedLayerSink(bool value)
Definition: Firtool.h:233
FirtoolOptions & setExportModuleHierarchy(bool value)
Definition: Firtool.h:344
@ 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.
Definition: DebugAnalysis.h:21