aboutsummaryrefslogtreecommitdiffstats
path: root/common/dynamic_bitarray.h
diff options
context:
space:
mode:
authorKeith Rothman <537074+litghost@users.noreply.github.com>2021-02-24 08:52:26 -0800
committerKeith Rothman <537074+litghost@users.noreply.github.com>2021-02-24 09:09:06 -0800
commit6d193ffd8b6482cddceb5c9050e36315d99d3363 (patch)
treeb84c5a56164e932477987dd06f8c9b82f7a8baa2 /common/dynamic_bitarray.h
parent3650294e512d48f2f2bb1bfdd867f672b7dc62dd (diff)
downloadnextpnr-6d193ffd8b6482cddceb5c9050e36315d99d3363.tar.gz
nextpnr-6d193ffd8b6482cddceb5c9050e36315d99d3363.tar.bz2
nextpnr-6d193ffd8b6482cddceb5c9050e36315d99d3363.zip
Fix some bugs found in review.
Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
Diffstat (limited to 'common/dynamic_bitarray.h')
-rw-r--r--common/dynamic_bitarray.h7
1 files changed, 2 insertions, 5 deletions
diff --git a/common/dynamic_bitarray.h b/common/dynamic_bitarray.h
index 7a7b2bf9..10a85fbc 100644
--- a/common/dynamic_bitarray.h
+++ b/common/dynamic_bitarray.h
@@ -39,10 +39,7 @@ template <typename Storage = std::vector<uint8_t>> class DynamicBitarray
std::fill(storage.begin(), storage.end(), value ? std::numeric_limits<typename Storage::value_type>::max() : 0);
}
- constexpr size_t bits_per_value() const
- {
- return sizeof(typename Storage::value_type) * std::numeric_limits<typename Storage::value_type>::digits;
- }
+ constexpr size_t bits_per_value() const { return std::numeric_limits<typename Storage::value_type>::digits; }
bool get(size_t bit) const
{
@@ -67,7 +64,7 @@ template <typename Storage = std::vector<uint8_t>> class DynamicBitarray
void resize(size_t number_bits)
{
- size_t required_storage = (number_bits + bits_per_value()) / bits_per_value();
+ size_t required_storage = (number_bits + bits_per_value() - 1) / bits_per_value();
storage.resize(required_storage);
}