aboutsummaryrefslogtreecommitdiffstats
path: root/ice40/pcf.cc
diff options
context:
space:
mode:
authorDavid Shah <dave@ds0.me>2018-11-26 09:34:28 +0000
committerDavid Shah <dave@ds0.me>2018-11-26 09:34:28 +0000
commitfe2fa0e3ed3cdd67cb0b4d12fc6ad0196bb8dff8 (patch)
tree2f3091b9e08dbb429c9718f915acb57df34c320f /ice40/pcf.cc
parent2c6a2c40e1a7a89430c0fbfb697970f75ea68b4f (diff)
downloadnextpnr-fe2fa0e3ed3cdd67cb0b4d12fc6ad0196bb8dff8.tar.gz
nextpnr-fe2fa0e3ed3cdd67cb0b4d12fc6ad0196bb8dff8.tar.bz2
nextpnr-fe2fa0e3ed3cdd67cb0b4d12fc6ad0196bb8dff8.zip
ice40: Improve PCF error handling
Fixes #147 Signed-off-by: David Shah <dave@ds0.me>
Diffstat (limited to 'ice40/pcf.cc')
-rw-r--r--ice40/pcf.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/ice40/pcf.cc b/ice40/pcf.cc
index af5b3e17..ce453af9 100644
--- a/ice40/pcf.cc
+++ b/ice40/pcf.cc
@@ -33,7 +33,9 @@ bool apply_pcf(Context *ctx, std::string filename, std::istream &in)
if (!in)
log_error("failed to open PCF file\n");
std::string line;
+ int lineno = 0;
while (std::getline(in, line)) {
+ lineno++;
size_t cstart = line.find("#");
if (cstart != std::string::npos)
line = line.substr(0, cstart);
@@ -49,21 +51,25 @@ bool apply_pcf(Context *ctx, std::string filename, std::istream &in)
size_t args_end = 1;
while (args_end < words.size() && words.at(args_end).at(0) == '-')
args_end++;
+ if (args_end >= words.size() - 1)
+ log_error("expected PCF syntax 'set_io cell pin' (on line %d)\n", lineno);
std::string cell = words.at(args_end);
std::string pin = words.at(args_end + 1);
auto fnd_cell = ctx->cells.find(ctx->id(cell));
if (fnd_cell == ctx->cells.end()) {
- log_warning("unmatched pcf constraint %s\n", cell.c_str());
+ log_warning("unmatched constraint '%s' (on line %d)\n", cell.c_str(), lineno);
} 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());
+ log_error("package does not have a pin named '%s' (on line %d)\n", pin.c_str(), lineno);
+ if (fnd_cell->second->attrs.count(ctx->id("BEL")))
+ log_error("duplicate pin constraint on '%s' (on line %d)\n", cell.c_str(), lineno);
fnd_cell->second->attrs[ctx->id("BEL")] = ctx->getBelName(pin_bel).str(ctx);
log_info("constrained '%s' to bel '%s'\n", cell.c_str(),
fnd_cell->second->attrs[ctx->id("BEL")].c_str());
}
} else {
- log_error("unsupported pcf command '%s'\n", cmd.c_str());
+ log_error("unsupported PCF command '%s' (on line %d)\n", cmd.c_str(), lineno);
}
}
ctx->settings.emplace(ctx->id("input/pcf"), filename);