diff options
author | whitequark <whitequark@whitequark.org> | 2020-06-15 01:37:05 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-15 01:37:05 +0000 |
commit | 9d0f1aa222972735412793ccb6ee7da609170fab (patch) | |
tree | d9a5060df14ff4eb0e4d16bd6c3da58b1fd63e62 /backends | |
parent | 74e93e083ff23f3381fe2409e5847f9843840b17 (diff) | |
parent | 66a2de2912604864e5d7a7717397caf814646621 (diff) | |
download | yosys-9d0f1aa222972735412793ccb6ee7da609170fab.tar.gz yosys-9d0f1aa222972735412793ccb6ee7da609170fab.tar.bz2 yosys-9d0f1aa222972735412793ccb6ee7da609170fab.zip |
Merge pull request #2158 from miek/sshr-sign-extension
cxxrtl: fix sshr sign-extension.
Diffstat (limited to 'backends')
-rw-r--r-- | backends/cxxrtl/cxxrtl.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/backends/cxxrtl/cxxrtl.h b/backends/cxxrtl/cxxrtl.h index c510b33d7..166b4896f 100644 --- a/backends/cxxrtl/cxxrtl.h +++ b/backends/cxxrtl/cxxrtl.h @@ -376,10 +376,12 @@ struct value : public expr_base<value<Bits>> { : data[chunks - 1 - n] << (chunk::bits - shift_bits); } if (Signed && is_neg()) { - for (size_t n = chunks - shift_chunks; n < chunks; n++) + size_t top_chunk_idx = (Bits - shift_bits) / chunk::bits; + size_t top_chunk_bits = (Bits - shift_bits) % chunk::bits; + for (size_t n = top_chunk_idx + 1; n < chunks; n++) result.data[n] = chunk::mask; if (shift_bits != 0) - result.data[chunks - shift_chunks] |= chunk::mask << (chunk::bits - shift_bits); + result.data[top_chunk_idx] |= chunk::mask << top_chunk_bits; } return result; } |