Library
Module
Module type
Parameter
Class
Class type
module Bits : Hardcaml.Comb.S
type bits = Bits.t
module Round : sig ... end
module Overflow : sig ... end
val sexp_of_t : t -> Sexplib0.Sexp.t
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)
.
val width_int : t -> int
number of integer bits
val width_frac : t -> int
number of fractional bits
val to_float : t -> float
convert fixed point value to a float
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
val of_float : int -> int -> float -> t
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.
val resize : ?round:Round.t -> ?overflow:Overflow.t -> t -> int -> int -> t
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