15#include "mlir/IR/BuiltinTypes.h"
16#include "mlir/IR/ImplicitLocOpBuilder.h"
26 StringRef reqName, Type reqType,
27 StringRef respName, Type respType) {
28 assert(reqType && respType);
29 auto *ctxt = reqType ? reqType.getContext() : respType.getContext();
30 auto bundle = ChannelBundleType::get(
32 {
BundledChannel{StringAttr::get(ctxt, reqName), ChannelDirection::from,
33 ChannelType::get(ctxt, reqType)},
34 BundledChannel{StringAttr::get(ctxt, respName), ChannelDirection::to,
35 ChannelType::get(ctxt, respType)}},
37 return {hw::InnerRefAttr::get(sym, StringAttr::get(ctxt, name)), bundle};
41 auto *
ctxt = getContext();
42 auto addressType = IntegerType::get(ctxt, llvm::Log2_64_Ceil(getDepth()));
45 hw::StructType writeType = hw::StructType::get(
47 {hw::StructType::FieldInfo{StringAttr::get(ctxt,
"address"), addressType},
48 hw::StructType::FieldInfo{StringAttr::get(ctxt,
"data"),
50 return createReqResp(getSymNameAttr(),
"write",
"req", writeType,
"ack",
51 IntegerType::get(ctxt, 0));
55 auto *
ctxt = getContext();
56 auto addressType = IntegerType::get(ctxt, llvm::Log2_64_Ceil(getDepth()));
58 return createReqResp(getSymNameAttr(),
"read",
"address", addressType,
"data",
62void RandomAccessMemoryDeclOp::getPortList(
63 SmallVectorImpl<ServicePortInfo> &ports) {
64 ports.push_back(writePortInfo());
65 ports.push_back(readPortInfo());
68void CallServiceDeclOp::getPortList(SmallVectorImpl<ServicePortInfo> &ports) {
69 auto *
ctxt = getContext();
71 hw::InnerRefAttr::get(getSymNameAttr(), StringAttr::get(ctxt,
"call")),
72 ChannelBundleType::get(
74 {
BundledChannel{StringAttr::get(ctxt,
"arg"), ChannelDirection::from,
75 ChannelType::get(ctxt, AnyType::get(ctxt))},
76 BundledChannel{StringAttr::get(ctxt,
"result"), ChannelDirection::to,
77 ChannelType::get(ctxt, AnyType::get(ctxt))}},
81void FuncServiceDeclOp::getPortList(SmallVectorImpl<ServicePortInfo> &ports) {
82 auto *
ctxt = getContext();
84 hw::InnerRefAttr::get(getSymNameAttr(), StringAttr::get(ctxt,
"call")),
85 ChannelBundleType::get(
87 {
BundledChannel{StringAttr::get(ctxt,
"arg"), ChannelDirection::to,
88 ChannelType::get(ctxt, AnyType::get(ctxt))},
90 ChannelDirection::from,
91 ChannelType::get(ctxt, AnyType::get(ctxt))}},
95void MMIOServiceDeclOp::getPortList(SmallVectorImpl<ServicePortInfo> &ports) {
96 auto *
ctxt = getContext();
99 hw::InnerRefAttr::get(getSymNameAttr(), StringAttr::get(ctxt,
"read")),
100 ChannelBundleType::get(
103 StringAttr::get(ctxt,
"offset"), ChannelDirection::to,
107 ctxt, 32, IntegerType::SignednessSemantics::Unsigned))},
108 BundledChannel{StringAttr::get(ctxt,
"data"), ChannelDirection::from,
109 ChannelType::get(ctxt, IntegerType::get(ctxt, 64))}},
112 auto cmdType = hw::StructType::get(
114 hw::StructType::FieldInfo{StringAttr::get(ctxt,
"write"),
115 IntegerType::get(ctxt, 1)},
116 hw::StructType::FieldInfo{
117 StringAttr::get(ctxt,
"offset"),
119 ctxt, 32, IntegerType::SignednessSemantics::Unsigned)},
120 hw::StructType::FieldInfo{StringAttr::get(ctxt,
"data"),
121 IntegerType::get(ctxt, 64)},
124 hw::InnerRefAttr::get(getSymNameAttr(),
125 StringAttr::get(ctxt,
"read_write")),
126 ChannelBundleType::get(
128 {
BundledChannel{StringAttr::get(ctxt,
"cmd"), ChannelDirection::to,
129 ChannelType::get(ctxt, cmdType)},
130 BundledChannel{StringAttr::get(ctxt,
"data"), ChannelDirection::from,
131 ChannelType::get(ctxt, IntegerType::get(ctxt, 64))}},
136 auto *
ctxt = getContext();
138 IntegerType::get(ctxt, 64, IntegerType::SignednessSemantics::Unsigned);
141 hw::StructType writeType = hw::StructType::get(
143 {hw::StructType::FieldInfo{StringAttr::get(ctxt,
"address"), addressType},
144 hw::StructType::FieldInfo{
145 StringAttr::get(ctxt,
"tag"),
146 IntegerType::get(ctxt, 8,
147 IntegerType::SignednessSemantics::Unsigned)},
148 hw::StructType::FieldInfo{StringAttr::get(ctxt,
"data"),
149 AnyType::get(ctxt)}});
151 getSymNameAttr(),
"write",
"req", writeType,
"ackTag",
152 IntegerType::get(ctxt, 8, IntegerType::SignednessSemantics::Unsigned));
156 auto *
ctxt = getContext();
158 IntegerType::get(ctxt, 64, IntegerType::SignednessSemantics::Unsigned);
160 hw::StructType readReqType = hw::StructType::get(
162 hw::StructType::FieldInfo{StringAttr::get(ctxt,
"address"),
164 hw::StructType::FieldInfo{
165 StringAttr::get(ctxt,
"tag"),
167 ctxt, 8, IntegerType::SignednessSemantics::Unsigned)},
169 hw::StructType readRespType = hw::StructType::get(
171 hw::StructType::FieldInfo{
172 StringAttr::get(ctxt,
"tag"),
174 ctxt, 8, IntegerType::SignednessSemantics::Unsigned)},
175 hw::StructType::FieldInfo{StringAttr::get(ctxt,
"data"),
178 return createReqResp(getSymNameAttr(),
"read",
"req", readReqType,
"resp",
182void HostMemServiceDeclOp::getPortList(
183 SmallVectorImpl<ServicePortInfo> &ports) {
184 ports.push_back(writePortInfo());
185 ports.push_back(readPortInfo());
assert(baseType &&"element must be base type")
static ServicePortInfo createReqResp(StringAttr sym, Twine name, StringRef reqName, Type reqType, StringRef respName, Type respType)
Utility function to create a req/resp pair bundle service port.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Describes a service port.