Skip to content

Commit

Permalink
cxxrtl: Mask bmux result appropriately
Browse files Browse the repository at this point in the history
  • Loading branch information
povik authored and whitequark committed Dec 14, 2023
1 parent 39fdde8 commit 449e3db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions backends/cxxrtl/runtime/cxxrtl/cxxrtl.h
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ struct value : public expr_base<value<Bits>> {
carry = (shift_bits == 0) ? 0
: data[result.chunks + shift_chunks - 1 - n] << (chunk::bits - shift_bits);
}
result.data[result.chunks - 1] &= result.msb_mask;
return result;
}

Expand Down
7 changes: 7 additions & 0 deletions tests/cxxrtl/test_value.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,11 @@ int main()
cxxrtl::value<32> a(0x00040000u);
assert(a.ctlz() == 13);
}

{
// bmux clears top bits of result
cxxrtl::value<8> val(0x1fu);
cxxrtl::value<1> sel(0u);
assert(val.template bmux<4>(sel).get<uint64_t>() == 0xfu);
}
}

0 comments on commit 449e3db

Please sign in to comment.