Skip to content

Add Sfixed/Ufixed datatypes #173

Description

@ktbarrett

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions