aboutsummaryrefslogtreecommitdiffstats
path: root/ice40
diff options
context:
space:
mode:
authorDavid Shah <dave@ds0.me>2018-12-06 11:19:48 +0000
committerDavid Shah <dave@ds0.me>2018-12-06 11:19:48 +0000
commite7fc42ac84d70b2ac09f4e0f8666504f75de89e2 (patch)
treef041592d187e7afcc31c3b6712669a7a47273087 /ice40
parent88e1e6bdf4d01d31389fce92cdc88e16c9a5ebc1 (diff)
downloadnextpnr-e7fc42ac84d70b2ac09f4e0f8666504f75de89e2.tar.gz
nextpnr-e7fc42ac84d70b2ac09f4e0f8666504f75de89e2.tar.bz2
nextpnr-e7fc42ac84d70b2ac09f4e0f8666504f75de89e2.zip
ice40: Improve bitstream error handling
Fixes #161 and provides a clearer error for #170 Signed-off-by: David Shah <dave@ds0.me>
Diffstat (limited to 'ice40')
-rw-r--r--ice40/bitstream.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/ice40/bitstream.cc b/ice40/bitstream.cc
index 83664169..d1f51676 100644
--- a/ice40/bitstream.cc
+++ b/ice40/bitstream.cc
@@ -156,7 +156,9 @@ void configure_extra_cell(chipconfig_t &config, const Context *ctx, CellInfo *ce
// Lattice's weird string style params, not sure if
// prefixes other than 0b should be supported, only 0b features in docs
std::string raw = get_param_str_or_def(cell, ctx->id(p.first), "0b0");
- assert(raw.substr(0, 2) == "0b");
+ if (raw.substr(0, 2) != "0b")
+ log_error("expected configuration string starting with '0b' for parameter '%s' on cell '%s'\n",
+ p.first.c_str(), cell->name.c_str(ctx));
raw = raw.substr(2);
value.resize(raw.length());
for (int i = 0; i < (int)raw.length(); i++) {
@@ -168,7 +170,13 @@ void configure_extra_cell(chipconfig_t &config, const Context *ctx, CellInfo *ce
}
}
} else {
- int ival = get_param_or_def(cell, ctx->id(p.first), 0);
+ int ival;
+ try {
+ ival = get_param_or_def(cell, ctx->id(p.first), 0);
+ } catch (std::invalid_argument &e) {
+ log_error("expected numeric value for parameter '%s' on cell '%s'\n", p.first.c_str(),
+ cell->name.c_str(ctx));
+ }
for (int i = 0; i < p.second; i++)
value.push_back((ival >> i) & 0x1);