1
0
mirror of https://github.com/YosysHQ/nextpnr.git synced 2026-01-11 23:53:21 +00:00

himbaechel/uarch/gowin/cst.cc: added support for IO_LOC with _p/_n separated by a comma (#1571)

This commit is contained in:
Gwenhael Goavec-Merou 2025-10-08 14:26:50 +02:00 committed by GitHub
parent 5d45520bb2
commit 4b00f58af5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -96,7 +96,7 @@ struct GowinCstReader
std::regex("INS_LOC +\"([^\"]+)\" +(TOP|RIGHT|BOTTOM|LEFT)SIDE\\[([0,1])\\] *;*[\\s\\S]*"); std::regex("INS_LOC +\"([^\"]+)\" +(TOP|RIGHT|BOTTOM|LEFT)SIDE\\[([0,1])\\] *;*[\\s\\S]*");
std::regex clockre = std::regex("CLOCK_LOC +\"([^\"]+)\" +BUF([GS])(\\[([0-7])\\])?[^;]*;.*[\\s\\S]*"); std::regex clockre = std::regex("CLOCK_LOC +\"([^\"]+)\" +BUF([GS])(\\[([0-7])\\])?[^;]*;.*[\\s\\S]*");
std::smatch match, match_attr, match_pinloc; std::smatch match, match_attr, match_pinloc;
std::string line, pinline; std::string line, pinlines[2];
std::vector<IdStringList> constrained_clkdivs; std::vector<IdStringList> constrained_clkdivs;
enum enum
{ {
@ -171,27 +171,53 @@ struct GowinCstReader
} }
} break; } break;
case ioloc: { // IO_LOC name pin case ioloc: { // IO_LOC name pin
IdString pinname = ctx->id(match[2]); int nb_iter = 1;
pinline = match[2]; IdString nets[2];
const PadInfoPOD *belname = // Prepare pinlines and nets (default: one Pin, one LOC).
pinLookup(ctx->package_info->pads.get(), ctx->package_info->pads.ssize(), pinname); pinlines[0] = match[2];
if (belname != nullptr) { nets[0] = ctx->id(match[1]);
IdStringList bel = IdStringList::concat(IdString(belname->tile), IdString(belname->bel));
it->second->setAttr(IdString(ID_BEL), bel.str(ctx)); // Differential case: one Pin (_p), two LOCs separated by a ','
debug_cell(it->second->name, bel); if (match[3].length() > 0) {
} else { nb_iter++;
if (std::regex_match(pinline, match_pinloc, iobelre)) { // Uses second pin after removing ','
// may be it's IOx#[AB] style? pinlines[1] = std::regex_replace(match[3].str(), std::regex("^,"), "");
Loc loc = getLoc(match_pinloc, ctx->getGridDimX(), ctx->getGridDimY());
BelId bel = ctx->getBelByLocation(loc); // Replaces _p with _n in pinname.
if (bel == BelId()) { std::string tmp = std::regex_replace(match[1].str(), std::regex("_p$"), "_n");
log_error("Pin %s not found (TRBL style). \n", pinline.c_str());
} nets[1] = ctx->id(tmp);
it->second->setAttr(IdString(ID_BEL), std::string(ctx->nameOfBel(bel))); it = ctx->cells.find(nets[1]);
debug_cell(it->second->name, ctx->getBelName(bel)); if (cst_type != clock && it == ctx->cells.end()) {
log_info("Cell %s not found\n", nets[1].c_str(ctx));
continue;
}
}
for (int iter = 0; iter < nb_iter; iter++) {
IdString pinname = ctx->id(pinlines[iter]);
auto it = ctx->cells.find(nets[iter]);
const PadInfoPOD *belname =
pinLookup(ctx->package_info->pads.get(), ctx->package_info->pads.ssize(), pinname);
if (belname != nullptr) {
IdStringList bel = IdStringList::concat(IdString(belname->tile), IdString(belname->bel));
it->second->setAttr(IdString(ID_BEL), bel.str(ctx));
debug_cell(it->second->name, bel);
} else { } else {
log_error("Pin %s not found (pin# style)\n", pinname.c_str(ctx)); if (std::regex_match(pinlines[iter], match_pinloc, iobelre)) {
// may be it's IOx#[AB] style?
Loc loc = getLoc(match_pinloc, ctx->getGridDimX(), ctx->getGridDimY());
BelId bel = ctx->getBelByLocation(loc);
if (bel == BelId()) {
log_error("Pin %s not found (TRBL style). \n", pinlines[iter].c_str());
}
it->second->setAttr(IdString(ID_BEL), std::string(ctx->nameOfBel(bel)));
debug_cell(it->second->name, ctx->getBelName(bel));
} else {
log_error("Pin %s not found (pin# style)\n", pinname.c_str(ctx));
}
} }
} }
} break; } break;