43 : ImplicitLocOpBuilder(UnknownLoc::get(top->getContext()), top),
44 a(StringAttr::get(getContext(),
"a")),
45 aValid(StringAttr::get(getContext(),
"a_valid")),
46 aReady(StringAttr::get(getContext(),
"a_ready")),
47 x(StringAttr::get(getContext(),
"x")),
48 xValid(StringAttr::get(getContext(),
"x_valid")),
49 xReady(StringAttr::get(getContext(),
"x_ready")),
50 dataOutValid(StringAttr::get(getContext(),
"DataOutValid")),
51 dataOutReady(StringAttr::get(getContext(),
"DataOutReady")),
52 dataOut(StringAttr::get(getContext(),
"DataOut")),
53 dataInValid(StringAttr::get(getContext(),
"DataInValid")),
54 dataInReady(StringAttr::get(getContext(),
"DataInReady")),
55 dataIn(StringAttr::get(getContext(),
"DataIn")),
56 clk(StringAttr::get(getContext(),
"clk")),
57 rst(StringAttr::get(getContext(),
"rst")),
58 width(StringAttr::get(getContext(),
"WIDTH")),
59 dataDelay(StringAttr::get(getContext(),
"DATA_DELAY")) {
61 auto regions = top->getRegions();
62 if (regions.empty()) {
63 top->emitError(
"ESI HW Builder needs a region to insert HW.");
65 auto ®ion = regions.front();
67 setInsertionPoint(®ion.front(), region.front().begin());
71 StringRef proposedNameRef) {
72 SmallString<64> proposedName = proposedNameRef;
75 for (
char &ch : proposedName) {
83 size_t baseLength = proposedName.size();
85 while (SymbolTable::lookupSymbolIn(tableOp, proposedName)) {
86 proposedName.resize(baseLength);
87 proposedName.append(llvm::utostr(++tries));
90 return StringAttr::get(tableOp->getContext(), proposedName);
95 Attribute dataDelayValue) {
96 auto type = IntegerType::get(
width.getContext(), 32, IntegerType::Unsigned);
97 return ArrayAttr::get(
99 {ParamDeclAttr::get(width.getContext(), width, type, widthValue),
100 ParamDeclAttr::get(width.getContext(), dataDelay, type,
151 SmallVector<Attribute, 8> params;
153 ParamDeclAttr::get(
"ENDPOINT_ID", NoneType::get(getContext())));
155 ParamDeclAttr::get(
"TO_HOST_TYPE_ID", NoneType::get(getContext())));
156 params.push_back(ParamDeclAttr::get(
"TO_HOST_SIZE_BITS", getI32Type()));
158 auto dataInType = hw::IntType::get(hw::ParamDeclRefAttr::get(
159 StringAttr::get(getContext(),
"TO_HOST_SIZE_BITS"),
160 getIntegerType(32,
false)));
170 "Cosim_Endpoint_ToHost", ArrayAttr::get(getContext(), params));
179 SmallVector<Attribute, 8> params;
181 ParamDeclAttr::get(
"ENDPOINT_ID", NoneType::get(getContext())));
183 ParamDeclAttr::get(
"FROM_HOST_TYPE_ID", NoneType::get(getContext())));
184 params.push_back(ParamDeclAttr::get(
"FROM_HOST_SIZE_BITS", getI32Type()));
186 auto dataInType = hw::IntType::get(hw::ParamDeclRefAttr::get(
187 StringAttr::get(getContext(),
"FROM_HOST_SIZE_BITS"),
188 getIntegerType(32,
false)));
198 "Cosim_Endpoint_FromHost", ArrayAttr::get(getContext(), params));