NumberConfig#
- class NumberConfig#
A class to define the configuration of a number when represented in memory.
- static bit() pyhelayers.NumberConfig #
Builds a configuration describing a 1-bit number.
- static fixed_point(size: pyhelayers.NumberSize, sign: pyhelayers.NumberSigned, fractional_part_bits: int) pyhelayers.NumberConfig #
Builds a configuration describing a fraction represented by fixed point.
- Parameters:
size – The size of the number.
sign – Whether the number is signed or not.
fractional_part_bits – The number of bits allocated to the fractional part of the number.
- static floating_point(size: pyhelayers.NumberSize) pyhelayers.NumberConfig #
Builds a configuration describing a fraction represented by floating point.
- Parameters:
size – The size of the number.
- static integer(size: pyhelayers.NumberSize, sign: pyhelayers.NumberSigned) pyhelayers.NumberConfig #
Builds a configuration describing an integer.
- Parameters:
size – The size of the number.
sign – Whether the number is signed or not.
-
class NumberConfig : public helayers::SaveableBasic#
A class to define the configuration of a number when represented in memory.
Public Functions
-
bool isBit() const#
Returns an indication for whether a configuration describes a bit.
-
bool isInteger() const#
Returns an indication for whether a configuration describes an integer.
-
bool isFixedPoint() const#
Returns an indication for whether a configuration describes a fixed point fraction.
-
bool isFloatingPoint() const#
Returns an indication for whether a configuration describes a floating point fraction.
-
size_t getNumBits() const#
Returns the total number of bits in the number described by the configuration.
-
bool isSigned() const#
Returns an indication for whether the number described by the configuration is signed or not.
-
size_t getFixedPointFracBits() const#
Returns the number of bits of the fractional part of a fixed point fraction.
-
virtual std::streamoff save(std::ostream &stream) const override#
Saves this object to a stream in binary form.
Returns the number of bytes written to the output stream.
- Parameters:
stream – [in] output stream to write to
-
virtual std::streamoff load(std::istream &stream) override#
Loads this object from the given stream.
Returns the number of bytes read from the input stream.
- Parameters:
stream – [in] input stream to read from
Public Static Functions
-
static NumberConfig bit()#
Builds a configuration describing a 1-bit number.
-
static NumberConfig integer(NumberSize size, NumberSigned sign)#
Builds a configuration describing an integer.
- Parameters:
size – The size of the number.
sign – Whether the number is signed or not.
-
static NumberConfig fixedPoint(NumberSize size, NumberSigned sign, size_t fractionalPartBits)#
Builds a configuration describing a fraction represented by fixed point.
- Parameters:
size – The size of the number.
sign – Whether the number is signed or not.
fractionalPartBits – The number of bits allocated to the fractional part of the number.
-
static NumberConfig floatingPoint(NumberSize size)#
Builds a configuration describing a fraction represented by floating point.
- Parameters:
size – The size of the number.
-
bool isBit() const#