Skip to content

Commit f6f009a

Browse files
committed
Change assert to log_assert
1 parent c7f665e commit f6f009a

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

backends/functional/cxx.cc

+4-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*
1818
*/
1919

20-
#include <cassert>
2120
#include "kernel/yosys.h"
2221
#include "kernel/drivertools.h"
2322
#include "kernel/topo_scc.h"
@@ -38,7 +37,7 @@ const char *reserved_keywords[] = {
3837
"int","long","mutable","namespace","new","noexcept","not","not_eq",
3938
"nullptr","operator","or","or_eq","private","protected","public",
4039
"reflexpr","register","reinterpret_cast","requires","return","short",
41-
"signed","sizeof","static","static_assert","static_cast","struct",
40+
"signed","sizeof","static","static_log_assert","static_cast","struct",
4241
"switch","synchronized","template","this","thread_local","throw",
4342
"true","try","typedef","typeid","typename","union","unsigned",
4443
"using","virtual","void","volatile","wchar_t","while","xor","xor_eq",
@@ -193,11 +192,11 @@ class CxxComputeGraphFactory {
193192
public:
194193
CxxComputeGraphFactory(CxxComputeGraph &g) : graph(g) {}
195194
T slice(T a, int in_width, int offset, int out_width) {
196-
assert(offset + out_width <= in_width);
195+
log_assert(offset + out_width <= in_width);
197196
return graph.add(CxxFunction(ID($$slice), out_width, {{ID(offset), offset}}), 0, std::array<T, 1>{a});
198197
}
199198
T extend(T a, int in_width, int out_width, bool is_signed) {
200-
assert(in_width < out_width);
199+
log_assert(in_width < out_width);
201200
if(is_signed)
202201
return graph.add(CxxFunction(ID($sign_extend), out_width, {{ID(WIDTH), out_width}}), 0, std::array<T, 1>{a});
203202
else
@@ -250,7 +249,7 @@ class CxxComputeGraphFactory {
250249
return graph.add(CxxFunction(ID($$pending), width), 0);
251250
}
252251
void update_pending(T pending, T node) {
253-
assert(pending.function().name == ID($$pending));
252+
log_assert(pending.function().name == ID($$pending));
254253
pending.set_function(CxxFunction(ID($$buf), pending.function().width));
255254
pending.append_arg(node);
256255
}

backends/functional/cxx_runtime/sim.h

+5-6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#ifndef SIM_H
2121
#define SIM_H
2222

23-
#include <cassert>
2423
#include <array>
2524

2625
template<size_t n>
@@ -250,7 +249,7 @@ Signal<n> $shl(Signal<na> const& a, Signal<nb> const &b)
250249
{
251250
if(nb >= sizeof(int) * 8 - 1)
252251
for(size_t i = sizeof(int) * 8 - 1; i < nb; i++)
253-
assert(!b[i]);
252+
log_assert(!b[i]);
254253
size_t amount = as_int(b);
255254
Signal<n> ret = $const<n>(0);
256255
if(amount < n){
@@ -267,7 +266,7 @@ Signal<n> $shr(Signal<n> const& a, Signal<nb> const &b)
267266
{
268267
if(nb >= sizeof(int) * 8 - 1)
269268
for(size_t i = sizeof(int) * 8 - 1; i < nb; i++)
270-
assert(!b[i]);
269+
log_assert(!b[i]);
271270
size_t amount = as_int(b);
272271
Signal<n> ret;
273272
for (size_t i = 0; i < n; i++) {
@@ -284,7 +283,7 @@ Signal<n> $asr(Signal<n> const& a, Signal<nb> const &b)
284283
{
285284
if(nb >= sizeof(int) * 8 - 1)
286285
for(size_t i = sizeof(int) * 8 - 1; i < nb; i++)
287-
assert(!b[i]);
286+
log_assert(!b[i]);
288287
size_t amount = as_int(b);
289288
Signal<n> ret;
290289
for (size_t i = 0; i < n; i++) {
@@ -345,7 +344,7 @@ Signal<n+m> concat(Signal<n> const& a, Signal<m> const& b)
345344
template<size_t n, size_t m>
346345
Signal<n> $zero_extend(Signal<m> const& a)
347346
{
348-
assert(n >= m);
347+
log_assert(n >= m);
349348
Signal<n> ret;
350349
std::copy(a.begin(), a.end(), ret.begin());
351350
for(size_t i = m; i < n; i++)
@@ -356,7 +355,7 @@ Signal<n> $zero_extend(Signal<m> const& a)
356355
template<size_t n, size_t m>
357356
Signal<n> $sign_extend(Signal<m> const& a)
358357
{
359-
assert(n >= m);
358+
log_assert(n >= m);
360359
Signal<n> ret;
361360
std::copy(a.begin(), a.end(), ret.begin());
362361
for(size_t i = m; i < n; i++)

backends/functional/smtlib.cc

+3-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*
1818
*/
1919

20-
#include <cassert>
2120
#include "kernel/yosys.h"
2221
#include "kernel/drivertools.h"
2322
#include "kernel/topo_scc.h"
@@ -328,11 +327,11 @@ class SmtlibComputeGraphFactory {
328327
public:
329328
SmtlibComputeGraphFactory(SmtlibModule &mod) : module(mod), graph(mod.compute_graph) {}
330329
T slice(T a, int in_width, int offset, int out_width) {
331-
assert(offset + out_width <= in_width);
330+
log_assert(offset + out_width <= in_width);
332331
return node(extract(Arg(1), offset, out_width), out_width, {a});
333332
}
334333
T extend(T a, int in_width, int out_width, bool is_signed) {
335-
assert(in_width < out_width);
334+
log_assert(in_width < out_width);
336335
if(is_signed)
337336
return node(SExpr {SExpr {"_", "sign_extend", out_width - in_width}, Arg(1)}, out_width, {a});
338337
else
@@ -399,7 +398,7 @@ class SmtlibComputeGraphFactory {
399398
return node(SExpr(), width, {});
400399
}
401400
void update_pending(T pending, T node) {
402-
assert(pending.function().expr.is_none());
401+
log_assert(pending.function().expr.is_none());
403402
pending.set_function(Node(Arg(1), pending.function().width));
404403
pending.append_arg(node);
405404
}

0 commit comments

Comments
 (0)