Skip to content

Commit

Permalink
Call export_bytes in Data::two_comp_mod operator
Browse files Browse the repository at this point in the history
Fixes #476
  • Loading branch information
antoninbas committed Jan 2, 2018
1 parent 6a1fb0c commit 9e4a70e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion include/bm/bm_sim/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,8 @@ class Data {

//! NC
void two_comp_mod(const Data &src, const Data &width) {
static Bignum one(1);
// used to implement (int<?>) casts in P4_16
static const Bignum one(1);
unsigned int uwidth = width.get_uint();
Bignum mask = (one << uwidth) - 1;
Bignum max = (one << (uwidth - 1)) - 1;
Expand All @@ -327,6 +328,7 @@ class Data {
} else {
value = src.value;
}
export_bytes();
}

//! NC
Expand Down
2 changes: 1 addition & 1 deletion tests/test_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ namespace {
void test_two_comp_mod(int src, unsigned int width, int expected) {
Data dst;
dst.two_comp_mod(Data(src), Data(width));
ASSERT_EQ(expected, dst.get_int());
EXPECT_EQ(expected, dst.get_int());
}

} // namespace
Expand Down

0 comments on commit 9e4a70e

Please sign in to comment.