2 (** This module defines functions to manipulate bounded integers. They can be
3 used to represent sequences of bits. *)
5 (* Integers, whatever their size, will be represented using the Big_int
6 module. This allows immediate conversion, and allows the representation of
7 any integer (that fits into memory). *)
10 val print_int_repr : int_repr -> string
12 (* The parameter module. Bounded integers are characterized by the number of
13 bits used to represent them. *)
17 val size : int (* in bytes *)
20 (* The signature provided to manipulate bounded integers. *)
27 val compare : t -> t -> int
28 val to_string : t -> string
32 val to_signed_repr : t -> repr
33 val to_unsigned_repr : t -> repr
38 (** [add_of i1 i2] returns [true] iff adding [i1] and [i2] overflows. *)
39 val add_of : t -> t -> bool
41 (** [sub_uf i1 i2] returns [true] iff substracting [i1] and [i2]
43 val sub_uf : t -> t -> bool
46 val divu : t -> t -> t
47 val modulo : t -> t -> t
48 val modulou : t -> t -> t
49 val eq : t -> t -> bool
50 val neq : t -> t -> bool
51 val lt : t -> t -> bool
52 val ltu : t -> t -> bool
53 val le : t -> t -> bool
54 val leu : t -> t -> bool
55 val gt : t -> t -> bool
56 val gtu : t -> t -> bool
57 val ge : t -> t -> bool
58 val geu : t -> t -> bool
61 val logand : t -> t -> t
62 val logor : t -> t -> t
63 val logxor : t -> t -> t
66 val shrl : t -> t -> t
68 val maxu : t -> t -> t
70 val minu : t -> t -> t
75 (** [zero_ext n a] performs zero extension on [a] where [n] bits are
77 val zero_ext : int -> t -> t
78 (** [sign_ext n a] performs sign extension on [a] where [n] bits are
80 val sign_ext : int -> t -> t
82 (** [break i n] cuts [i] in [n] parts. In the resulting list, the first
83 element is the low bits, and the last is the high bits (little endian
85 val break : t -> int -> t list
86 (** [merge l] creates the integer where the first element of [l] is its low
87 bits, etc, and the last element of [l] is its high bits (little endian
89 val merge : t list -> t
93 module type SRepr = S with type t = int_repr and type repr = int_repr
95 (** The functor to create bounded integers from a size. *)
97 module Make: functor (IntType: INTTYPE) -> SRepr
115 (** Unbounded integers. *)
120 type int16s = Int16s.t
121 type int16u = Int16u.t
123 type integer = Integer.t