aboutsummaryrefslogtreecommitdiffstats
path: root/ice40/pcf.cc
diff options
context:
space:
mode:
authorSergiusz Bazanski <q3k@q3k.org>2018-06-22 14:29:28 +0100
committerSergiusz Bazanski <q3k@q3k.org>2018-06-22 14:29:28 +0100
commit858acc5c1c0ee4bbdfb8d2012b80cda656ca39db (patch)
tree7cc94b94e40c05c5a7baae61c9d0db4f23a31b60 /ice40/pcf.cc
parent98b1f0c041b01d07f64e8e04503f8eccb05a93de (diff)
parentf86a0d6c8c8792c36c87cf345665ce7c9fbcc60f (diff)
downloadnextpnr-858acc5c1c0ee4bbdfb8d2012b80cda656ca39db.tar.gz
nextpnr-858acc5c1c0ee4bbdfb8d2012b80cda656ca39db.tar.bz2
nextpnr-858acc5c1c0ee4bbdfb8d2012b80cda656ca39db.zip
Merge branch 'master' of gitlab.com:SymbioticEDA/nextpnr into q3k/gl
Diffstat (limited to 'ice40/pcf.cc')
-rw-r--r--ice40/pcf.cc75
1 files changed, 41 insertions, 34 deletions
diff --git a/ice40/pcf.cc b/ice40/pcf.cc
index 756aba4a..87d27ff1 100644
--- a/ice40/pcf.cc
+++ b/ice40/pcf.cc
@@ -27,44 +27,51 @@ NEXTPNR_NAMESPACE_BEGIN
// Read a w
// Apply PCF constraints to a pre-packing design
-void apply_pcf(Context *ctx, std::istream &in)
+bool apply_pcf(Context *ctx, std::istream &in)
{
- if (!in)
- log_error("failed to open PCF file");
- std::string line;
- while (std::getline(in, line)) {
- size_t cstart = line.find("#");
- if (cstart != std::string::npos)
- line = line.substr(0, cstart);
- std::stringstream ss(line);
- std::vector<std::string> words;
- std::string tmp;
- while (ss >> tmp)
- words.push_back(tmp);
- if (words.size() == 0)
- continue;
- std::string cmd = words.at(0);
- if (cmd == "set_io") {
- size_t args_end = 1;
- while (args_end < words.size() && words.at(args_end).at(0) == '-')
- args_end++;
- std::string cell = words.at(args_end);
- std::string pin = words.at(args_end + 1);
- auto fnd_cell = ctx->cells.find(cell);
- if (fnd_cell == ctx->cells.end()) {
- log_warning("unmatched pcf constraint %s\n", cell.c_str());
+ try {
+ if (!in)
+ log_error("failed to open PCF file");
+ std::string line;
+ while (std::getline(in, line)) {
+ size_t cstart = line.find("#");
+ if (cstart != std::string::npos)
+ line = line.substr(0, cstart);
+ std::stringstream ss(line);
+ std::vector<std::string> words;
+ std::string tmp;
+ while (ss >> tmp)
+ words.push_back(tmp);
+ if (words.size() == 0)
+ continue;
+ std::string cmd = words.at(0);
+ if (cmd == "set_io") {
+ size_t args_end = 1;
+ while (args_end < words.size() &&
+ words.at(args_end).at(0) == '-')
+ args_end++;
+ std::string cell = words.at(args_end);
+ std::string pin = words.at(args_end + 1);
+ auto fnd_cell = ctx->cells.find(cell);
+ if (fnd_cell == ctx->cells.end()) {
+ log_warning("unmatched pcf constraint %s\n", cell.c_str());
+ } else {
+ BelId pin_bel = ctx->getPackagePinBel(pin);
+ if (pin_bel == BelId())
+ log_error("package does not have a pin named %s\n",
+ pin.c_str());
+ fnd_cell->second->attrs["BEL"] =
+ ctx->getBelName(pin_bel).str();
+ log_info("constrained '%s' to bel '%s'\n", cell.c_str(),
+ fnd_cell->second->attrs["BEL"].c_str());
+ }
} else {
- BelId pin_bel = ctx->getPackagePinBel(pin);
- if (pin_bel == BelId())
- log_error("package does not have a pin named %s\n",
- pin.c_str());
- fnd_cell->second->attrs["BEL"] = ctx->getBelName(pin_bel).str();
- log_info("constrained '%s' to bel '%s'\n", cell.c_str(),
- fnd_cell->second->attrs["BEL"].c_str());
+ log_error("unsupported pcf command '%s'\n", cmd.c_str());
}
- } else {
- log_error("unsupported pcf command '%s'\n", cmd.c_str());
}
+ return true;
+ } catch (log_execution_error_exception) {
+ return false;
}
}