Universal Numbers Library C++ API
sw::universal -- header-only custom arithmetic types (posit, cfloat, lns, fixpnt, dd/qd, and more)
Loading...
Searching...
No Matches
sw::universal::bitblock< nbits > Class Template Reference

templated class implementing efficient multi-precision binary arithmetic and logic More...

#include <bitblock_v2.hpp>

Inheritance diagram for sw::universal::bitblock< nbits >:
universal_bitset::bitset< nbits > universal_bitset::BaseBitset< UBB_WORDS(Nb)>

Public Member Functions

 bitblock ()
 bitblock (const bitblock &)=default
 bitblock (bitblock &&)=default
bitblock & operator= (const bitblock &)=default
bitblock & operator= (bitblock &&)=default
bitblock & operator= (signed char rhs)
bitblock & operator= (short rhs)
bitblock & operator= (int rhs)
bitblock & operator= (long rhs)
bitblock & operator= (long long rhs)
bitblock & operator= (char rhs)
bitblock & operator= (unsigned short rhs)
bitblock & operator= (unsigned int rhs)
bitblock & operator= (unsigned long rhs)
bitblock & operator= (unsigned long long rhs)
unsigned long long to_ullong () const
void setzero ()
bool load_bits (const std::string &string_of_bits)
Public Member Functions inherited from universal_bitset::bitset< nbits >
constexpr bitset () noexcept
 All bits set to zero.
bitset< Nb > & operator&= (const bitset< Nb > &rhs) noexcept
 Operations on bitsets.
bitset< Nb > & operator|= (const bitset< Nb > &rhs) noexcept
bitset< Nb > & operator^= (const bitset< Nb > &rhs) noexcept
bitset< Nb > & operator<<= (size_t position) noexcept
 Operations on bitsets.
bitset< Nb > & operator>>= (size_t position) noexcept
bitset< Nb > & Unchecked_set (size_t pos) noexcept
 These versions of single-bit set, reset, flip, and test are extensions from the SGI version.
bitset< Nb > & Unchecked_reset (size_t pos) noexcept
bitset< Nb > & Unchecked_flip (size_t pos) noexcept
constexpr bool Unchecked_test (size_t pos) const noexcept
bitset< Nb > & set () noexcept
 Sets every bit to true.
bitset< Nb > & reset () noexcept
 Sets every bit to false.
bitset< Nb > & flip () noexcept
 Toggles every bit to its opposite value.
bitset< Nb > operator~ () const noexcept
 See the no-argument flip().
reference operator[] (size_t position)
 Array-indexing support.
unsigned long to_ulong () const
 Returns a numerical interpretation of the bitset.
unsigned long long to_ullong () const
std::basic_string< _CharT, _Traits, _Alloc > to_string () const
 Returns a character interpretation of the bitset.
void M_copy_from_ptr (const _CharT *, size_t, size_t, size_t, _CharT, _CharT)
void M_copy_from_string (const std::basic_string< _CharT, _Traits, _Alloc > &s, size_t pos, size_t n, _CharT zero, _CharT one)
void M_copy_to_string (std::basic_string< _CharT, _Traits, _Alloc > &, _CharT, _CharT) const
size_t count () const noexcept
 Returns the number of bits which are set.
constexpr size_t size () const noexcept
 Returns the total number of bits.
bool operator== (const bitset< Nb > &rhs) const noexcept
 These comparisons for equality/inequality are, well, bitwise.
bool operator!= (const bitset< Nb > &rhs) const noexcept
bool operator< (const bitset< Nb > &rhs) const noexcept
bool operator<= (const bitset< Nb > &rhs) const noexcept
bool operator> (const bitset< Nb > &rhs) const noexcept
bool operator>= (const bitset< Nb > &rhs) const noexcept
int getMSB () const noexcept
bool increment () noexcept
bool decrement () noexcept
bool add (const bitset< NbOpnd > &a, const bitset< NbOpnd > &b) noexcept
bool sub (const bitset< NbOpnd > &a, const bitset< NbOpnd > &b) noexcept
bool test (size_t position) const
 Tests the value of a bit.
bool all () const noexcept
 Tests whether all the bits are on.
bool any () const noexcept
 Tests whether any of the bits are on.
bool none () const noexcept
 Tests whether any of the bits are on.
bitset< Nb > operator<< (size_t position) const noexcept
 Self-explanatory.
bitset< Nb > operator>> (size_t position) const noexcept
size_t _Find_first () const noexcept
 Finds the index of the first "on" bit.
size_t _Find_next (size_t prev) const noexcept
 Finds the index of the next "on" bit after prev.
Public Member Functions inherited from universal_bitset::BaseBitset< UBB_WORDS(Nb)>
constexpr BaseBitset () noexcept
constexpr BaseBitset (unsigned long long val) noexcept
constexpr bool M_testBit (size_t pos) const noexcept
WordT & M_getword (size_t pos) noexcept
constexpr WordT M_getword (size_t pos) const noexcept
const WordT * M_getdata () const noexcept
WordT & M_hiword () noexcept
constexpr WordT M_hiword () const noexcept
void M_do_and (const BaseBitset< Nw > &x) noexcept
void M_do_or (const BaseBitset< Nw > &x) noexcept
void M_do_xor (const BaseBitset< Nw > &x) noexcept
void M_do_left_shift (size_t shift) noexcept
void M_do_right_shift (size_t shift) noexcept
void M_do_flip () noexcept
void M_do_set () noexcept
void M_do_reset () noexcept
bool M_is_equal (const BaseBitset< Nw > &x) const noexcept
bool M_is_less_than (const BaseBitset< Nw > &x) const noexcept
 Blocked unsigned less-than operation.
bool M_is_greater_than (const BaseBitset< Nw > &x) const noexcept
 Blocked unsigned greater-than operation.
int M_getMSB () const noexcept
 Finds the position of the highest set bit.
bool M_increment () noexcept
 Increments underlying value by unity.
bool M_decrement () noexcept
 Decrements underlying value by unity.
bool M_do_add (const BaseBitset< UBB_WORDS(Nb)> &a, const BaseBitset< UBB_WORDS(Nb)> &b) noexcept
 Slotwise addtion to this value.
bool M_do_add (const BaseBitset< UBB_WORDS(Nb)> &a) noexcept
 Slotwise increment of this value.
bool M_do_sub (const BaseBitset< UBB_WORDS(Nb)> &a, const BaseBitset< UBB_WORDS(Nb)> &b) noexcept
 Slotwise subtraction into this value.
bool M_do_sub (const BaseBitset< UBB_WORDS(Nb)> &a) noexcept
 Slotwise decrement of this value.
bool M_are_all () const noexcept
bool M_is_any () const noexcept
size_t M_do_count () const noexcept
unsigned long M_do_to_ulong () const
unsigned long long M_do_to_ullong () const
size_t M_do_find_first (size_t) const noexcept
size_t M_do_find_next (size_t, size_t) const noexcept

Additional Inherited Members

Static Public Member Functions inherited from universal_bitset::BaseBitset< UBB_WORDS(Nb)>
static int S_getMSB (const WordT &val)
 Finds leading bit of value passed.
static bool S_increment (WordT &val)
 increments the value passed.
static bool S_decrement (WordT &val)
 decrements the value passed.
static bool S_add (WordT &accum, const WordT &a, const WordT &b, bool carry)
 Performs a two-operand addition on a single slot.
static bool S_add (WordT &accum, const WordT &a, bool carry)
 Performs a two-operand addition on a single slot.
static bool S_sub (WordT &accum, const WordT &a, const WordT &b, const bool borrow)
 Performs a two-operand subtraction on a single slot.
static bool S_sub (WordT &accum, const WordT &a, bool borrow)
 Performs a single-operand subtraction.
static constexpr size_t S_whichword (size_t pos) noexcept
static constexpr size_t S_whichbyte (size_t pos) noexcept
static constexpr size_t S_whichbit (size_t pos) noexcept
static constexpr WordT S_maskbit (size_t pos) noexcept
Public Attributes inherited from universal_bitset::BaseBitset< UBB_WORDS(Nb)>
WordT M_w [Nw]
 0 is the least significant word.

Detailed Description

template<size_t nbits>
class sw::universal::bitblock< nbits >

templated class implementing efficient multi-precision binary arithmetic and logic

Constructor & Destructor Documentation

◆ bitblock() [1/3]

template<size_t nbits>
sw::universal::bitblock< nbits >::bitblock ( )
inline

◆ bitblock() [2/3]

template<size_t nbits>
sw::universal::bitblock< nbits >::bitblock ( const bitblock< nbits > & )
default

◆ bitblock() [3/3]

template<size_t nbits>
sw::universal::bitblock< nbits >::bitblock ( bitblock< nbits > && )
default

Member Function Documentation

◆ load_bits()

template<size_t nbits>
bool sw::universal::bitblock< nbits >::load_bits ( const std::string & string_of_bits)
inline

◆ operator=() [1/12]

template<size_t nbits>
bitblock & sw::universal::bitblock< nbits >::operator= ( bitblock< nbits > && )
default

◆ operator=() [2/12]

template<size_t nbits>
bitblock & sw::universal::bitblock< nbits >::operator= ( char rhs)
inline

◆ operator=() [3/12]

template<size_t nbits>
bitblock & sw::universal::bitblock< nbits >::operator= ( const bitblock< nbits > & )
default

◆ operator=() [4/12]

template<size_t nbits>
bitblock & sw::universal::bitblock< nbits >::operator= ( int rhs)
inline

◆ operator=() [5/12]

template<size_t nbits>
bitblock & sw::universal::bitblock< nbits >::operator= ( long long rhs)
inline

◆ operator=() [6/12]

template<size_t nbits>
bitblock & sw::universal::bitblock< nbits >::operator= ( long rhs)
inline

◆ operator=() [7/12]

template<size_t nbits>
bitblock & sw::universal::bitblock< nbits >::operator= ( short rhs)
inline

◆ operator=() [8/12]

template<size_t nbits>
bitblock & sw::universal::bitblock< nbits >::operator= ( signed char rhs)
inline

◆ operator=() [9/12]

template<size_t nbits>
bitblock & sw::universal::bitblock< nbits >::operator= ( unsigned int rhs)
inline

◆ operator=() [10/12]

template<size_t nbits>
bitblock & sw::universal::bitblock< nbits >::operator= ( unsigned long long rhs)
inline

◆ operator=() [11/12]

template<size_t nbits>
bitblock & sw::universal::bitblock< nbits >::operator= ( unsigned long rhs)
inline

◆ operator=() [12/12]

template<size_t nbits>
bitblock & sw::universal::bitblock< nbits >::operator= ( unsigned short rhs)
inline

◆ setzero()

template<size_t nbits>
void sw::universal::bitblock< nbits >::setzero ( )
inline

◆ to_ullong()

template<size_t nbits>
unsigned long long sw::universal::bitblock< nbits >::to_ullong ( ) const
inline

The documentation for this class was generated from the following file:
  • /home/runner/work/universal/universal/include/sw/universal/internal/bitblock/bitblock_v2.hpp