mirror of https://github.com/YosysHQ/yosys.git
Change assert to log_assert
This commit is contained in:
parent
720429b1fd
commit
76371d177f
|
@ -17,7 +17,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
#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<T, 1>{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<T, 1>{a});
|
||||
else
|
||||
|
@ -250,7 +249,7 @@ public:
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#ifndef SIM_H
|
||||
#define SIM_H
|
||||
|
||||
#include <cassert>
|
||||
#include <array>
|
||||
|
||||
template<size_t n>
|
||||
|
@ -250,7 +249,7 @@ Signal<n> $shl(Signal<na> const& a, Signal<nb> 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<n> ret = $const<n>(0);
|
||||
if(amount < n){
|
||||
|
@ -267,7 +266,7 @@ Signal<n> $shr(Signal<n> const& a, Signal<nb> 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<n> ret;
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
|
@ -284,7 +283,7 @@ Signal<n> $asr(Signal<n> const& a, Signal<nb> 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<n> ret;
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
|
@ -345,7 +344,7 @@ Signal<n+m> concat(Signal<n> const& a, Signal<m> const& b)
|
|||
template<size_t n, size_t m>
|
||||
Signal<n> $zero_extend(Signal<m> const& a)
|
||||
{
|
||||
assert(n >= m);
|
||||
log_assert(n >= m);
|
||||
Signal<n> ret;
|
||||
std::copy(a.begin(), a.end(), ret.begin());
|
||||
for(size_t i = m; i < n; i++)
|
||||
|
@ -356,7 +355,7 @@ Signal<n> $zero_extend(Signal<m> const& a)
|
|||
template<size_t n, size_t m>
|
||||
Signal<n> $sign_extend(Signal<m> const& a)
|
||||
{
|
||||
assert(n >= m);
|
||||
log_assert(n >= m);
|
||||
Signal<n> ret;
|
||||
std::copy(a.begin(), a.end(), ret.begin());
|
||||
for(size_t i = m; i < n; i++)
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
#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 @@ public:
|
|||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue