Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file fixed_intf.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146moduletypeRound=sigtypebitstypet(** These are purely directional rounding, to be read as round to the nearest whole
fraction specified. For example if we were in base 10 and rounding to 1 decimal
place:
[neg_infinity]: 1.91 -> 1.9; -1.15 -> -1.2; 1.55 -> 1.5
[pos_infinity]: 1.91 -> 2.0; -1.15 -> -1.1; 1.55 -> 1.6
[to_zero]: 1.91 -> 1.9; -1.15 -> -1.1; 1.55 -> 1.5
[away_from_zero]: 1.91 -> 2.0; -1.15 -> -1.2; 1.55 -> 1.6
*)valneg_infinity:tvalpos_infinity:tvalto_zero:tvalaway_from_zero:t(** The tie_ functions always round to the nearest whole fraction specified, except in
the X.5 case which is determined by the function used. [tie_away_from_zero] would
match round_nearest in software implementations.
[tie_to_neg_infinity]: 1.91 -> 1.9; -1.15 -> -1.2; 1.55 -> 1.5
[tie_to_pos_infinity]: 1.91 -> 1.9; -1.15 -> -1.1; 1.55 -> 1.6
[tie_to_zero]: 1.91 -> 1.9; -1.15 -> -1.1; 1.55 -> 1.5
[tie_away_from_zero]: 1.91 -> 1.9; -1.15 -> -1.2; 1.55 -> 1.6
[tie_to_nearest_even]: 1.91 -> 1.9; -1.15 -> -1.2; 1.55 -> 1.6
[tie_to_nearest_odd]: 1.91 -> 1.9; -1.15 -> -1.1; 1.55 -> 1.5
*)valtie_to_neg_infinity:tvaltie_to_pos_infinity:tvaltie_to_zero:tvaltie_away_from_zero:tvaltie_to_nearest_even:tvaltie_to_nearest_odd:tvalgeneric:bits->tvaleval:t->int->bits->bitsendmoduletypeOverflow=sigtypebitstypetvalwrap:tvalsaturate:tvaleval:t->int->int->bits->bitsendmoduletypeFixed_point=sigtypebitsmoduleRound:Roundwithtypebits=bitsmoduleOverflow:Overflowwithtypebits=bitstypet[@@derivingsexp_of](** create a fixed point value. [create f x] will have [f] fractional bits. [width x -
f] will be the number of integer bits *)valcreate:int->bits->t(** return the integer part of the value *)valint:t->bits(** return the fractional part of the value *)valfrac:t->bits(** return the underlying bits *)valsignal:t->bits(** Map over the internal signal. Useful to register fixed point values
[map t ~f:(reg spec ~enable:vdd)]. *)valmap:t->f:(bits->bits)->t(** number of integer bits *)valwidth_int:t->int(** number of fractional bits *)valwidth_frac:t->int(** convert fixed point value to a float *)valto_float:t->float(** [select_int f x] extracts the integer part, and resizes it to x bits. Bits are
dropped from the msb down, if required. *)valselect_int: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. *)valselect_frac:t->int->bits(** resizes a fixed type using select_int and select_frac *)valselect:t->int->int->t(** find largest integer and fractional parts in each fixed value, and resize all
elements to that size *)valnorm:tlist->tlist(** same as norm, but for 2 values *)valnorm2:t->t->t*t(** create a fixed value with the given number of integer and fractional bits from the
floating point value *)valof_float:int->int->float->t(** adition *)val(+:):t->t->t(** subtraction *)val(-:):t->t->t(** multiplication *)val(*:):t->t->t(** equality *)val(==:):t->t->bits(** inequality *)val(<>:):t->t->bits(** less than *)val(<:):t->t->bits(** less than or equal to *)val(<=:):t->t->bits(** greater than *)val(>:):t->t->bits(** greater than or equal to *)val(>=:):t->t->bits(** multiplexor *)valmux:bits->tlist->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. *)valscale_pow2:t->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 *)valresize:?round:Round.t->?overflow:Overflow.t->t->int->int->tend