From f6f009a0b735b2f07a443b2c011b6f319f89ac72 Mon Sep 17 00:00:00 2001 From: Roland Coeurjoly Date: Wed, 12 Jun 2024 09:23:44 +0200 Subject: [PATCH] Change assert to log_assert --- backends/functional/cxx.cc | 9 ++++----- backends/functional/cxx_runtime/sim.h | 11 +++++------ backends/functional/smtlib.cc | 7 +++---- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/backends/functional/cxx.cc b/backends/functional/cxx.cc index 03f33092cdc..b42e20ca718 100644 --- a/backends/functional/cxx.cc +++ b/backends/functional/cxx.cc @@ -17,7 +17,6 @@ * */ -#include #include "kernel/yosys.h" #include "kernel/drivertools.h" #include "kernel/topo_scc.h" @@ -38,7 +37,7 @@ const char *reserved_keywords[] = { "int","long","mutable","namespace","new","noexcept","not","not_eq", "nullptr","operator","or","or_eq","private","protected","public", "reflexpr","register","reinterpret_cast","requires","return","short", - "signed","sizeof","static","static_assert","static_cast","struct", + "signed","sizeof","static","static_log_assert","static_cast","struct", "switch","synchronized","template","this","thread_local","throw", "true","try","typedef","typeid","typename","union","unsigned", "using","virtual","void","volatile","wchar_t","while","xor","xor_eq", @@ -193,11 +192,11 @@ class CxxComputeGraphFactory { public: CxxComputeGraphFactory(CxxComputeGraph &g) : graph(g) {} T slice(T a, int in_width, int offset, int out_width) { - assert(offset + out_width <= in_width); + log_assert(offset + out_width <= in_width); return graph.add(CxxFunction(ID($$slice), out_width, {{ID(offset), offset}}), 0, std::array{a}); } T extend(T a, int in_width, int out_width, bool is_signed) { - assert(in_width < out_width); + log_assert(in_width < out_width); if(is_signed) return graph.add(CxxFunction(ID($sign_extend), out_width, {{ID(WIDTH), out_width}}), 0, std::array{a}); else @@ -250,7 +249,7 @@ class CxxComputeGraphFactory { return graph.add(CxxFunction(ID($$pending), width), 0); } void update_pending(T pending, T node) { - assert(pending.function().name == ID($$pending)); + log_assert(pending.function().name == ID($$pending)); pending.set_function(CxxFunction(ID($$buf), pending.function().width)); pending.append_arg(node); } diff --git a/backends/functional/cxx_runtime/sim.h b/backends/functional/cxx_runtime/sim.h index 1e5a282639c..75d045ccf35 100644 --- a/backends/functional/cxx_runtime/sim.h +++ b/backends/functional/cxx_runtime/sim.h @@ -20,7 +20,6 @@ #ifndef SIM_H #define SIM_H -#include #include template @@ -250,7 +249,7 @@ Signal $shl(Signal const& a, Signal const &b) { if(nb >= sizeof(int) * 8 - 1) for(size_t i = sizeof(int) * 8 - 1; i < nb; i++) - assert(!b[i]); + log_assert(!b[i]); size_t amount = as_int(b); Signal ret = $const(0); if(amount < n){ @@ -267,7 +266,7 @@ Signal $shr(Signal const& a, Signal const &b) { if(nb >= sizeof(int) * 8 - 1) for(size_t i = sizeof(int) * 8 - 1; i < nb; i++) - assert(!b[i]); + log_assert(!b[i]); size_t amount = as_int(b); Signal ret; for (size_t i = 0; i < n; i++) { @@ -284,7 +283,7 @@ Signal $asr(Signal const& a, Signal const &b) { if(nb >= sizeof(int) * 8 - 1) for(size_t i = sizeof(int) * 8 - 1; i < nb; i++) - assert(!b[i]); + log_assert(!b[i]); size_t amount = as_int(b); Signal ret; for (size_t i = 0; i < n; i++) { @@ -345,7 +344,7 @@ Signal concat(Signal const& a, Signal const& b) template Signal $zero_extend(Signal const& a) { - assert(n >= m); + log_assert(n >= m); Signal ret; std::copy(a.begin(), a.end(), ret.begin()); for(size_t i = m; i < n; i++) @@ -356,7 +355,7 @@ Signal $zero_extend(Signal const& a) template Signal $sign_extend(Signal const& a) { - assert(n >= m); + log_assert(n >= m); Signal ret; std::copy(a.begin(), a.end(), ret.begin()); for(size_t i = m; i < n; i++) diff --git a/backends/functional/smtlib.cc b/backends/functional/smtlib.cc index cd11111b9d8..7a283cccf26 100644 --- a/backends/functional/smtlib.cc +++ b/backends/functional/smtlib.cc @@ -17,7 +17,6 @@ * */ -#include #include "kernel/yosys.h" #include "kernel/drivertools.h" #include "kernel/topo_scc.h" @@ -328,11 +327,11 @@ class SmtlibComputeGraphFactory { public: SmtlibComputeGraphFactory(SmtlibModule &mod) : module(mod), graph(mod.compute_graph) {} T slice(T a, int in_width, int offset, int out_width) { - assert(offset + out_width <= in_width); + log_assert(offset + out_width <= in_width); return node(extract(Arg(1), offset, out_width), out_width, {a}); } T extend(T a, int in_width, int out_width, bool is_signed) { - assert(in_width < out_width); + log_assert(in_width < out_width); if(is_signed) return node(SExpr {SExpr {"_", "sign_extend", out_width - in_width}, Arg(1)}, out_width, {a}); else @@ -399,7 +398,7 @@ class SmtlibComputeGraphFactory { return node(SExpr(), width, {}); } void update_pending(T pending, T node) { - assert(pending.function().expr.is_none()); + log_assert(pending.function().expr.is_none()); pending.set_function(Node(Arg(1), pending.function().width)); pending.append_arg(node); }