Fixed point data types will be modeled after sfixed and ufixed from VHDL since they are fantastically well-designed. These should act as subtypes of BitArray, thus only contain 0/1 values.
Implementation
Implementation should use arbitrary-sized integers under the hood like signed, unsigned, and BitArray will. This can start out as 64 bit integers with a size limit of 64 enforced at the start.
Interface
Operations include the following:
+
-
*
resize: resize a fixed point to a different size with round mode, saturation mode, and guard bits
- unary
-
- unary
+
abs()
/
%
divmod()
divide: returns division with round mode and guard bits
reciprocal: return 1/value with round round mode and guard bits
modulo: returns the modulo with round mode and guard bits
remainder: returns the remainder after division with round mode and guard bits
- total ordering
Binary operations with these types should support other numeric types: integers, floats, Signed, Unsigned, Float, other fixed point types (when appropriate).
It should also include the full set of operation on BitArray include bitwise operators and unary negation ~. These should yield BitArrays.
It should be convertible by value from and to the following types:
- C++ integer types
- C++ floating types
Signed
Unsigned
Float
- each other
They should be reinterpretable with a an as cast to:
BitArray
Signed
Unsigned
Float
Fixed point data types will be modeled after
sfixedandufixedfrom VHDL since they are fantastically well-designed. These should act as subtypes of BitArray, thus only contain 0/1 values.Implementation
Implementation should use arbitrary-sized integers under the hood like
signed,unsigned, andBitArraywill. This can start out as 64 bit integers with a size limit of 64 enforced at the start.Interface
Operations include the following:
+-*resize: resize a fixed point to a different size with round mode, saturation mode, and guard bits-+abs()/%divmod()divide: returns division with round mode and guard bitsreciprocal: return 1/value with round round mode and guard bitsmodulo: returns the modulo with round mode and guard bitsremainder: returns the remainder after division with round mode and guard bitsBinary operations with these types should support other numeric types: integers, floats, Signed, Unsigned, Float, other fixed point types (when appropriate).
It should also include the full set of operation on BitArray include bitwise operators and unary negation
~. These should yield BitArrays.It should be convertible by value from and to the following types:
SignedUnsignedFloatThey should be reinterpretable with a an
ascast to:BitArraySignedUnsignedFloat