-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaiger.mli
137 lines (102 loc) · 3.5 KB
/
aiger.mli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
(*
* Copyright 2014 Romain Brenguier
* Author: Romain Brenguier <[email protected]>
*
* This file is part of Ocaml-aiger.
*
* Ocaml-aiger is a free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*)
(** An OCaml library for AIGER files *)
(** type for literals *)
type lit
(** type for variables *)
type var
val aiger_false : lit
val aiger_true : lit
val sign : lit -> bool
val strip : lit -> lit
val aiger_not : lit -> lit
val var2lit : var -> lit
val var2int : var -> int
val lit2var : lit -> var
val lit2int : lit -> int
val int2lit : int -> lit
val int2var : int -> var
module Symbol :
sig
type t = string * (int option)
val to_string : t -> string
val of_string : string -> t
end
module SymbolMap : Map.S with type key = Symbol.t
module LitMap : Map.S with type key = lit
type t = {
maxvar:int;
num_inputs:int;
num_latches:int;
num_outputs:int;
num_ands:int;
inputs:lit list;
latches:(lit*lit) list;
outputs:lit list;
ands: (lit*lit*lit) list;
comments:string list;
symbols: lit SymbolMap.t;
abstract : Symbol.t LitMap.t;
}
val read : in_channel -> t
val read_from_file : string -> t
val write : t -> out_channel -> unit
val write_to_file : t -> string -> unit
val empty : t
val new_var : t -> (t * var)
exception AlreadyExists
val add_input : t -> lit -> Symbol.t -> t
(** [add_latch aiger lit next name] *)
val add_latch : t -> lit -> lit -> Symbol.t -> t
val add_output : t -> lit -> Symbol.t -> t
(** [add_and aiger lhs rhs0 rhs1] *)
val add_and : t -> lit -> lit -> lit -> t
val add_comment : t -> string -> t
(** remove an output *)
val hide : t -> Symbol.t -> t
val full_hide : t -> string -> t
val nth_input : t -> int -> lit
val nth_output : t -> int -> lit
val nth_latch : t -> int -> (lit * lit)
(** These function may raise [Not_found] *)
val lit2string : t -> lit -> string
val lit2symbol : t -> lit -> Symbol.t
val symbol2lit : t -> Symbol.t -> lit
(** Give an array containing all the literals encoding the given name.
For example, for an integer "i" encoded on two bits, [name_to_literals a "i"] will return the literals corresponding to "i<0>" and "i<1>".
*)
val name_to_literals : t -> string -> lit array
(** Gives the number of literal encoding the variable with the given name. *)
val size_symbol : t -> string -> int
(** List of names used as symbols. *)
val names : t -> string list
val inputs : t -> string list
val outputs : t -> string list
val latches : t -> string list
type tag = Constant of bool | Input of lit | Latch of (lit*lit) | And of (lit*lit*lit) | Output of lit
val lit2tag : t -> lit -> tag
(** Rename variables of the aiger file according to the correspondance given in the list *)
val rename : t -> (Symbol.t * Symbol.t) list -> t
val full_rename : t -> (string * string) list -> t
(** Merge 2 aiger files where symbols with the same name are merged.
They are identified by their name in the comments.
*)
val compose : t -> t -> t
(** Reduce the size of the AIG by merging gates with same definition *)
val reduce : t -> t