Skip to content

Commit

Permalink
sim.h cannot use log_assert because does not include yosys headers
Browse files Browse the repository at this point in the history
  • Loading branch information
RCoeurjoly committed Jun 12, 2024
1 parent ef20f53 commit d283a3f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions backends/functional/cxx_runtime/sim.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define SIM_H

#include <array>
#include <cassert>

template<size_t n>
using Signal = std::array<bool, n>;
Expand Down Expand Up @@ -249,7 +250,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++)
log_assert(!b[i]);
assert(!b[i]);
size_t amount = as_int(b);
Signal<n> ret = $const<n>(0);
if(amount < n){
Expand All @@ -266,7 +267,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++)
log_assert(!b[i]);
assert(!b[i]);
size_t amount = as_int(b);
Signal<n> ret;
for (size_t i = 0; i < n; i++) {
Expand All @@ -283,7 +284,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++)
log_assert(!b[i]);
assert(!b[i]);
size_t amount = as_int(b);
Signal<n> ret;
for (size_t i = 0; i < n; i++) {
Expand Down Expand Up @@ -344,7 +345,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)
{
log_assert(n >= m);
assert(n >= m);
Signal<n> ret;
std::copy(a.begin(), a.end(), ret.begin());
for(size_t i = m; i < n; i++)
Expand All @@ -355,7 +356,7 @@ Signal<n> $zero_extend(Signal<m> const& a)
template<size_t n, size_t m>
Signal<n> $sign_extend(Signal<m> const& a)
{
log_assert(n >= m);
assert(n >= m);
Signal<n> ret;
std::copy(a.begin(), a.end(), ret.begin());
for(size_t i = m; i < n; i++)
Expand Down

0 comments on commit d283a3f

Please sign in to comment.