Loading [MathJax]/extensions/tex2jax.js
CIRCT 22.0.0git
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ExportAIGER.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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 file defines the interface for exporting AIGER files.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef CIRCT_CONVERSION_EXPORTAIGER_H
14#define CIRCT_CONVERSION_EXPORTAIGER_H
15
16#include "circt/Support/LLVM.h"
17#include "mlir/IR/Value.h"
18#include "llvm/Support/raw_ostream.h"
19
20namespace mlir {
21class MLIRContext;
22class TimingScope;
23} // namespace mlir
24
25namespace circt {
26namespace hw {
27class HWModuleOp;
28} // namespace hw
29
30namespace aiger {
31
32/// Handler for AIGER export. If it's passed to the exportAIGER function, the
33/// handler will be called for each operand and result of the operation. Clients
34/// are expected to record this information in their use case.
36 ExportAIGERHandler() = default;
37 virtual ~ExportAIGERHandler() = default;
38
39 // Return true if the operand should be added to the output, false
40 // otherwise. If returned false, outputIndex will be invalid for the given
41 // operand. This callback is called for hw::OutputOp operands and unknown
42 // operations.
43 virtual bool operandCallback(mlir::OpOperand &operand, size_t bitPos,
44 size_t outputIndex) {
45 return true;
46 };
47
48 // Return true if the result should be added to the input, false otherwise.
49 // If returned false, inputIndex will be invalid for the given result. This
50 // callback is called for BlockArguments and unknown operation results.
51 virtual bool valueCallback(Value result, size_t bitPos, size_t inputIndex) {
52 return true;
53 };
54
55 // Callback for notifying that an operation has been emitted into AIGER.
56 virtual void notifyEmitted(Operation *op){};
57
58 // Callback for notifying that a clock has been emitted.
59 virtual void notifyClock(Value value){};
60};
61
62/// Options for AIGER export.
64 /// Whether to export in binary format (aig) or ASCII format (aag).
65 /// Default is ASCII format.
66 bool binaryFormat = false;
67
68 /// Whether to include symbol table in the output.
69 /// Default is true.
70 bool includeSymbolTable = true;
71};
72
73/// Export an MLIR module containing AIG dialect operations to AIGER format.
74mlir::LogicalResult exportAIGER(hw::HWModuleOp module, llvm::raw_ostream &os,
75 const ExportAIGEROptions *options = nullptr,
76 ExportAIGERHandler *handler = nullptr);
77
78/// Register the `export-aiger` MLIR translation.
80
81} // namespace aiger
82} // namespace circt
83
84#endif // CIRCT_CONVERSION_EXPORTAIGER_H
mlir::LogicalResult exportAIGER(hw::HWModuleOp module, llvm::raw_ostream &os, const ExportAIGEROptions *options=nullptr, ExportAIGERHandler *handler=nullptr)
Export an MLIR module containing AIG dialect operations to AIGER format.
void registerExportAIGERTranslation()
Register the export-aiger MLIR translation.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition hw.py:1
Handler for AIGER export.
Definition ExportAIGER.h:35
virtual bool valueCallback(Value result, size_t bitPos, size_t inputIndex)
Definition ExportAIGER.h:51
virtual ~ExportAIGERHandler()=default
virtual void notifyClock(Value value)
Definition ExportAIGER.h:59
virtual bool operandCallback(mlir::OpOperand &operand, size_t bitPos, size_t outputIndex)
Definition ExportAIGER.h:43
virtual void notifyEmitted(Operation *op)
Definition ExportAIGER.h:56
Options for AIGER export.
Definition ExportAIGER.h:63
bool includeSymbolTable
Whether to include symbol table in the output.
Definition ExportAIGER.h:70
bool binaryFormat
Whether to export in binary format (aig) or ASCII format (aag).
Definition ExportAIGER.h:66