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 getOmirOutputFile() const { return omirOutFile; }
56  StringRef getBlackBoxRootPath() const { return blackBoxRootPath; }
59  }
60  StringRef getReplaceSequentialMemoriesFile() const { return replSeqMemFile; }
61  StringRef getOutputAnnotationFilename() const {
63  }
64 
66  return preserveAggregate;
67  }
69 
70  seq::ExternalizeClockGateOptions getClockGateOptions() const {
73  }
74 
75  FirtoolOptions &setClockGateOptions(seq::ExternalizeClockGateOptions &opts) {
76  ckgModuleName = opts.moduleName;
77  ckgInputName = opts.inputName;
78  ckgOutputName = opts.outputName;
79  ckgEnableName = opts.enableName;
80  ckgTestEnableName = opts.testEnableName;
81  ckgInstName = opts.instName;
82  return *this;
83  }
84 
85  bool isDefaultOutputFilename() const { return outputFilename == "-"; }
88  }
91  }
94  }
97  }
102  bool shouldLowerMemories() const { return lowerMemories; }
103  bool shouldDedup() const { return !noDedup; }
104  bool shouldEnableDebugInfo() const { return enableDebugInfo; }
106  bool shouldEmitOMIR() const { return emitOMIR; }
108  bool shouldConvertVecOfBundle() const { return vbToBV; }
111  }
114  }
117  }
118  bool shouldStripDebugInfo() const { return stripDebugInfo; }
123  }
125  auto getVerificationFlavor() const { return verificationFlavor; }
128  }
129  bool shouldAddMuxPragmas() const { return addMuxPragmas; }
132  }
133  bool shouldExtractTestCode() const { return extractTestCode; }
134  bool shouldFixupEICGWrapper() const { return fixupEICGWrapper; }
136 
137  // Setters, used by the CAPI
139  outputFilename = name;
140  return *this;
141  }
142 
144  disableAnnotationsUnknown = disable;
145  return *this;
146  }
147 
150  return *this;
151  }
152 
155  return *this;
156  }
157 
159  allowAddingPortsOnPublic = value;
160  return *this;
161  }
162 
164  probesToSignals = value;
165  return *this;
166  }
167 
170  preserveAggregate = value;
171  return *this;
172  }
173 
176  preserveMode = value;
177  return *this;
178  }
179 
181  enableDebugInfo = value;
182  return *this;
183  }
184 
186  buildMode = value;
187  return *this;
188  }
189 
191  disableOptimization = value;
192  return *this;
193  }
194 
196  exportChiselInterface = value;
197  return *this;
198  }
199 
202  return *this;
203  }
204 
205  FirtoolOptions &setVbToBV(bool value) {
206  vbToBV = value;
207  return *this;
208  }
209 
210  FirtoolOptions &setNoDedup(bool value) {
211  noDedup = value;
212  return *this;
213  }
214 
216  companionMode = value;
217  return *this;
218  }
219 
222  return *this;
223  }
224 
226  emitOMIR = value;
227  return *this;
228  }
229 
230  FirtoolOptions &setOmirOutFile(StringRef value) {
231  omirOutFile = value;
232  return *this;
233  }
234 
236  advancedLayerSink = value;
237  return *this;
238  }
239 
241  lowerMemories = value;
242  return *this;
243  }
244 
246  blackBoxRootPath = value;
247  return *this;
248  }
249 
251  replSeqMem = value;
252  return *this;
253  }
254 
255  FirtoolOptions &setReplSeqMemFile(StringRef value) {
256  replSeqMemFile = value;
257  return *this;
258  }
259 
261  extractTestCode = value;
262  return *this;
263  }
264 
266  ignoreReadEnableMem = value;
267  return *this;
268  }
269 
271  disableRandom = value;
272  return *this;
273  }
274 
276  outputAnnotationFilename = value;
277  return *this;
278  }
279 
281  enableAnnotationWarning = value;
282  return *this;
283  }
284 
286  addMuxPragmas = value;
287  return *this;
288  }
289 
291  verificationFlavor = value;
292  return *this;
293  }
294 
296  emitSeparateAlwaysBlocks = value;
297  return *this;
298  }
299 
302  return *this;
303  }
304 
307  return *this;
308  }
309 
311  etcDisableModuleInlining = value;
312  return *this;
313  }
314 
318  return *this;
319  }
320 
321  FirtoolOptions &setCkgModuleName(StringRef value) {
322  ckgModuleName = value;
323  return *this;
324  }
325 
326  FirtoolOptions &setCkgInputName(StringRef value) {
327  ckgInputName = value;
328  return *this;
329  }
330 
331  FirtoolOptions &setCkgOutputName(StringRef value) {
332  ckgOutputName = value;
333  return *this;
334  }
335 
336  FirtoolOptions &setCkgEnableName(StringRef value) {
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  addCompanionAssume = value;
368  return *this;
369  }
370 
371 private:
372  std::string outputFilename;
385  bool vbToBV;
386  bool noDedup;
389  bool emitOMIR;
390  std::string omirOutFile;
393  std::string blackBoxRootPath;
395  std::string replSeqMemFile;
408  std::string ckgModuleName;
409  std::string ckgInputName;
410  std::string ckgOutputName;
411  std::string ckgEnableName;
412  std::string ckgTestEnableName;
413  std::string ckgInstName;
419 };
420 
422 
423 LogicalResult populatePreprocessTransforms(mlir::PassManager &pm,
424  const FirtoolOptions &opt);
425 
426 LogicalResult populateCHIRRTLToLowFIRRTL(mlir::PassManager &pm,
427  const FirtoolOptions &opt,
428  StringRef inputFilename);
429 
430 LogicalResult populateLowFIRRTLToHW(mlir::PassManager &pm,
431  const FirtoolOptions &opt);
432 
433 LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt);
434 
435 LogicalResult populateExportVerilog(mlir::PassManager &pm,
436  const FirtoolOptions &opt,
437  std::unique_ptr<llvm::raw_ostream> os);
438 
439 LogicalResult populateExportVerilog(mlir::PassManager &pm,
440  const FirtoolOptions &opt,
441  llvm::raw_ostream &os);
442 
443 LogicalResult populateExportSplitVerilog(mlir::PassManager &pm,
444  const FirtoolOptions &opt,
445  llvm::StringRef directory);
446 
447 LogicalResult populateFinalizeIR(mlir::PassManager &pm,
448  const FirtoolOptions &opt);
449 
450 LogicalResult populateHWToBTOR2(mlir::PassManager &pm,
451  const FirtoolOptions &opt,
452  llvm::raw_ostream &os);
453 
454 } // namespace firtool
455 } // namespace circt
456 
457 #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:341
FirtoolOptions & setOutputFilename(StringRef name)
Definition: Firtool.h:138
FirtoolOptions & setCkgModuleName(StringRef value)
Definition: Firtool.h:321
bool shouldStripDebugInfo() const
Definition: Firtool.h:118
FirtoolOptions & setChiselInterfaceOutDirectory(StringRef value)
Definition: Firtool.h:200
FirtoolOptions & setIgnoreReadEnableMem(bool value)
Definition: Firtool.h:265
firrtl::PreserveAggregate::PreserveMode getPreserveAggregate() const
Definition: Firtool.h:65
FirtoolOptions & setLowerAnnotationsNoRefTypePorts(bool value)
Definition: Firtool.h:153
bool shouldAddVivadoRAMAddressConflictSynthesisBugWorkaround() const
Definition: Firtool.h:130
firrtl::PreserveValues::PreserveMode preserveMode
Definition: Firtool.h:379
FirtoolOptions & setExportChiselInterface(bool value)
Definition: Firtool.h:195
bool shouldAddCompanionAssume() const
Definition: Firtool.h:135
auto getVerificationFlavor() const
Definition: Firtool.h:125
StringRef getOmirOutputFile() const
Definition: Firtool.h:55
bool isDefaultOutputFilename() const
Definition: Firtool.h:85
FirtoolOptions & setFixupEICGWrapper(bool value)
Definition: Firtool.h:361
StringRef getOutputFilename() const
Definition: Firtool.h:54
bool shouldDisableAggressiveMergeConnections() const
Definition: Firtool.h:121
FirtoolOptions & setDisableUnknownAnnotations(bool disable)
Definition: Firtool.h:143
StringRef getReplaceSequentialMemoriesFile() const
Definition: Firtool.h:60
FirtoolOptions & setPreserveAggregate(firrtl::PreserveAggregate::PreserveMode value)
Definition: Firtool.h:169
bool addVivadoRAMAddressConflictSynthesisBugWorkaround
Definition: Firtool.h:407
FirtoolOptions & setCkgEnableName(StringRef value)
Definition: Firtool.h:336
FirtoolOptions & setReplSeqMemFile(StringRef value)
Definition: Firtool.h:255
bool shouldExportChiselInterface() const
Definition: Firtool.h:107
bool shouldAdvancedLayerSink() const
Definition: Firtool.h:101
bool shouldExtractTestCode() const
Definition: Firtool.h:133
FirtoolOptions & setEtcDisableModuleInlining(bool value)
Definition: Firtool.h:310
std::string chiselInterfaceOutDirectory
Definition: Firtool.h:384
bool shouldFixupEICGWrapper() const
Definition: Firtool.h:134
bool shouldConvertProbesToSignals() const
Definition: Firtool.h:98
firrtl::PreserveValues::PreserveMode getPreserveMode() const
Definition: Firtool.h:42
StringRef getBlackBoxRootPath() const
Definition: Firtool.h:56
bool shouldDisableOptimization() const
Definition: Firtool.h:100
FirtoolOptions & setCkgOutputName(StringRef value)
Definition: Firtool.h:331
FirtoolOptions & setExtractTestCode(bool value)
Definition: Firtool.h:260
firrtl::CompanionMode getCompanionMode() const
Definition: Firtool.h:68
FirtoolOptions & setOmirOutFile(StringRef value)
Definition: Firtool.h:230
bool shouldDisableClasslessAnnotations() const
Definition: Firtool.h:89
FirtoolOptions & setEtcDisableInstanceExtraction(bool value)
Definition: Firtool.h:300
bool shouldReplaceSequentialMemories() const
Definition: Firtool.h:99
FirtoolOptions & setStripDebugInfo(bool value)
Definition: Firtool.h:356
FirtoolOptions & setAddCompanionAssume(bool value)
Definition: Firtool.h:366
bool shouldIgnoreReadEnableMemories() const
Definition: Firtool.h:105
FirtoolOptions & setVbToBV(bool value)
Definition: Firtool.h:205
FirtoolOptions & setDisableAnnotationsClassless(bool value)
Definition: Firtool.h:148
FirtoolOptions & setLowerMemories(bool value)
Definition: Firtool.h:240
bool isRandomEnabled(RandomKind kind) const
Definition: Firtool.h:38
FirtoolOptions & setReplSeqMem(bool value)
Definition: Firtool.h:250
bool shouldDisableUnknownAnnotations() const
Definition: Firtool.h:86
FirtoolOptions & setDisableRandom(RandomKind value)
Definition: Firtool.h:270
bool shouldAddMuxPragmas() const
Definition: Firtool.h:129
bool shouldEnableAnnotationWarning() const
Definition: Firtool.h:124
FirtoolOptions & setVerificationFlavor(firrtl::VerificationFlavor value)
Definition: Firtool.h:290
bool shouldEtcDisableInstanceExtraction() const
Definition: Firtool.h:109
bool shouldConvertVecOfBundle() const
Definition: Firtool.h:108
FirtoolOptions & setEmitOMIR(bool value)
Definition: Firtool.h:225
StringRef getOutputAnnotationFilename() const
Definition: Firtool.h:61
FirtoolOptions & setCompanionMode(firrtl::CompanionMode value)
Definition: Firtool.h:215
bool shouldStripFirDebugInfo() const
Definition: Firtool.h:119
bool shouldEtcDisableRegisterExtraction() const
Definition: Firtool.h:112
FirtoolOptions & setBuildMode(BuildMode value)
Definition: Firtool.h:185
std::string outputAnnotationFilename
Definition: Firtool.h:399
firrtl::VerificationFlavor verificationFlavor
Definition: Firtool.h:402
FirtoolOptions & setNoDedup(bool value)
Definition: Firtool.h:210
firrtl::PreserveAggregate::PreserveMode preserveAggregate
Definition: Firtool.h:378
bool shouldLowerMemories() const
Definition: Firtool.h:102
FirtoolOptions & setClockGateOptions(seq::ExternalizeClockGateOptions &opts)
Definition: Firtool.h:75
bool shouldEtcDisableModuleInlining() const
Definition: Firtool.h:115
FirtoolOptions & setAddVivadoRAMAddressConflictSynthesisBugWorkaround(bool value)
Definition: Firtool.h:316
bool shouldAllowAddingPortsOnPublic() const
Definition: Firtool.h:95
FirtoolOptions & setConvertProbesToSignals(bool value)
Definition: Firtool.h:163
FirtoolOptions & setEnableDebugInfo(bool value)
Definition: Firtool.h:180
FirtoolOptions & setEmitSeparateAlwaysBlocks(bool value)
Definition: Firtool.h:295
bool shouldLowerNoRefTypePortAnnotations() const
Definition: Firtool.h:92
bool shouldExportModuleHierarchy() const
Definition: Firtool.h:120
FirtoolOptions & setPreserveValues(firrtl::PreserveValues::PreserveMode value)
Definition: Firtool.h:175
firrtl::CompanionMode companionMode
Definition: Firtool.h:387
FirtoolOptions & setCkgInputName(StringRef value)
Definition: Firtool.h:326
FirtoolOptions & setStripFirDebugInfo(bool value)
Definition: Firtool.h:351
FirtoolOptions & setOutputAnnotationFilename(StringRef value)
Definition: Firtool.h:275
FirtoolOptions & setEnableAnnotationWarning(bool value)
Definition: Firtool.h:280
FirtoolOptions & setBlackBoxRootPath(StringRef value)
Definition: Firtool.h:245
FirtoolOptions & setDisableAggressiveMergeConnections(bool value)
Definition: Firtool.h:220
FirtoolOptions & setAllowAddingPortsOnPublic(bool value)
Definition: Firtool.h:158
FirtoolOptions & setAddMuxPragmas(bool value)
Definition: Firtool.h:285
seq::ExternalizeClockGateOptions getClockGateOptions() const
Definition: Firtool.h:70
bool shouldEnableDebugInfo() const
Definition: Firtool.h:104
bool shouldEmitSeparateAlwaysBlocks() const
Definition: Firtool.h:126
FirtoolOptions & setDisableOptimization(bool value)
Definition: Firtool.h:190
FirtoolOptions & setEtcDisableRegisterExtraction(bool value)
Definition: Firtool.h:305
StringRef getChiselInterfaceOutputDirectory() const
Definition: Firtool.h:57
FirtoolOptions & setAdvancedLayerSink(bool value)
Definition: Firtool.h:235
FirtoolOptions & setExportModuleHierarchy(bool value)
Definition: Firtool.h:346
@ 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:417
LogicalResult populateExportSplitVerilog(mlir::PassManager &pm, const FirtoolOptions &opt, llvm::StringRef directory)
Definition: Firtool.cpp:399
LogicalResult populateHWToSV(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition: Firtool.cpp:288
LogicalResult populateLowFIRRTLToHW(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition: Firtool.cpp:247
LogicalResult populateExportVerilog(mlir::PassManager &pm, const FirtoolOptions &opt, std::unique_ptr< llvm::raw_ostream > os)
Definition: Firtool.cpp:380
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:742
LogicalResult populateFinalizeIR(mlir::PassManager &pm, const FirtoolOptions &opt)
Definition: Firtool.cpp:409
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