diff options
Diffstat (limited to 'ice40')
-rw-r--r-- | ice40/arch_pybindings.h | 26 | ||||
-rw-r--r-- | ice40/pack.cc | 2 | ||||
-rw-r--r-- | ice40/pcf.cc | 12 |
3 files changed, 35 insertions, 5 deletions
diff --git a/ice40/arch_pybindings.h b/ice40/arch_pybindings.h index 070c2396..eaf3ac97 100644 --- a/ice40/arch_pybindings.h +++ b/ice40/arch_pybindings.h @@ -45,14 +45,36 @@ template <> struct string_converter<WireId> { WireId from_str(Context *ctx, std::string name) { return ctx->getWireByName(ctx->id(name)); } - std::string to_str(Context *ctx, WireId id) { return ctx->getWireName(id).str(ctx); } + std::string to_str(Context *ctx, WireId id) + { + if (id == WireId()) + throw bad_wrap(); + return ctx->getWireName(id).str(ctx); + } +}; + +template <> struct string_converter<const WireId> +{ + WireId from_str(Context *ctx, std::string name) { return ctx->getWireByName(ctx->id(name)); } + + std::string to_str(Context *ctx, WireId id) + { + if (id == WireId()) + throw bad_wrap(); + return ctx->getWireName(id).str(ctx); + } }; template <> struct string_converter<PipId> { PipId from_str(Context *ctx, std::string name) { return ctx->getPipByName(ctx->id(name)); } - std::string to_str(Context *ctx, PipId id) { return ctx->getPipName(id).str(ctx); } + std::string to_str(Context *ctx, PipId id) + { + if (id == PipId()) + throw bad_wrap(); + return ctx->getPipName(id).str(ctx); + } }; } // namespace PythonConversion diff --git a/ice40/pack.cc b/ice40/pack.cc index 34d671cf..682baadd 100644 --- a/ice40/pack.cc +++ b/ice40/pack.cc @@ -987,6 +987,8 @@ static void pack_special(Context *ctx) for (auto user : pad_packagepin_net->users) { user.cell->ports.erase(user.port); } + if (pad_packagepin_net->driver.cell != nullptr) + pad_packagepin_net->driver.cell->ports.erase(pad_packagepin_net->driver.port); ctx->nets.erase(pad_packagepin_net->name); pad_packagepin_net = nullptr; } 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); |