Skip to content

helpers ¤

Functions:

  • to_signed

    Returns the signed number associated with the two's-complement binary representation of unsigned

  • logical_shift_left
  • logical_shift_right

    n is truncated to the width of bit_width before the operation takes place.

  • rotate_right

    n is truncated to the width of bit_width before the operation takes place.

  • arithmetic_shift_right

    This returns the value represented by the two's-complement binary representation of the final result.

to_signed ¤

to_signed(unsigned: int, bit_width: int)

Returns the signed number associated with the two's-complement binary representation of unsigned

logical_shift_left ¤

logical_shift_left(n: int, shift_amt: int, bit_width: int)

logical_shift_right ¤

logical_shift_right(n: int, shift_amt: int, bit_width: int)

n is truncated to the width of bit_width before the operation takes place.

rotate_right ¤

rotate_right(n: int, shift_amt: int, bit_width: int)

n is truncated to the width of bit_width before the operation takes place.

arithmetic_shift_right ¤

arithmetic_shift_right(n: int, shift_amt: int, bit_width: int)

This returns the value represented by the two's-complement binary representation of the final result. This means the result could be negative (if the top bit of the input is negative)

n is truncated to the width of bit_width before the operation takes place.