Merge pull request #904 from yrabbit/diff-locations

gowin: Add a DS location recognition
This commit is contained in:
gatecat 2022-02-04 15:46:59 +00:00 committed by GitHub
commit d13a4f4c7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -671,10 +671,13 @@ static Loc getLoc(std::smatch match, int maxX, int maxY)
void Arch::read_cst(std::istream &in)
{
std::regex iobre = std::regex("IO_LOC +\"([^\"]+)\" +([^ ;]+) *;.*");
// If two locations are specified separated by commas (for differential I/O buffers),
// only the first location is actually recognized and used.
// And pin A will be Positive and pin B will be Negative in any case.
std::regex iobre = std::regex("IO_LOC +\"([^\"]+)\" +([^ ,;]+)(, *[^ ;]+)? *;.*");
std::regex portre = std::regex("IO_PORT +\"([^\"]+)\" +([^;]+;).*");
std::regex port_attrre = std::regex("([^ =;]+=[^ =;]+) *([^;]*;)");
std::regex iobelre = std::regex("IO([TRBL])([0-9]+)([A-Z])");
std::regex iobelre = std::regex("IO([TRBL])([0-9]+)\\[?([A-Z])\\]?");
std::regex inslocre = std::regex("INS_LOC +\"([^\"]+)\" +R([0-9]+)C([0-9]+)\\[([0-9])\\]\\[([AB])\\] *;.*");
std::smatch match, match_attr, match_pinloc;
std::string line, pinline;
@ -718,17 +721,19 @@ void Arch::read_cst(std::istream &in)
if (belname != nullptr) {
std::string bel = IdString(belname->src_id).str(this);
it->second->setAttr(IdString(ID_BEL), bel);
} else if (std::regex_match(pinline, match_pinloc, iobelre)) {
// may be it's IOx#[AB] style?
Loc loc = getLoc(match_pinloc, getGridDimX(), getGridDimY());
BelId bel = getBelByLocation(loc);
if (bel == BelId()) {
log_error("Pin %s not found\n", pinline.c_str());
}
std::string belname = getCtx()->nameOfBel(bel);
it->second->setAttr(IdString(ID_BEL), belname);
} else {
log_error("Pin %s not found\n", pinname.c_str(this));
if (std::regex_match(pinline, match_pinloc, iobelre)) {
// may be it's IOx#[AB] style?
Loc loc = getLoc(match_pinloc, getGridDimX(), getGridDimY());
BelId bel = getBelByLocation(loc);
if (bel == BelId()) {
log_error("Pin %s not found (TRBL style). \n", pinline.c_str());
}
std::string belname = getCtx()->nameOfBel(bel);
it->second->setAttr(IdString(ID_BEL), belname);
} else {
log_error("Pin %s not found (pin# style)\n", pinname.c_str(this));
}
}
} break;
case insloc: { // INS_LOC