source: Deliverables/D2.2/8051/src/common/intValue.mli @ 619

Last change on this file since 619 was 619, checked in by ayache, 9 years ago

Update of D2.2 from Paris.

File size: 3.0 KB
RevLine 
[486]1
[619]2(** This module defines functions to manipulate bounded integers. They can be
3    used to represent sequences of bits. *)
[486]4
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). *)
8
9type int_repr = Big_int.big_int
10
[619]11(* The parameter module. Bounded integers are characterized by the number of
12   bits used to represent them. *)
[486]13   
14module type INTTYPE = 
15sig
[619]16  val size : int (* in bytes *)
[486]17end
18
[619]19(* The signature provided to manipulate bounded integers. *)
[486]20
21module type S = sig
22
23  type t = Big_int.big_int
24
25  val compare   : t -> t -> int
26  val to_string : t -> string
27  val zero      : t
28  val one       : t
29
[619]30  val succ    : t -> t
31  val pred    : t -> t
32  val add     : t -> t -> t
33  (** [add_of i1 i2] returns [true] iff adding [i1] and [i2] overflows. *)
34  val add_of  : t -> t -> bool
35  val sub     : t -> t -> t
36  (** [sub_uf i1 i2] returns [true] iff substracting [i1] and [i2]
37      underflows. *)
38  val sub_uf  : t -> t -> bool
39  val mul     : t -> t -> t
40  val div     : t -> t -> t
41  val divu    : t -> t -> t
42  val modulo  : t -> t -> t
43  val modulou : t -> t -> t
44  val eq      : t -> t -> bool
45  val neq     : t -> t -> bool
46  val lt      : t -> t -> bool
47  val ltu     : t -> t -> bool
48  val le      : t -> t -> bool
49  val leu     : t -> t -> bool
50  val gt      : t -> t -> bool
51  val gtu     : t -> t -> bool
52  val ge      : t -> t -> bool
53  val geu     : t -> t -> bool
54  val neg     : t -> t
55  val lognot  : t -> t
56  val logand  : t -> t -> t
57  val logor   : t -> t -> t
58  val logxor  : t -> t -> t
59  val shl     : t -> t -> t
60  val shr     : t -> t -> t
61  val shrl    : t -> t -> t
62  val max     : t -> t -> t
63  val maxu    : t -> t -> t
64  val min     : t -> t -> t
65  val minu    : t -> t -> t
66  val cast    : int_repr -> t
67  val of_int  : int -> t
68  val to_int  : t -> int
[486]69
[619]70  (** [zero_ext n a] performs zero extension on [a] where [n] bits are
71      significant. *)
72  val zero_ext : int -> t -> t
73  (** [sign_ext n a] performs sign extension on [a] where [n] bits are
74      significant. *)
75  val sign_ext : int -> t -> t
76
[486]77  (** [break i n] cuts [i] in [n] parts. In the resulting list, the first
78      element is the high bits, and the last is the low bits. *)
79  val break : t -> int -> t list
80  (** [merge l] creates the integer where the first element of [l] is its
81      high bits, etc, and the last element of [l] is its low bits. *)
82  val merge : t list -> t
83
84end
85
[619]86(** The functor to create bounded integers from a size. *)
[486]87
88module Make: functor (IntType: INTTYPE) -> S
89
[619]90module Int8  : S
91module Int16 : S
92module Int32 : S
93
94type int8  = Int8.t
95type int16 = Int16.t
96type int32 = Int32.t
97
98
99(*
[486]100module Int8s   : S
101module Int8u   : S
102module Int16s  : S
103module Int16u  : S
104module Int32   : S
105
106(** Unbounded integers. *)
107module Integer : S
108
109type int8s   = Int8s.t
110type int8u   = Int8u.t
111type int16s  = Int16s.t
112type int16u  = Int16u.t
113type int32   = Int32.t
114type integer = Integer.t
[619]115*)
Note: See TracBrowser for help on using the repository browser.