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

Base class, general case. More...

#include <ubb.h>

Public Member Functions

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.
template<size_t Nb>
bool M_do_add (const BaseBitset< UBB_WORDS(Nb)> &a, const BaseBitset< UBB_WORDS(Nb)> &b) noexcept
 Slotwise addtion to this value.
template<size_t Nb>
bool M_do_add (const BaseBitset< UBB_WORDS(Nb)> &a) noexcept
 Slotwise increment of this value.
template<size_t Nb>
bool M_do_sub (const BaseBitset< UBB_WORDS(Nb)> &a, const BaseBitset< UBB_WORDS(Nb)> &b) noexcept
 Slotwise subtraction into this value.
template<size_t Nb>
bool M_do_sub (const BaseBitset< UBB_WORDS(Nb)> &a) noexcept
 Slotwise decrement of this value.
template<size_t Nb>
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

Static Public Member Functions

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

WordT M_w [Nw]
 0 is the least significant word.

Detailed Description

template<size_t Nw>
struct universal_bitset::BaseBitset< Nw >

Base class, general case.

It is a class invariant that Nw will be nonnegative.

See documentation for bitset.

Constructor & Destructor Documentation

◆ BaseBitset() [1/2]

template<size_t Nw>
universal_bitset::BaseBitset< Nw >::BaseBitset ( )
inlineconstexprnoexcept

◆ BaseBitset() [2/2]

template<size_t Nw>
universal_bitset::BaseBitset< Nw >::BaseBitset ( unsigned long long val)
inlineconstexprnoexcept

Member Function Documentation

◆ M_are_all()

template<size_t Nw>
template<size_t Nb>
bool universal_bitset::BaseBitset< Nw >::M_are_all ( ) const
inlinenoexcept

◆ M_decrement()

template<size_t Nw>
bool universal_bitset::BaseBitset< Nw >::M_decrement ( )
inlinenoexcept

Decrements underlying value by unity.

Returns
true iff borrow generated in most-significant word.

◆ M_do_add() [1/2]

template<size_t Nw>
template<size_t Nb>
bool universal_bitset::BaseBitset< Nw >::M_do_add ( const BaseBitset< UBB_WORDS(Nb)> & a)
inlinenoexcept

Slotwise increment of this value.

Parameters
ais an addend.
Returns
true iff carry generated.

◆ M_do_add() [2/2]

template<size_t Nw>
template<size_t Nb>
bool universal_bitset::BaseBitset< Nw >::M_do_add ( const BaseBitset< UBB_WORDS(Nb)> & a,
const BaseBitset< UBB_WORDS(Nb)> & b )
inlinenoexcept

Slotwise addtion to this value.

Parameters
ais an addend.
bis an addend.
Returns
true iff carry generated.

◆ M_do_and()

template<size_t Nw>
void universal_bitset::BaseBitset< Nw >::M_do_and ( const BaseBitset< Nw > & x)
inlinenoexcept

◆ M_do_count()

template<size_t Nw>
size_t universal_bitset::BaseBitset< Nw >::M_do_count ( ) const
inlinenoexcept

◆ M_do_find_first()

template<size_t Nw>
size_t universal_bitset::BaseBitset< Nw >::M_do_find_first ( size_t not_found) const
noexcept

◆ M_do_find_next()

template<size_t Nw>
size_t universal_bitset::BaseBitset< Nw >::M_do_find_next ( size_t prev,
size_t not_found ) const
noexcept

◆ M_do_flip()

template<size_t Nw>
void universal_bitset::BaseBitset< Nw >::M_do_flip ( )
inlinenoexcept

◆ M_do_left_shift()

template<size_t Nw>
void universal_bitset::BaseBitset< Nw >::M_do_left_shift ( size_t shift)
noexcept

◆ M_do_or()

template<size_t Nw>
void universal_bitset::BaseBitset< Nw >::M_do_or ( const BaseBitset< Nw > & x)
inlinenoexcept

◆ M_do_reset()

template<size_t Nw>
void universal_bitset::BaseBitset< Nw >::M_do_reset ( )
inlinenoexcept

◆ M_do_right_shift()

template<size_t Nw>
void universal_bitset::BaseBitset< Nw >::M_do_right_shift ( size_t shift)
noexcept

◆ M_do_set()

template<size_t Nw>
void universal_bitset::BaseBitset< Nw >::M_do_set ( )
inlinenoexcept

◆ M_do_sub() [1/2]

template<size_t Nw>
template<size_t Nb>
bool universal_bitset::BaseBitset< Nw >::M_do_sub ( const BaseBitset< UBB_WORDS(Nb)> & a)
inlinenoexcept

Slotwise decrement of this value.

Parameters
ais the subtrahend.
Returns
true iff borrow generated.

◆ M_do_sub() [2/2]

template<size_t Nw>
template<size_t Nb>
bool universal_bitset::BaseBitset< Nw >::M_do_sub ( const BaseBitset< UBB_WORDS(Nb)> & a,
const BaseBitset< UBB_WORDS(Nb)> & b )
inlinenoexcept

Slotwise subtraction into this value.

Parameters
ais the minuend.
bis the subtrahend.

◆ M_do_to_ullong()

template<size_t Nw>
unsigned long long universal_bitset::BaseBitset< Nw >::M_do_to_ullong ( ) const

◆ M_do_to_ulong()

template<size_t Nw>
unsigned long universal_bitset::BaseBitset< Nw >::M_do_to_ulong ( ) const

◆ M_do_xor()

template<size_t Nw>
void universal_bitset::BaseBitset< Nw >::M_do_xor ( const BaseBitset< Nw > & x)
inlinenoexcept

◆ M_getdata()

template<size_t Nw>
const WordT * universal_bitset::BaseBitset< Nw >::M_getdata ( ) const
inlinenoexcept

◆ M_getMSB()

template<size_t Nw>
int universal_bitset::BaseBitset< Nw >::M_getMSB ( ) const
inlinenoexcept

Finds the position of the highest set bit.

Returns
leading bit position, if any, else -1.

◆ M_getword() [1/2]

template<size_t Nw>
WordT universal_bitset::BaseBitset< Nw >::M_getword ( size_t pos) const
inlineconstexprnoexcept

◆ M_getword() [2/2]

template<size_t Nw>
WordT & universal_bitset::BaseBitset< Nw >::M_getword ( size_t pos)
inlinenoexcept

◆ M_hiword() [1/2]

template<size_t Nw>
WordT universal_bitset::BaseBitset< Nw >::M_hiword ( ) const
inlineconstexprnoexcept

◆ M_hiword() [2/2]

template<size_t Nw>
WordT & universal_bitset::BaseBitset< Nw >::M_hiword ( )
inlinenoexcept

◆ M_increment()

template<size_t Nw>
bool universal_bitset::BaseBitset< Nw >::M_increment ( )
inlinenoexcept

Increments underlying value by unity.

Returns
true iff carry in most-significant word.

◆ M_is_any()

template<size_t Nw>
bool universal_bitset::BaseBitset< Nw >::M_is_any ( ) const
inlinenoexcept

◆ M_is_equal()

template<size_t Nw>
bool universal_bitset::BaseBitset< Nw >::M_is_equal ( const BaseBitset< Nw > & x) const
inlinenoexcept

◆ M_is_greater_than()

template<size_t Nw>
bool universal_bitset::BaseBitset< Nw >::M_is_greater_than ( const BaseBitset< Nw > & x) const
inlinenoexcept

Blocked unsigned greater-than operation.

Parameters
xis the comparison value.
Returns
true iff this is greater than passed value.

◆ M_is_less_than()

template<size_t Nw>
bool universal_bitset::BaseBitset< Nw >::M_is_less_than ( const BaseBitset< Nw > & x) const
inlinenoexcept

Blocked unsigned less-than operation.

Parameters
xis the comparison value.
Returns
true iff this is less than passed argument.

◆ M_testBit()

template<size_t Nw>
bool universal_bitset::BaseBitset< Nw >::M_testBit ( size_t pos) const
inlineconstexprnoexcept

◆ S_add() [1/2]

template<size_t Nw>
bool universal_bitset::BaseBitset< Nw >::S_add ( WordT & accum,
const WordT & a,
bool carry )
inlinestatic

Performs a two-operand addition on a single slot.

Parameters
[in,out]accumaccumulates the sum.
ais an addend.
carryis true iff a carry was generated by the previous slot.
Returns
true iff a full slot carry precipitated.

◆ S_add() [2/2]

template<size_t Nw>
bool universal_bitset::BaseBitset< Nw >::S_add ( WordT & accum,
const WordT & a,
const WordT & b,
bool carry )
inlinestatic

Performs a two-operand addition on a single slot.

Parameters
[in,out]accumaccumulates the sum.
ais an addend.
bis an addend.
carryis true iff a carry was generated by the previous slot.
Returns
true iff a full slot carry precipitated.

◆ S_decrement()

template<size_t Nw>
bool universal_bitset::BaseBitset< Nw >::S_decrement ( WordT & val)
inlinestatic

decrements the value passed.

Parameters
[in,out]valthe value to be decremented.
Returns
true iff (unsigned) decrement precipitates a borrow.

◆ S_getMSB()

template<size_t Nw>
int universal_bitset::BaseBitset< Nw >::S_getMSB ( const WordT & val)
inlinestatic

Finds leading bit of value passed.

Parameters
valis said value.
Returns
leading bit position, if any, else -1.

◆ S_increment()

template<size_t Nw>
bool universal_bitset::BaseBitset< Nw >::S_increment ( WordT & val)
inlinestatic

increments the value passed.

Parameters
[in,out]valthe value to be incremented.
Returns
true iff (unsigned) increment precipitates a carry.

◆ S_maskbit()

template<size_t Nw>
constexpr WordT universal_bitset::BaseBitset< Nw >::S_maskbit ( size_t pos)
inlinestaticconstexprnoexcept

◆ S_sub() [1/2]

template<size_t Nw>
bool universal_bitset::BaseBitset< Nw >::S_sub ( WordT & accum,
const WordT & a,
bool borrow )
inlinestatic

Performs a single-operand subtraction.

Parameters
[in,out]accumaccumulates the sum.
ais the (pre-borrow) subtrahend.
borrowinidcates whether a borrow applies from the previous slot.
Returns
true iff a full slot borrow precipitated.

◆ S_sub() [2/2]

template<size_t Nw>
bool universal_bitset::BaseBitset< Nw >::S_sub ( WordT & accum,
const WordT & a,
const WordT & b,
const bool borrow )
inlinestatic

Performs a two-operand subtraction on a single slot.

Parameters
[in,out]accumaccumulates the sum.
ais the minuend.
bis the (pre-borrow) subtrahend.
borrowinidcates whether a borrow applies from the previous slot.
Returns
true iff a full slot borrow precipitated.

◆ S_whichbit()

template<size_t Nw>
constexpr size_t universal_bitset::BaseBitset< Nw >::S_whichbit ( size_t pos)
inlinestaticconstexprnoexcept

◆ S_whichbyte()

template<size_t Nw>
constexpr size_t universal_bitset::BaseBitset< Nw >::S_whichbyte ( size_t pos)
inlinestaticconstexprnoexcept

◆ S_whichword()

template<size_t Nw>
constexpr size_t universal_bitset::BaseBitset< Nw >::S_whichword ( size_t pos)
inlinestaticconstexprnoexcept

Member Data Documentation

◆ M_w

template<size_t Nw>
WordT universal_bitset::BaseBitset< Nw >::M_w[Nw]

0 is the least significant word.


The documentation for this struct was generated from the following file:
  • /home/runner/work/universal/universal/include/sw/universal/internal/bitblock/ubb.h