17 #include "mlir/IR/PatternMatch.h"
23 ComponentOp component,
size_t width,
25 OpBuilder::InsertionGuard guard(builder);
26 builder.setInsertionPointToStart(component.getBodyBlock());
27 return builder.create<RegisterOp>(loc, (prefix +
"_reg").str(),
width);
31 ComponentOp component,
size_t width,
33 OpBuilder::InsertionGuard g(builder);
34 builder.setInsertionPointToStart(component.getBodyBlock());
36 loc, APInt(
width, value,
false));
40 ComponentOp component,
41 SmallVectorImpl<Type> &resultTypes,
42 StringRef instanceName,
43 StringRef componentName) {
44 OpBuilder::InsertionGuard g(builder);
45 builder.setInsertionPointToStart(component.getBodyBlock());
46 return builder.create<InstanceOp>(loc, resultTypes, instanceName,
51 SmallVector<StringRef, 2> strVet = {callOp.getCallee(),
"instance"};
52 return llvm::join(strVet,
"_");
63 SmallVectorImpl<calyx::PortInfo> &ports) {
64 MLIRContext *ctx = rewriter.getContext();
66 rewriter.getStringAttr(
clkPort),
78 rewriter.getStringAttr(
goPort),
92 return std::max(llvm::Log2_64_Ceil(dim), 1U);
Direction get(bool isOutput)
Returns an output direction if isOutput is true, otherwise returns an input direction.
static constexpr std::string_view clkPort
void addMandatoryComponentPorts(PatternRewriter &rewriter, SmallVectorImpl< calyx::PortInfo > &ports)
static constexpr std::string_view donePort
bool isControlLeafNode(Operation *op)
static constexpr std::string_view resetPort
unsigned handleZeroWidth(int64_t dim)
hw::ConstantOp createConstant(Location loc, OpBuilder &builder, ComponentOp component, size_t width, size_t value)
A helper function to create constants in the HW dialect.
DictionaryAttr getMandatoryPortAttr(MLIRContext *ctx, StringRef name)
calyx::RegisterOp createRegister(Location loc, OpBuilder &builder, ComponentOp component, size_t width, Twine prefix)
Creates a RegisterOp, with input and output port bit widths defined by width.
calyx::InstanceOp createInstance(Location loc, OpBuilder &builder, ComponentOp component, SmallVectorImpl< Type > &resultTypes, StringRef instanceName, StringRef componentName)
A helper function to create calyx.instance operation.
static constexpr std::string_view goPort
std::string getInstanceName(mlir::func::CallOp callOp)
A helper function to get the instance name.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.