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

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

32 and 16 bits operations support in D2.2/8051

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