diff options
author | gatecat <gatecat@ds0.me> | 2022-02-04 15:46:59 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-04 15:46:59 +0000 |
commit | d13a4f4c7a41b891877f6b1f02f2ecd61a207558 (patch) | |
tree | 9222e46fa0beb47dd7e8102866e9c280f49443a9 | |
parent | 5007cd3603d71f10924bb97acfe42d50d2ebcbd4 (diff) | |
parent | 1152c9f2f816c3d996b76dcf8c9333fb931ca8a8 (diff) | |
download | nextpnr-d13a4f4c7a41b891877f6b1f02f2ecd61a207558.tar.gz nextpnr-d13a4f4c7a41b891877f6b1f02f2ecd61a207558.tar.bz2 nextpnr-d13a4f4c7a41b891877f6b1f02f2ecd61a207558.zip |
Merge pull request #904 from yrabbit/diff-locations
gowin: Add a DS location recognition
-rw-r--r-- | gowin/arch.cc | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/gowin/arch.cc b/gowin/arch.cc index c55d4a71..07938326 100644 --- a/gowin/arch.cc +++ b/gowin/arch.cc @@ -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 |