diff options
author | David Shah <dave@ds0.me> | 2018-11-22 13:42:20 +0000 |
---|---|---|
committer | David Shah <dave@ds0.me> | 2018-11-22 13:42:20 +0000 |
commit | 65a5d0595218e6f26d995abf5133d9ea381f40ea (patch) | |
tree | 4ef42482b7cba0a289b2f32a95490a9ecdb88f2e /ice40 | |
parent | e48c9e73e7bd30ef49fe3386330337b8a8c02054 (diff) | |
download | nextpnr-65a5d0595218e6f26d995abf5133d9ea381f40ea.tar.gz nextpnr-65a5d0595218e6f26d995abf5133d9ea381f40ea.tar.bz2 nextpnr-65a5d0595218e6f26d995abf5133d9ea381f40ea.zip |
python: Fixes to get net wires map working
Signed-off-by: David Shah <dave@ds0.me>
Diffstat (limited to 'ice40')
-rw-r--r-- | ice40/arch_pybindings.h | 26 |
1 files changed, 24 insertions, 2 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 |