package hardcaml_fixed_point

  1. Overview
  2. Docs

Module Hardcaml_fixed_point.UnsignedSource

Parameters

Signature

Sourcetype bits = Bits.t
Sourcemodule Round : sig ... end
Sourcemodule Overflow : sig ... end
Sourcetype t
Sourceval sexp_of_t : t -> Sexplib0.Sexp.t
Sourceval create : int -> bits -> t

create a fixed point value. create f x will have f fractional bits. width x - f will be the number of integer bits

Sourceval int : t -> bits

return the integer part of the value

Sourceval frac : t -> bits

return the fractional part of the value

Sourceval signal : t -> bits

return the underlying bits

Sourceval map : t -> f:(bits -> bits) -> t

Map over the internal signal. Useful to register fixed point values

map t ~f:(reg spec ~enable:vdd).

Sourceval width_int : t -> int

number of integer bits

Sourceval width_frac : t -> int

number of fractional bits

Sourceval to_float : t -> float

convert fixed point value to a float

Sourceval select_int : t -> int -> bits

select_int f x extracts the integer part, and resizes it to x bits. Bits are dropped from the msb down, if required.

Sourceval select_frac : t -> int -> bits

select_frac f x extracts the fractional part, and resizes it to x bits. Bits are dropped from the lsb up, if required.

Sourceval select : t -> int -> int -> t

resizes a fixed type using select_int and select_frac

Sourceval norm : t list -> t list

find largest integer and fractional parts in each fixed value, and resize all elements to that size

Sourceval norm2 : t -> t -> t * t

same as norm, but for 2 values

Sourceval of_float : int -> int -> float -> t

create a fixed value with the given number of integer and fractional bits from the floating point value

Sourceval (+:) : t -> t -> t

adition

Sourceval (-:) : t -> t -> t

subtraction

Sourceval (*:) : t -> t -> t

multiplication

Sourceval (==:) : t -> t -> bits

equality

Sourceval (<>:) : t -> t -> bits

inequality

Sourceval (<:) : t -> t -> bits

less than

Sourceval (<=:) : t -> t -> bits

less than or equal to

Sourceval (>:) : t -> t -> bits

greater than

Sourceval (>=:) : t -> t -> bits

greater than or equal to

Sourceval mux : bits -> t list -> t

multiplexor

Sourceval scale_pow2 : t -> int -> t

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.

Sourceval 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

OCaml

Innovation. Community. Security.