aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Shah <davey1576@gmail.com>2018-07-04 13:04:31 +0200
committerDavid Shah <davey1576@gmail.com>2018-07-04 13:04:31 +0200
commit2e8c0c872f99276602f9cd0daf06bfaf11832a08 (patch)
tree84badae08d0cc8593374560717dcfe8c1ff722a2
parent6eaae6196cca762ed4e46f6f4011000e07e6577b (diff)
downloadnextpnr-2e8c0c872f99276602f9cd0daf06bfaf11832a08.tar.gz
nextpnr-2e8c0c872f99276602f9cd0daf06bfaf11832a08.tar.bz2
nextpnr-2e8c0c872f99276602f9cd0daf06bfaf11832a08.zip
Add NPNR_ASSERT_FALSE, use in bitstream.cc
Signed-off-by: David Shah <davey1576@gmail.com>
-rw-r--r--common/nextpnr.h9
-rw-r--r--ice40/bitstream.cc4
2 files changed, 10 insertions, 3 deletions
diff --git a/common/nextpnr.h b/common/nextpnr.h
index 9d46b654..6a45875b 100644
--- a/common/nextpnr.h
+++ b/common/nextpnr.h
@@ -44,7 +44,7 @@
#if defined(__GNUC__) || defined(__clang__)
#define NPNR_ATTRIBUTE(...) __attribute__((__VA_ARGS__))
-#define NPNR_NORETURN
+#define NPNR_NORETURN __attribute__((noreturn))
#define NPNR_DEPRECATED __attribute__((deprecated))
#define NPNR_PACKED_STRUCT(...) __VA_ARGS__ __attribute__((packed))
#elif defined(_MSC_VER)
@@ -78,8 +78,15 @@ inline void except_assert_impl(bool expr, std::string message, std::string expr_
throw assertion_failure(message, expr_str, filename, line);
}
+NPNR_NORETURN
+inline void assert_false_impl(std::string message, std::string filename, int line)
+{
+ throw assertion_failure(message, "false", filename, line);
+}
+
#define NPNR_ASSERT(cond) except_assert_impl((cond), #cond, #cond, __FILE__, __LINE__)
#define NPNR_ASSERT_MSG(cond, msg) except_assert_impl((cond), msg, #cond, __FILE__, __LINE__)
+#define NPNR_ASSERT_FALSE(msg) assert_false_impl(msg, __FILE__, __LINE__)
struct BaseCtx;
struct Context;
diff --git a/ice40/bitstream.cc b/ice40/bitstream.cc
index 33c4d97b..98a7a0e4 100644
--- a/ice40/bitstream.cc
+++ b/ice40/bitstream.cc
@@ -36,7 +36,7 @@ const ConfigEntryPOD &find_config(const TileInfoPOD &tile, const std::string &na
return tile.entries[i];
}
}
- NPNR_ASSERT(false);
+ NPNR_ASSERT_FALSE("unable to find config bit " + name);
}
std::tuple<int8_t, int8_t, int8_t> get_ieren(const BitstreamInfoPOD &bi, int8_t x, int8_t y, int8_t z)
@@ -124,7 +124,7 @@ void write_asc(const Context *ctx, std::ostream &out)
out << ".device 5k" << std::endl;
break;
default:
- NPNR_ASSERT(false);
+ NPNR_ASSERT_FALSE("unsupported device type");
}
// Set pips
for (auto pip : ctx->getPips()) {