From 65a5d0595218e6f26d995abf5133d9ea381f40ea Mon Sep 17 00:00:00 2001 From: David Shah Date: Thu, 22 Nov 2018 13:42:20 +0000 Subject: python: Fixes to get net wires map working Signed-off-by: David Shah --- ecp5/arch_pybindings.h | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'ecp5/arch_pybindings.h') diff --git a/ecp5/arch_pybindings.h b/ecp5/arch_pybindings.h index f18b5ff1..9bd7bcdf 100644 --- a/ecp5/arch_pybindings.h +++ b/ecp5/arch_pybindings.h @@ -44,14 +44,36 @@ template <> struct string_converter { 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 +{ + 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 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 -- cgit v1.2.3