Page
Library
Module
Module type
Parameter
Class
Class type
Source
Hardcaml_fixed_point.Unsigned
Sourcemodule Bits : Hardcaml.Comb.S
create a fixed point value. create f x
will have f
fractional bits. width x - f
will be the number of integer bits
Map over the internal signal. Useful to register fixed point values
map t ~f:(reg spec ~enable:vdd)
.
select_int f x
extracts the integer part, and resizes it to x bits. Bits are dropped from the msb down, if required.
select_frac f x
extracts the fractional part, and resizes it to x bits. Bits are dropped from the lsb up, if required.
find largest integer and fractional parts in each fixed value, and resize all elements to that size
create a fixed value with the given number of integer and fractional bits from the floating point value
scale_pow2 t x
will compute t * (2 ^ x)
, allowing for multiplication or division by a power of 2. Equivalent to a left or right bit shift but also does boundary checking and will extend the underlying number of bits if required.
resize x i f
will resize the integer part to have i
bits, and fractional part to have f
bits. Rounding and overflow control is applied