aboutsummaryrefslogtreecommitdiffstats
path: root/gowin/arch.cc
diff options
context:
space:
mode:
authorgatecat <gatecat@ds0.me>2021-07-10 23:24:38 +0100
committergatecat <gatecat@ds0.me>2021-07-10 23:24:38 +0100
commit8531658019a5d8f7834c6054e10c8438d8006505 (patch)
tree9ed98754646aeea1c7c2cae749c7f3f20f57fc40 /gowin/arch.cc
parentd290766101a62d575c3e6aacbecde46ecab349f6 (diff)
parent478456e6e98c05ee5f810de0c0206daee25482f3 (diff)
downloadnextpnr-8531658019a5d8f7834c6054e10c8438d8006505.tar.gz
nextpnr-8531658019a5d8f7834c6054e10c8438d8006505.tar.bz2
nextpnr-8531658019a5d8f7834c6054e10c8438d8006505.zip
Merge branch 'master' of github.com:YosysHQ/nextpnr
Diffstat (limited to 'gowin/arch.cc')
-rw-r--r--gowin/arch.cc40
1 files changed, 24 insertions, 16 deletions
diff --git a/gowin/arch.cc b/gowin/arch.cc
index e8a14522..e4dce329 100644
--- a/gowin/arch.cc
+++ b/gowin/arch.cc
@@ -18,6 +18,7 @@
*
*/
+#include <boost/algorithm/string.hpp>
#include <iostream>
#include <math.h>
#include <regex>
@@ -483,37 +484,44 @@ DelayQuad Arch::getWireTypeDelay(IdString wire)
void Arch::read_cst(std::istream &in)
{
- std::regex iobre = std::regex("IO_LOC +\"([^\"]+)\" +([^ ;]+);");
+ std::regex iobre = std::regex("IO_LOC +\"([^\"]+)\" +([^ ;]+) *;.*");
+ std::regex portre = std::regex("IO_PORT +\"([^\"]+)\" +([^ =;]+=[^ =;]+) *;.*");
std::smatch match;
std::string line;
+ bool io_loc;
while (!in.eof()) {
std::getline(in, line);
+ io_loc = true;
if (!std::regex_match(line, match, iobre)) {
- // empty line or comment
- if (line.empty() || line.rfind("//", 0) == 0) {
- continue;
+ if (std::regex_match(line, match, portre)) {
+ io_loc = false;
} else {
- log_warning("Invalid constraint: %s\n", line.c_str());
+ if ((!line.empty()) && (line.rfind("//", 0) == std::string::npos)) {
+ log_warning("Invalid constraint: %s\n", line.c_str());
+ }
continue;
}
}
- // std::cout << match[1] << " " << match[2] << std::endl;
+
IdString net = id(match[1]);
- IdString pinname = id(match[2]);
- const PairPOD *belname = pairLookup(package->pins.get(), package->num_pins, pinname.index);
- if (belname == nullptr)
- log_error("Pin %s not found\n", pinname.c_str(this));
- // BelId bel = getBelByName(belname->src_id);
- // for (auto cell : sorted(cells)) {
- // std::cout << cell.first.str(this) << std::endl;
- // }
auto it = cells.find(net);
if (it == cells.end()) {
log_info("Cell %s not found\n", net.c_str(this));
continue;
}
- std::string bel = IdString(belname->src_id).str(this);
- it->second->attrs[IdString(ID_BEL)] = bel;
+ if (io_loc) { // IO_LOC name pin
+ IdString pinname = id(match[2]);
+ const PairPOD *belname = pairLookup(package->pins.get(), package->num_pins, pinname.index);
+ if (belname == nullptr)
+ log_error("Pin %s not found\n", pinname.c_str(this));
+ std::string bel = IdString(belname->src_id).str(this);
+ it->second->attrs[IdString(ID_BEL)] = bel;
+ } else { // IO_PORT attr=value
+ std::string attr = "&";
+ attr += match[2];
+ boost::algorithm::to_upper(attr);
+ it->second->attrs[id(attr)] = 1;
+ }
}
}