summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpu/Makefile25
-rw-r--r--cpu/alu.ml16
-rw-r--r--cpu/cpu.ml8
-rw-r--r--cpu/netlist_ast.ml42
-rw-r--r--cpu/netlist_gen.ml1941
-rw-r--r--cpu/netlist_gen.mli115
-rw-r--r--cpu/netlist_proc.ml178
7 files changed, 2325 insertions, 0 deletions
diff --git a/cpu/Makefile b/cpu/Makefile
new file mode 100644
index 0000000..e2ef7a8
--- /dev/null
+++ b/cpu/Makefile
@@ -0,0 +1,25 @@
+.SECONDARY:
+
+GENERATOR=netlist_ast.ml netlist_gen.ml netlist_gen.mli netlist_proc.ml
+AUXILLARY=alu.ml
+
+SCHED=../sched/main.byte
+SIM=../csim/csim
+
+%.sim: _build/%.dumb
+ $(SIM) $<
+
+_build/%.dumb _build/%.snet _build/%_opt.dumb _build/%_opt.snet: _build/%.net
+ $(SCHED) $<
+
+_build/%.net: _build/%.byte
+ ./$< > $@
+
+_build/%.byte: $(GENERATOR) $(AUXILLARY) %.ml
+ ocamlbuild `basename $@`
+ # remove stupid symbolic link
+ rm `basename $@`
+
+
+clean:
+ rm -rf _build
diff --git a/cpu/alu.ml b/cpu/alu.ml
new file mode 100644
index 0000000..0a0c00f
--- /dev/null
+++ b/cpu/alu.ml
@@ -0,0 +1,16 @@
+open Netlist_gen
+
+let fulladder a b c =
+ let s = a ^^ b ^^ c in
+ let r = (a ^& b) ^| ((a ^^ b) ^& c) in
+ s, r
+
+let rec nadder n a b c_in =
+ if n = 1 then fulladder a b c_in
+ else
+ let s_n, c_n1 = fulladder (a ** 0) (b ** 0) c_in in
+ let s_n1, c_out = nadder (n-1) (a % (1, n-1)) (b % (1, n-1)) c_n1 in
+ s_n ++ s_n1, c_out
+
+
+
diff --git a/cpu/cpu.ml b/cpu/cpu.ml
new file mode 100644
index 0000000..10e7bc4
--- /dev/null
+++ b/cpu/cpu.ml
@@ -0,0 +1,8 @@
+open Netlist_gen
+
+(* Dumb CPU that just does an 8-bit addition *)
+
+let p =
+main_2_2 (fun a b -> Alu.nadder 8 a b (value "0")) 8 8
+
+let () = Netlist_proc.print stdout p
diff --git a/cpu/netlist_ast.ml b/cpu/netlist_ast.ml
new file mode 100644
index 0000000..1866ed3
--- /dev/null
+++ b/cpu/netlist_ast.ml
@@ -0,0 +1,42 @@
+type ident = string
+
+module Env = struct
+ include Map.Make(struct
+ type t = ident
+ let compare = compare
+ end)
+
+ let of_list l =
+ List.fold_left (fun env (x, ty) -> add x ty env) empty l
+end
+
+type ty = int (* just one for a bit... *)
+type value = bool array
+
+type binop = Or | Xor | And | Nand
+
+type arg =
+ | Avar of ident
+ | Aconst of value
+
+type exp =
+ | Earg of arg
+ | Ereg of ident
+ | Enot of arg
+ | Ebinop of binop * arg * arg
+ | Emux of arg * arg * arg
+ | Erom of int (*addr size*) * int (*word size*) * arg (*read_addr*)
+ | Eram of int (*addr size*) * int (*word size*)
+ * arg (*read_addr*) * arg (*write_enable*)
+ * arg (*write_addr*) * arg (*data*)
+ | Econcat of arg * arg
+ | Eslice of int * int * arg
+ | Eselect of int * arg
+
+type equation = ident * exp
+
+type program =
+ { p_eqs : equation list;
+ p_inputs : ident list;
+ p_outputs : ident list;
+ p_vars : ty Env.t; }
diff --git a/cpu/netlist_gen.ml b/cpu/netlist_gen.ml
new file mode 100644
index 0000000..4eabf25
--- /dev/null
+++ b/cpu/netlist_gen.ml
@@ -0,0 +1,1941 @@
+open Netlist_ast
+
+include Netlist_proc
+
+type t = calc ref
+
+let main_0_1 circuit =
+ let eqs = [] in
+ let vars = Idm.empty in
+ let o_1 = circuit in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ match arg_1 with
+ | Avar id_1 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [];
+ p_outputs = [id_1] }
+ | _ -> failwith "constant output"
+
+let main_0_2 circuit =
+ let eqs = [] in
+ let vars = Idm.empty in
+ let o_1,o_2 = circuit in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ match arg_1,arg_2 with
+ | Avar id_1,Avar id_2 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [];
+ p_outputs = [id_1;id_2] }
+ | _ -> failwith "constant output"
+
+let main_0_3 circuit =
+ let eqs = [] in
+ let vars = Idm.empty in
+ let o_1,o_2,o_3 = circuit in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ match arg_1,arg_2,arg_3 with
+ | Avar id_1,Avar id_2,Avar id_3 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [];
+ p_outputs = [id_1;id_2;id_3] }
+ | _ -> failwith "constant output"
+
+let main_0_4 circuit =
+ let eqs = [] in
+ let vars = Idm.empty in
+ let o_1,o_2,o_3,o_4 = circuit in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ match arg_1,arg_2,arg_3,arg_4 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [];
+ p_outputs = [id_1;id_2;id_3;id_4] }
+ | _ -> failwith "constant output"
+
+let main_0_5 circuit =
+ let eqs = [] in
+ let vars = Idm.empty in
+ let o_1,o_2,o_3,o_4,o_5 = circuit in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5] }
+ | _ -> failwith "constant output"
+
+let main_0_6 circuit =
+ let eqs = [] in
+ let vars = Idm.empty in
+ let o_1,o_2,o_3,o_4,o_5,o_6 = circuit in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6] }
+ | _ -> failwith "constant output"
+
+let main_0_7 circuit =
+ let eqs = [] in
+ let vars = Idm.empty in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7 = circuit in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7] }
+ | _ -> failwith "constant output"
+
+let main_0_8 circuit =
+ let eqs = [] in
+ let vars = Idm.empty in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8 = circuit in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ let arg_8,_,eqs,vars = calc eqs vars o_8 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7,arg_8 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7,Avar id_8 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7;id_8] }
+ | _ -> failwith "constant output"
+
+let main_0_9 circuit =
+ let eqs = [] in
+ let vars = Idm.empty in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8,o_9 = circuit in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ let arg_8,_,eqs,vars = calc eqs vars o_8 in
+ let arg_9,_,eqs,vars = calc eqs vars o_9 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7,arg_8,arg_9 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7,Avar id_8,Avar id_9 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7;id_8;id_9] }
+ | _ -> failwith "constant output"
+
+let main_1_1 circuit t_1 =
+ let i_1 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_1 t_1 (Idm.empty) in
+ let o_1 = circuit (ref (Id (i_1,t_1))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ match arg_1 with
+ | Avar id_1 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1];
+ p_outputs = [id_1] }
+ | _ -> failwith "constant output"
+
+let main_1_2 circuit t_1 =
+ let i_1 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_1 t_1 (Idm.empty) in
+ let o_1,o_2 = circuit (ref (Id (i_1,t_1))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ match arg_1,arg_2 with
+ | Avar id_1,Avar id_2 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1];
+ p_outputs = [id_1;id_2] }
+ | _ -> failwith "constant output"
+
+let main_1_3 circuit t_1 =
+ let i_1 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_1 t_1 (Idm.empty) in
+ let o_1,o_2,o_3 = circuit (ref (Id (i_1,t_1))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ match arg_1,arg_2,arg_3 with
+ | Avar id_1,Avar id_2,Avar id_3 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1];
+ p_outputs = [id_1;id_2;id_3] }
+ | _ -> failwith "constant output"
+
+let main_1_4 circuit t_1 =
+ let i_1 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_1 t_1 (Idm.empty) in
+ let o_1,o_2,o_3,o_4 = circuit (ref (Id (i_1,t_1))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ match arg_1,arg_2,arg_3,arg_4 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1];
+ p_outputs = [id_1;id_2;id_3;id_4] }
+ | _ -> failwith "constant output"
+
+let main_1_5 circuit t_1 =
+ let i_1 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_1 t_1 (Idm.empty) in
+ let o_1,o_2,o_3,o_4,o_5 = circuit (ref (Id (i_1,t_1))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5] }
+ | _ -> failwith "constant output"
+
+let main_1_6 circuit t_1 =
+ let i_1 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_1 t_1 (Idm.empty) in
+ let o_1,o_2,o_3,o_4,o_5,o_6 = circuit (ref (Id (i_1,t_1))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6] }
+ | _ -> failwith "constant output"
+
+let main_1_7 circuit t_1 =
+ let i_1 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_1 t_1 (Idm.empty) in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7 = circuit (ref (Id (i_1,t_1))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7] }
+ | _ -> failwith "constant output"
+
+let main_1_8 circuit t_1 =
+ let i_1 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_1 t_1 (Idm.empty) in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8 = circuit (ref (Id (i_1,t_1))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ let arg_8,_,eqs,vars = calc eqs vars o_8 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7,arg_8 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7,Avar id_8 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7;id_8] }
+ | _ -> failwith "constant output"
+
+let main_1_9 circuit t_1 =
+ let i_1 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_1 t_1 (Idm.empty) in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8,o_9 = circuit (ref (Id (i_1,t_1))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ let arg_8,_,eqs,vars = calc eqs vars o_8 in
+ let arg_9,_,eqs,vars = calc eqs vars o_9 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7,arg_8,arg_9 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7,Avar id_8,Avar id_9 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7;id_8;id_9] }
+ | _ -> failwith "constant output"
+
+let main_2_1 circuit t_1 t_2 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)) in
+ let o_1 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ match arg_1 with
+ | Avar id_1 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2];
+ p_outputs = [id_1] }
+ | _ -> failwith "constant output"
+
+let main_2_2 circuit t_1 t_2 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)) in
+ let o_1,o_2 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ match arg_1,arg_2 with
+ | Avar id_1,Avar id_2 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2];
+ p_outputs = [id_1;id_2] }
+ | _ -> failwith "constant output"
+
+let main_2_3 circuit t_1 t_2 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)) in
+ let o_1,o_2,o_3 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ match arg_1,arg_2,arg_3 with
+ | Avar id_1,Avar id_2,Avar id_3 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2];
+ p_outputs = [id_1;id_2;id_3] }
+ | _ -> failwith "constant output"
+
+let main_2_4 circuit t_1 t_2 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)) in
+ let o_1,o_2,o_3,o_4 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ match arg_1,arg_2,arg_3,arg_4 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2];
+ p_outputs = [id_1;id_2;id_3;id_4] }
+ | _ -> failwith "constant output"
+
+let main_2_5 circuit t_1 t_2 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)) in
+ let o_1,o_2,o_3,o_4,o_5 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5] }
+ | _ -> failwith "constant output"
+
+let main_2_6 circuit t_1 t_2 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)) in
+ let o_1,o_2,o_3,o_4,o_5,o_6 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6] }
+ | _ -> failwith "constant output"
+
+let main_2_7 circuit t_1 t_2 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)) in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7] }
+ | _ -> failwith "constant output"
+
+let main_2_8 circuit t_1 t_2 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)) in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ let arg_8,_,eqs,vars = calc eqs vars o_8 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7,arg_8 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7,Avar id_8 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7;id_8] }
+ | _ -> failwith "constant output"
+
+let main_2_9 circuit t_1 t_2 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)) in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8,o_9 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ let arg_8,_,eqs,vars = calc eqs vars o_8 in
+ let arg_9,_,eqs,vars = calc eqs vars o_9 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7,arg_8,arg_9 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7,Avar id_8,Avar id_9 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7;id_8;id_9] }
+ | _ -> failwith "constant output"
+
+let main_3_1 circuit t_1 t_2 t_3 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))) in
+ let o_1 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ match arg_1 with
+ | Avar id_1 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3];
+ p_outputs = [id_1] }
+ | _ -> failwith "constant output"
+
+let main_3_2 circuit t_1 t_2 t_3 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))) in
+ let o_1,o_2 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ match arg_1,arg_2 with
+ | Avar id_1,Avar id_2 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3];
+ p_outputs = [id_1;id_2] }
+ | _ -> failwith "constant output"
+
+let main_3_3 circuit t_1 t_2 t_3 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))) in
+ let o_1,o_2,o_3 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ match arg_1,arg_2,arg_3 with
+ | Avar id_1,Avar id_2,Avar id_3 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3];
+ p_outputs = [id_1;id_2;id_3] }
+ | _ -> failwith "constant output"
+
+let main_3_4 circuit t_1 t_2 t_3 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))) in
+ let o_1,o_2,o_3,o_4 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ match arg_1,arg_2,arg_3,arg_4 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3];
+ p_outputs = [id_1;id_2;id_3;id_4] }
+ | _ -> failwith "constant output"
+
+let main_3_5 circuit t_1 t_2 t_3 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))) in
+ let o_1,o_2,o_3,o_4,o_5 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5] }
+ | _ -> failwith "constant output"
+
+let main_3_6 circuit t_1 t_2 t_3 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))) in
+ let o_1,o_2,o_3,o_4,o_5,o_6 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6] }
+ | _ -> failwith "constant output"
+
+let main_3_7 circuit t_1 t_2 t_3 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))) in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7] }
+ | _ -> failwith "constant output"
+
+let main_3_8 circuit t_1 t_2 t_3 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))) in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ let arg_8,_,eqs,vars = calc eqs vars o_8 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7,arg_8 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7,Avar id_8 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7;id_8] }
+ | _ -> failwith "constant output"
+
+let main_3_9 circuit t_1 t_2 t_3 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))) in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8,o_9 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ let arg_8,_,eqs,vars = calc eqs vars o_8 in
+ let arg_9,_,eqs,vars = calc eqs vars o_9 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7,arg_8,arg_9 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7,Avar id_8,Avar id_9 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7;id_8;id_9] }
+ | _ -> failwith "constant output"
+
+let main_4_1 circuit t_1 t_2 t_3 t_4 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)))) in
+ let o_1 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ match arg_1 with
+ | Avar id_1 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4];
+ p_outputs = [id_1] }
+ | _ -> failwith "constant output"
+
+let main_4_2 circuit t_1 t_2 t_3 t_4 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)))) in
+ let o_1,o_2 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ match arg_1,arg_2 with
+ | Avar id_1,Avar id_2 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4];
+ p_outputs = [id_1;id_2] }
+ | _ -> failwith "constant output"
+
+let main_4_3 circuit t_1 t_2 t_3 t_4 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)))) in
+ let o_1,o_2,o_3 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ match arg_1,arg_2,arg_3 with
+ | Avar id_1,Avar id_2,Avar id_3 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4];
+ p_outputs = [id_1;id_2;id_3] }
+ | _ -> failwith "constant output"
+
+let main_4_4 circuit t_1 t_2 t_3 t_4 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)))) in
+ let o_1,o_2,o_3,o_4 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ match arg_1,arg_2,arg_3,arg_4 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4];
+ p_outputs = [id_1;id_2;id_3;id_4] }
+ | _ -> failwith "constant output"
+
+let main_4_5 circuit t_1 t_2 t_3 t_4 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)))) in
+ let o_1,o_2,o_3,o_4,o_5 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5] }
+ | _ -> failwith "constant output"
+
+let main_4_6 circuit t_1 t_2 t_3 t_4 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)))) in
+ let o_1,o_2,o_3,o_4,o_5,o_6 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6] }
+ | _ -> failwith "constant output"
+
+let main_4_7 circuit t_1 t_2 t_3 t_4 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)))) in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7] }
+ | _ -> failwith "constant output"
+
+let main_4_8 circuit t_1 t_2 t_3 t_4 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)))) in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ let arg_8,_,eqs,vars = calc eqs vars o_8 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7,arg_8 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7,Avar id_8 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7;id_8] }
+ | _ -> failwith "constant output"
+
+let main_4_9 circuit t_1 t_2 t_3 t_4 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)))) in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8,o_9 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ let arg_8,_,eqs,vars = calc eqs vars o_8 in
+ let arg_9,_,eqs,vars = calc eqs vars o_9 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7,arg_8,arg_9 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7,Avar id_8,Avar id_9 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7;id_8;id_9] }
+ | _ -> failwith "constant output"
+
+let main_5_1 circuit t_1 t_2 t_3 t_4 t_5 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))))) in
+ let o_1 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ match arg_1 with
+ | Avar id_1 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5];
+ p_outputs = [id_1] }
+ | _ -> failwith "constant output"
+
+let main_5_2 circuit t_1 t_2 t_3 t_4 t_5 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))))) in
+ let o_1,o_2 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ match arg_1,arg_2 with
+ | Avar id_1,Avar id_2 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5];
+ p_outputs = [id_1;id_2] }
+ | _ -> failwith "constant output"
+
+let main_5_3 circuit t_1 t_2 t_3 t_4 t_5 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))))) in
+ let o_1,o_2,o_3 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ match arg_1,arg_2,arg_3 with
+ | Avar id_1,Avar id_2,Avar id_3 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5];
+ p_outputs = [id_1;id_2;id_3] }
+ | _ -> failwith "constant output"
+
+let main_5_4 circuit t_1 t_2 t_3 t_4 t_5 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))))) in
+ let o_1,o_2,o_3,o_4 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ match arg_1,arg_2,arg_3,arg_4 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5];
+ p_outputs = [id_1;id_2;id_3;id_4] }
+ | _ -> failwith "constant output"
+
+let main_5_5 circuit t_1 t_2 t_3 t_4 t_5 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))))) in
+ let o_1,o_2,o_3,o_4,o_5 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5] }
+ | _ -> failwith "constant output"
+
+let main_5_6 circuit t_1 t_2 t_3 t_4 t_5 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))))) in
+ let o_1,o_2,o_3,o_4,o_5,o_6 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6] }
+ | _ -> failwith "constant output"
+
+let main_5_7 circuit t_1 t_2 t_3 t_4 t_5 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))))) in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7] }
+ | _ -> failwith "constant output"
+
+let main_5_8 circuit t_1 t_2 t_3 t_4 t_5 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))))) in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ let arg_8,_,eqs,vars = calc eqs vars o_8 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7,arg_8 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7,Avar id_8 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7;id_8] }
+ | _ -> failwith "constant output"
+
+let main_5_9 circuit t_1 t_2 t_3 t_4 t_5 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))))) in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8,o_9 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ let arg_8,_,eqs,vars = calc eqs vars o_8 in
+ let arg_9,_,eqs,vars = calc eqs vars o_9 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7,arg_8,arg_9 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7,Avar id_8,Avar id_9 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7;id_8;id_9] }
+ | _ -> failwith "constant output"
+
+let main_6_1 circuit t_1 t_2 t_3 t_4 t_5 t_6 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)))))) in
+ let o_1 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ match arg_1 with
+ | Avar id_1 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6];
+ p_outputs = [id_1] }
+ | _ -> failwith "constant output"
+
+let main_6_2 circuit t_1 t_2 t_3 t_4 t_5 t_6 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)))))) in
+ let o_1,o_2 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ match arg_1,arg_2 with
+ | Avar id_1,Avar id_2 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6];
+ p_outputs = [id_1;id_2] }
+ | _ -> failwith "constant output"
+
+let main_6_3 circuit t_1 t_2 t_3 t_4 t_5 t_6 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)))))) in
+ let o_1,o_2,o_3 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ match arg_1,arg_2,arg_3 with
+ | Avar id_1,Avar id_2,Avar id_3 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6];
+ p_outputs = [id_1;id_2;id_3] }
+ | _ -> failwith "constant output"
+
+let main_6_4 circuit t_1 t_2 t_3 t_4 t_5 t_6 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)))))) in
+ let o_1,o_2,o_3,o_4 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ match arg_1,arg_2,arg_3,arg_4 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6];
+ p_outputs = [id_1;id_2;id_3;id_4] }
+ | _ -> failwith "constant output"
+
+let main_6_5 circuit t_1 t_2 t_3 t_4 t_5 t_6 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)))))) in
+ let o_1,o_2,o_3,o_4,o_5 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5] }
+ | _ -> failwith "constant output"
+
+let main_6_6 circuit t_1 t_2 t_3 t_4 t_5 t_6 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)))))) in
+ let o_1,o_2,o_3,o_4,o_5,o_6 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6] }
+ | _ -> failwith "constant output"
+
+let main_6_7 circuit t_1 t_2 t_3 t_4 t_5 t_6 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)))))) in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7] }
+ | _ -> failwith "constant output"
+
+let main_6_8 circuit t_1 t_2 t_3 t_4 t_5 t_6 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)))))) in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ let arg_8,_,eqs,vars = calc eqs vars o_8 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7,arg_8 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7,Avar id_8 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7;id_8] }
+ | _ -> failwith "constant output"
+
+let main_6_9 circuit t_1 t_2 t_3 t_4 t_5 t_6 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)))))) in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8,o_9 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ let arg_8,_,eqs,vars = calc eqs vars o_8 in
+ let arg_9,_,eqs,vars = calc eqs vars o_9 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7,arg_8,arg_9 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7,Avar id_8,Avar id_9 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7;id_8;id_9] }
+ | _ -> failwith "constant output"
+
+let main_7_1 circuit t_1 t_2 t_3 t_4 t_5 t_6 t_7 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let i_7 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_7 t_7 (Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))))))) in
+ let o_1 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) (ref (Id (i_7,t_7))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ match arg_1 with
+ | Avar id_1 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6;i_7];
+ p_outputs = [id_1] }
+ | _ -> failwith "constant output"
+
+let main_7_2 circuit t_1 t_2 t_3 t_4 t_5 t_6 t_7 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let i_7 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_7 t_7 (Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))))))) in
+ let o_1,o_2 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) (ref (Id (i_7,t_7))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ match arg_1,arg_2 with
+ | Avar id_1,Avar id_2 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6;i_7];
+ p_outputs = [id_1;id_2] }
+ | _ -> failwith "constant output"
+
+let main_7_3 circuit t_1 t_2 t_3 t_4 t_5 t_6 t_7 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let i_7 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_7 t_7 (Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))))))) in
+ let o_1,o_2,o_3 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) (ref (Id (i_7,t_7))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ match arg_1,arg_2,arg_3 with
+ | Avar id_1,Avar id_2,Avar id_3 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6;i_7];
+ p_outputs = [id_1;id_2;id_3] }
+ | _ -> failwith "constant output"
+
+let main_7_4 circuit t_1 t_2 t_3 t_4 t_5 t_6 t_7 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let i_7 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_7 t_7 (Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))))))) in
+ let o_1,o_2,o_3,o_4 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) (ref (Id (i_7,t_7))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ match arg_1,arg_2,arg_3,arg_4 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6;i_7];
+ p_outputs = [id_1;id_2;id_3;id_4] }
+ | _ -> failwith "constant output"
+
+let main_7_5 circuit t_1 t_2 t_3 t_4 t_5 t_6 t_7 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let i_7 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_7 t_7 (Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))))))) in
+ let o_1,o_2,o_3,o_4,o_5 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) (ref (Id (i_7,t_7))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6;i_7];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5] }
+ | _ -> failwith "constant output"
+
+let main_7_6 circuit t_1 t_2 t_3 t_4 t_5 t_6 t_7 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let i_7 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_7 t_7 (Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))))))) in
+ let o_1,o_2,o_3,o_4,o_5,o_6 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) (ref (Id (i_7,t_7))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6;i_7];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6] }
+ | _ -> failwith "constant output"
+
+let main_7_7 circuit t_1 t_2 t_3 t_4 t_5 t_6 t_7 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let i_7 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_7 t_7 (Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))))))) in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) (ref (Id (i_7,t_7))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6;i_7];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7] }
+ | _ -> failwith "constant output"
+
+let main_7_8 circuit t_1 t_2 t_3 t_4 t_5 t_6 t_7 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let i_7 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_7 t_7 (Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))))))) in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) (ref (Id (i_7,t_7))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ let arg_8,_,eqs,vars = calc eqs vars o_8 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7,arg_8 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7,Avar id_8 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6;i_7];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7;id_8] }
+ | _ -> failwith "constant output"
+
+let main_7_9 circuit t_1 t_2 t_3 t_4 t_5 t_6 t_7 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let i_7 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_7 t_7 (Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))))))) in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8,o_9 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) (ref (Id (i_7,t_7))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ let arg_8,_,eqs,vars = calc eqs vars o_8 in
+ let arg_9,_,eqs,vars = calc eqs vars o_9 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7,arg_8,arg_9 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7,Avar id_8,Avar id_9 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6;i_7];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7;id_8;id_9] }
+ | _ -> failwith "constant output"
+
+let main_8_1 circuit t_1 t_2 t_3 t_4 t_5 t_6 t_7 t_8 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let i_7 = id "" in
+ let i_8 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_8 t_8 (Idm.add i_7 t_7 (Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)))))))) in
+ let o_1 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) (ref (Id (i_7,t_7))) (ref (Id (i_8,t_8))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ match arg_1 with
+ | Avar id_1 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6;i_7;i_8];
+ p_outputs = [id_1] }
+ | _ -> failwith "constant output"
+
+let main_8_2 circuit t_1 t_2 t_3 t_4 t_5 t_6 t_7 t_8 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let i_7 = id "" in
+ let i_8 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_8 t_8 (Idm.add i_7 t_7 (Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)))))))) in
+ let o_1,o_2 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) (ref (Id (i_7,t_7))) (ref (Id (i_8,t_8))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ match arg_1,arg_2 with
+ | Avar id_1,Avar id_2 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6;i_7;i_8];
+ p_outputs = [id_1;id_2] }
+ | _ -> failwith "constant output"
+
+let main_8_3 circuit t_1 t_2 t_3 t_4 t_5 t_6 t_7 t_8 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let i_7 = id "" in
+ let i_8 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_8 t_8 (Idm.add i_7 t_7 (Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)))))))) in
+ let o_1,o_2,o_3 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) (ref (Id (i_7,t_7))) (ref (Id (i_8,t_8))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ match arg_1,arg_2,arg_3 with
+ | Avar id_1,Avar id_2,Avar id_3 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6;i_7;i_8];
+ p_outputs = [id_1;id_2;id_3] }
+ | _ -> failwith "constant output"
+
+let main_8_4 circuit t_1 t_2 t_3 t_4 t_5 t_6 t_7 t_8 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let i_7 = id "" in
+ let i_8 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_8 t_8 (Idm.add i_7 t_7 (Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)))))))) in
+ let o_1,o_2,o_3,o_4 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) (ref (Id (i_7,t_7))) (ref (Id (i_8,t_8))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ match arg_1,arg_2,arg_3,arg_4 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6;i_7;i_8];
+ p_outputs = [id_1;id_2;id_3;id_4] }
+ | _ -> failwith "constant output"
+
+let main_8_5 circuit t_1 t_2 t_3 t_4 t_5 t_6 t_7 t_8 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let i_7 = id "" in
+ let i_8 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_8 t_8 (Idm.add i_7 t_7 (Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)))))))) in
+ let o_1,o_2,o_3,o_4,o_5 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) (ref (Id (i_7,t_7))) (ref (Id (i_8,t_8))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6;i_7;i_8];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5] }
+ | _ -> failwith "constant output"
+
+let main_8_6 circuit t_1 t_2 t_3 t_4 t_5 t_6 t_7 t_8 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let i_7 = id "" in
+ let i_8 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_8 t_8 (Idm.add i_7 t_7 (Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)))))))) in
+ let o_1,o_2,o_3,o_4,o_5,o_6 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) (ref (Id (i_7,t_7))) (ref (Id (i_8,t_8))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6;i_7;i_8];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6] }
+ | _ -> failwith "constant output"
+
+let main_8_7 circuit t_1 t_2 t_3 t_4 t_5 t_6 t_7 t_8 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let i_7 = id "" in
+ let i_8 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_8 t_8 (Idm.add i_7 t_7 (Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)))))))) in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) (ref (Id (i_7,t_7))) (ref (Id (i_8,t_8))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6;i_7;i_8];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7] }
+ | _ -> failwith "constant output"
+
+let main_8_8 circuit t_1 t_2 t_3 t_4 t_5 t_6 t_7 t_8 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let i_7 = id "" in
+ let i_8 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_8 t_8 (Idm.add i_7 t_7 (Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)))))))) in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) (ref (Id (i_7,t_7))) (ref (Id (i_8,t_8))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ let arg_8,_,eqs,vars = calc eqs vars o_8 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7,arg_8 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7,Avar id_8 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6;i_7;i_8];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7;id_8] }
+ | _ -> failwith "constant output"
+
+let main_8_9 circuit t_1 t_2 t_3 t_4 t_5 t_6 t_7 t_8 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let i_7 = id "" in
+ let i_8 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_8 t_8 (Idm.add i_7 t_7 (Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty)))))))) in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8,o_9 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) (ref (Id (i_7,t_7))) (ref (Id (i_8,t_8))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ let arg_8,_,eqs,vars = calc eqs vars o_8 in
+ let arg_9,_,eqs,vars = calc eqs vars o_9 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7,arg_8,arg_9 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7,Avar id_8,Avar id_9 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6;i_7;i_8];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7;id_8;id_9] }
+ | _ -> failwith "constant output"
+
+let main_9_1 circuit t_1 t_2 t_3 t_4 t_5 t_6 t_7 t_8 t_9 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let i_7 = id "" in
+ let i_8 = id "" in
+ let i_9 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_9 t_9 (Idm.add i_8 t_8 (Idm.add i_7 t_7 (Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))))))))) in
+ let o_1 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) (ref (Id (i_7,t_7))) (ref (Id (i_8,t_8))) (ref (Id (i_9,t_9))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ match arg_1 with
+ | Avar id_1 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6;i_7;i_8;i_9];
+ p_outputs = [id_1] }
+ | _ -> failwith "constant output"
+
+let main_9_2 circuit t_1 t_2 t_3 t_4 t_5 t_6 t_7 t_8 t_9 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let i_7 = id "" in
+ let i_8 = id "" in
+ let i_9 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_9 t_9 (Idm.add i_8 t_8 (Idm.add i_7 t_7 (Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))))))))) in
+ let o_1,o_2 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) (ref (Id (i_7,t_7))) (ref (Id (i_8,t_8))) (ref (Id (i_9,t_9))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ match arg_1,arg_2 with
+ | Avar id_1,Avar id_2 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6;i_7;i_8;i_9];
+ p_outputs = [id_1;id_2] }
+ | _ -> failwith "constant output"
+
+let main_9_3 circuit t_1 t_2 t_3 t_4 t_5 t_6 t_7 t_8 t_9 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let i_7 = id "" in
+ let i_8 = id "" in
+ let i_9 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_9 t_9 (Idm.add i_8 t_8 (Idm.add i_7 t_7 (Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))))))))) in
+ let o_1,o_2,o_3 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) (ref (Id (i_7,t_7))) (ref (Id (i_8,t_8))) (ref (Id (i_9,t_9))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ match arg_1,arg_2,arg_3 with
+ | Avar id_1,Avar id_2,Avar id_3 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6;i_7;i_8;i_9];
+ p_outputs = [id_1;id_2;id_3] }
+ | _ -> failwith "constant output"
+
+let main_9_4 circuit t_1 t_2 t_3 t_4 t_5 t_6 t_7 t_8 t_9 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let i_7 = id "" in
+ let i_8 = id "" in
+ let i_9 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_9 t_9 (Idm.add i_8 t_8 (Idm.add i_7 t_7 (Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))))))))) in
+ let o_1,o_2,o_3,o_4 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) (ref (Id (i_7,t_7))) (ref (Id (i_8,t_8))) (ref (Id (i_9,t_9))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ match arg_1,arg_2,arg_3,arg_4 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6;i_7;i_8;i_9];
+ p_outputs = [id_1;id_2;id_3;id_4] }
+ | _ -> failwith "constant output"
+
+let main_9_5 circuit t_1 t_2 t_3 t_4 t_5 t_6 t_7 t_8 t_9 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let i_7 = id "" in
+ let i_8 = id "" in
+ let i_9 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_9 t_9 (Idm.add i_8 t_8 (Idm.add i_7 t_7 (Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))))))))) in
+ let o_1,o_2,o_3,o_4,o_5 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) (ref (Id (i_7,t_7))) (ref (Id (i_8,t_8))) (ref (Id (i_9,t_9))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6;i_7;i_8;i_9];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5] }
+ | _ -> failwith "constant output"
+
+let main_9_6 circuit t_1 t_2 t_3 t_4 t_5 t_6 t_7 t_8 t_9 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let i_7 = id "" in
+ let i_8 = id "" in
+ let i_9 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_9 t_9 (Idm.add i_8 t_8 (Idm.add i_7 t_7 (Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))))))))) in
+ let o_1,o_2,o_3,o_4,o_5,o_6 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) (ref (Id (i_7,t_7))) (ref (Id (i_8,t_8))) (ref (Id (i_9,t_9))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6;i_7;i_8;i_9];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6] }
+ | _ -> failwith "constant output"
+
+let main_9_7 circuit t_1 t_2 t_3 t_4 t_5 t_6 t_7 t_8 t_9 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let i_7 = id "" in
+ let i_8 = id "" in
+ let i_9 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_9 t_9 (Idm.add i_8 t_8 (Idm.add i_7 t_7 (Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))))))))) in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) (ref (Id (i_7,t_7))) (ref (Id (i_8,t_8))) (ref (Id (i_9,t_9))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6;i_7;i_8;i_9];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7] }
+ | _ -> failwith "constant output"
+
+let main_9_8 circuit t_1 t_2 t_3 t_4 t_5 t_6 t_7 t_8 t_9 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let i_7 = id "" in
+ let i_8 = id "" in
+ let i_9 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_9 t_9 (Idm.add i_8 t_8 (Idm.add i_7 t_7 (Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))))))))) in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) (ref (Id (i_7,t_7))) (ref (Id (i_8,t_8))) (ref (Id (i_9,t_9))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ let arg_8,_,eqs,vars = calc eqs vars o_8 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7,arg_8 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7,Avar id_8 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6;i_7;i_8;i_9];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7;id_8] }
+ | _ -> failwith "constant output"
+
+let main_9_9 circuit t_1 t_2 t_3 t_4 t_5 t_6 t_7 t_8 t_9 =
+ let i_1 = id "" in
+ let i_2 = id "" in
+ let i_3 = id "" in
+ let i_4 = id "" in
+ let i_5 = id "" in
+ let i_6 = id "" in
+ let i_7 = id "" in
+ let i_8 = id "" in
+ let i_9 = id "" in
+ let eqs = [] in
+ let vars = Idm.add i_9 t_9 (Idm.add i_8 t_8 (Idm.add i_7 t_7 (Idm.add i_6 t_6 (Idm.add i_5 t_5 (Idm.add i_4 t_4 (Idm.add i_3 t_3 (Idm.add i_2 t_2 (Idm.add i_1 t_1 (Idm.empty))))))))) in
+ let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8,o_9 = circuit (ref (Id (i_1,t_1))) (ref (Id (i_2,t_2))) (ref (Id (i_3,t_3))) (ref (Id (i_4,t_4))) (ref (Id (i_5,t_5))) (ref (Id (i_6,t_6))) (ref (Id (i_7,t_7))) (ref (Id (i_8,t_8))) (ref (Id (i_9,t_9))) in
+ let arg_1,_,eqs,vars = calc eqs vars o_1 in
+ let arg_2,_,eqs,vars = calc eqs vars o_2 in
+ let arg_3,_,eqs,vars = calc eqs vars o_3 in
+ let arg_4,_,eqs,vars = calc eqs vars o_4 in
+ let arg_5,_,eqs,vars = calc eqs vars o_5 in
+ let arg_6,_,eqs,vars = calc eqs vars o_6 in
+ let arg_7,_,eqs,vars = calc eqs vars o_7 in
+ let arg_8,_,eqs,vars = calc eqs vars o_8 in
+ let arg_9,_,eqs,vars = calc eqs vars o_9 in
+ match arg_1,arg_2,arg_3,arg_4,arg_5,arg_6,arg_7,arg_8,arg_9 with
+ | Avar id_1,Avar id_2,Avar id_3,Avar id_4,Avar id_5,Avar id_6,Avar id_7,Avar id_8,Avar id_9 -> {
+ p_eqs = eqs;
+ p_vars = vars;
+ p_inputs = [i_1;i_2;i_3;i_4;i_5;i_6;i_7;i_8;i_9];
+ p_outputs = [id_1;id_2;id_3;id_4;id_5;id_6;id_7;id_8;id_9] }
+ | _ -> failwith "constant output"
+
diff --git a/cpu/netlist_gen.mli b/cpu/netlist_gen.mli
new file mode 100644
index 0000000..9dd7b62
--- /dev/null
+++ b/cpu/netlist_gen.mli
@@ -0,0 +1,115 @@
+type t
+
+val print : out_channel -> Netlist_ast.program -> unit
+
+val value : string -> t
+
+val ( ++ ) : t -> t -> t (* concat *)
+
+val ( ^| ) : t -> t -> t (* or *)
+val ( ^^ ) : t -> t -> t (* xor *)
+val ( ^& ) : t -> t -> t (* and *)
+val ( ^$ ) : t -> t -> t (* nand *)
+
+val not : t -> t
+
+val mux : t -> t -> t -> t
+
+val ( ** ) : t -> int -> t (* select *)
+
+val ( % ) : t -> int * int -> t (* slice *)
+
+val rom : string -> int -> int -> t -> t
+
+val ram : int -> int -> t -> t -> t -> t -> t
+
+val main_0_1 : t -> Netlist_ast.program
+val main_0_2 : t * t -> Netlist_ast.program
+val main_0_3 : t * t * t -> Netlist_ast.program
+val main_0_4 : t * t * t * t -> Netlist_ast.program
+val main_0_5 : t * t * t * t * t -> Netlist_ast.program
+val main_0_6 : t * t * t * t * t * t -> Netlist_ast.program
+val main_0_7 : t * t * t * t * t * t * t -> Netlist_ast.program
+val main_0_8 : t * t * t * t * t * t * t * t -> Netlist_ast.program
+val main_0_9 : t * t * t * t * t * t * t * t * t -> Netlist_ast.program
+val main_1_1 : (t -> t ) -> int -> Netlist_ast.program
+val main_1_2 : (t -> t * t ) -> int -> Netlist_ast.program
+val main_1_3 : (t -> t * t * t ) -> int -> Netlist_ast.program
+val main_1_4 : (t -> t * t * t * t ) -> int -> Netlist_ast.program
+val main_1_5 : (t -> t * t * t * t * t ) -> int -> Netlist_ast.program
+val main_1_6 : (t -> t * t * t * t * t * t ) -> int -> Netlist_ast.program
+val main_1_7 : (t -> t * t * t * t * t * t * t ) -> int -> Netlist_ast.program
+val main_1_8 : (t -> t * t * t * t * t * t * t * t ) -> int -> Netlist_ast.program
+val main_1_9 : (t -> t * t * t * t * t * t * t * t * t ) -> int -> Netlist_ast.program
+val main_2_1 : (t -> t -> t ) -> int -> int -> Netlist_ast.program
+val main_2_2 : (t -> t -> t * t ) -> int -> int -> Netlist_ast.program
+val main_2_3 : (t -> t -> t * t * t ) -> int -> int -> Netlist_ast.program
+val main_2_4 : (t -> t -> t * t * t * t ) -> int -> int -> Netlist_ast.program
+val main_2_5 : (t -> t -> t * t * t * t * t ) -> int -> int -> Netlist_ast.program
+val main_2_6 : (t -> t -> t * t * t * t * t * t ) -> int -> int -> Netlist_ast.program
+val main_2_7 : (t -> t -> t * t * t * t * t * t * t ) -> int -> int -> Netlist_ast.program
+val main_2_8 : (t -> t -> t * t * t * t * t * t * t * t ) -> int -> int -> Netlist_ast.program
+val main_2_9 : (t -> t -> t * t * t * t * t * t * t * t * t ) -> int -> int -> Netlist_ast.program
+val main_3_1 : (t -> t -> t -> t ) -> int -> int -> int -> Netlist_ast.program
+val main_3_2 : (t -> t -> t -> t * t ) -> int -> int -> int -> Netlist_ast.program
+val main_3_3 : (t -> t -> t -> t * t * t ) -> int -> int -> int -> Netlist_ast.program
+val main_3_4 : (t -> t -> t -> t * t * t * t ) -> int -> int -> int -> Netlist_ast.program
+val main_3_5 : (t -> t -> t -> t * t * t * t * t ) -> int -> int -> int -> Netlist_ast.program
+val main_3_6 : (t -> t -> t -> t * t * t * t * t * t ) -> int -> int -> int -> Netlist_ast.program
+val main_3_7 : (t -> t -> t -> t * t * t * t * t * t * t ) -> int -> int -> int -> Netlist_ast.program
+val main_3_8 : (t -> t -> t -> t * t * t * t * t * t * t * t ) -> int -> int -> int -> Netlist_ast.program
+val main_3_9 : (t -> t -> t -> t * t * t * t * t * t * t * t * t ) -> int -> int -> int -> Netlist_ast.program
+val main_4_1 : (t -> t -> t -> t -> t ) -> int -> int -> int -> int -> Netlist_ast.program
+val main_4_2 : (t -> t -> t -> t -> t * t ) -> int -> int -> int -> int -> Netlist_ast.program
+val main_4_3 : (t -> t -> t -> t -> t * t * t ) -> int -> int -> int -> int -> Netlist_ast.program
+val main_4_4 : (t -> t -> t -> t -> t * t * t * t ) -> int -> int -> int -> int -> Netlist_ast.program
+val main_4_5 : (t -> t -> t -> t -> t * t * t * t * t ) -> int -> int -> int -> int -> Netlist_ast.program
+val main_4_6 : (t -> t -> t -> t -> t * t * t * t * t * t ) -> int -> int -> int -> int -> Netlist_ast.program
+val main_4_7 : (t -> t -> t -> t -> t * t * t * t * t * t * t ) -> int -> int -> int -> int -> Netlist_ast.program
+val main_4_8 : (t -> t -> t -> t -> t * t * t * t * t * t * t * t ) -> int -> int -> int -> int -> Netlist_ast.program
+val main_4_9 : (t -> t -> t -> t -> t * t * t * t * t * t * t * t * t ) -> int -> int -> int -> int -> Netlist_ast.program
+val main_5_1 : (t -> t -> t -> t -> t -> t ) -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_5_2 : (t -> t -> t -> t -> t -> t * t ) -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_5_3 : (t -> t -> t -> t -> t -> t * t * t ) -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_5_4 : (t -> t -> t -> t -> t -> t * t * t * t ) -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_5_5 : (t -> t -> t -> t -> t -> t * t * t * t * t ) -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_5_6 : (t -> t -> t -> t -> t -> t * t * t * t * t * t ) -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_5_7 : (t -> t -> t -> t -> t -> t * t * t * t * t * t * t ) -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_5_8 : (t -> t -> t -> t -> t -> t * t * t * t * t * t * t * t ) -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_5_9 : (t -> t -> t -> t -> t -> t * t * t * t * t * t * t * t * t ) -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_6_1 : (t -> t -> t -> t -> t -> t -> t ) -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_6_2 : (t -> t -> t -> t -> t -> t -> t * t ) -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_6_3 : (t -> t -> t -> t -> t -> t -> t * t * t ) -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_6_4 : (t -> t -> t -> t -> t -> t -> t * t * t * t ) -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_6_5 : (t -> t -> t -> t -> t -> t -> t * t * t * t * t ) -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_6_6 : (t -> t -> t -> t -> t -> t -> t * t * t * t * t * t ) -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_6_7 : (t -> t -> t -> t -> t -> t -> t * t * t * t * t * t * t ) -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_6_8 : (t -> t -> t -> t -> t -> t -> t * t * t * t * t * t * t * t ) -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_6_9 : (t -> t -> t -> t -> t -> t -> t * t * t * t * t * t * t * t * t ) -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_7_1 : (t -> t -> t -> t -> t -> t -> t -> t ) -> int -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_7_2 : (t -> t -> t -> t -> t -> t -> t -> t * t ) -> int -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_7_3 : (t -> t -> t -> t -> t -> t -> t -> t * t * t ) -> int -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_7_4 : (t -> t -> t -> t -> t -> t -> t -> t * t * t * t ) -> int -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_7_5 : (t -> t -> t -> t -> t -> t -> t -> t * t * t * t * t ) -> int -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_7_6 : (t -> t -> t -> t -> t -> t -> t -> t * t * t * t * t * t ) -> int -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_7_7 : (t -> t -> t -> t -> t -> t -> t -> t * t * t * t * t * t * t ) -> int -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_7_8 : (t -> t -> t -> t -> t -> t -> t -> t * t * t * t * t * t * t * t ) -> int -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_7_9 : (t -> t -> t -> t -> t -> t -> t -> t * t * t * t * t * t * t * t * t ) -> int -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_8_1 : (t -> t -> t -> t -> t -> t -> t -> t -> t ) -> int -> int -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_8_2 : (t -> t -> t -> t -> t -> t -> t -> t -> t * t ) -> int -> int -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_8_3 : (t -> t -> t -> t -> t -> t -> t -> t -> t * t * t ) -> int -> int -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_8_4 : (t -> t -> t -> t -> t -> t -> t -> t -> t * t * t * t ) -> int -> int -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_8_5 : (t -> t -> t -> t -> t -> t -> t -> t -> t * t * t * t * t ) -> int -> int -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_8_6 : (t -> t -> t -> t -> t -> t -> t -> t -> t * t * t * t * t * t ) -> int -> int -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_8_7 : (t -> t -> t -> t -> t -> t -> t -> t -> t * t * t * t * t * t * t ) -> int -> int -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_8_8 : (t -> t -> t -> t -> t -> t -> t -> t -> t * t * t * t * t * t * t * t ) -> int -> int -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_8_9 : (t -> t -> t -> t -> t -> t -> t -> t -> t * t * t * t * t * t * t * t * t ) -> int -> int -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_9_1 : (t -> t -> t -> t -> t -> t -> t -> t -> t -> t ) -> int -> int -> int -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_9_2 : (t -> t -> t -> t -> t -> t -> t -> t -> t -> t * t ) -> int -> int -> int -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_9_3 : (t -> t -> t -> t -> t -> t -> t -> t -> t -> t * t * t ) -> int -> int -> int -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_9_4 : (t -> t -> t -> t -> t -> t -> t -> t -> t -> t * t * t * t ) -> int -> int -> int -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_9_5 : (t -> t -> t -> t -> t -> t -> t -> t -> t -> t * t * t * t * t ) -> int -> int -> int -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_9_6 : (t -> t -> t -> t -> t -> t -> t -> t -> t -> t * t * t * t * t * t ) -> int -> int -> int -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_9_7 : (t -> t -> t -> t -> t -> t -> t -> t -> t -> t * t * t * t * t * t * t ) -> int -> int -> int -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_9_8 : (t -> t -> t -> t -> t -> t -> t -> t -> t -> t * t * t * t * t * t * t * t ) -> int -> int -> int -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
+val main_9_9 : (t -> t -> t -> t -> t -> t -> t -> t -> t -> t * t * t * t * t * t * t * t * t ) -> int -> int -> int -> int -> int -> int -> int -> int -> int -> Netlist_ast.program
diff --git a/cpu/netlist_proc.ml b/cpu/netlist_proc.ml
new file mode 100644
index 0000000..99dde22
--- /dev/null
+++ b/cpu/netlist_proc.ml
@@ -0,0 +1,178 @@
+open Netlist_ast
+
+(* module Idm = Map.Make (String) *)
+module Idm = Env
+
+type calc =
+ | Id of (ident * int)
+ | Eq of (equation list -> int Idm.t -> arg * int * equation list * int Idm.t)
+ | Const of (bool array)
+
+let id =
+ let cnt = ref 0 in
+ fun n ->
+ let res = n ^ "_xoxo_" ^ (string_of_int !cnt) in
+ incr cnt; res
+
+let value n =
+ let l = String.length n in
+ ref (Const (Array.init l (fun i -> n.[i] = '1')))
+
+let calc eqs vars e =
+ match !e with
+ | Id (id,t) -> Avar id,t,eqs,vars
+ | Eq c ->
+ let arg,t,eqs,vars = c eqs vars in
+ let () =
+ match arg with
+ | Avar id -> e := Id (id,t)
+ | Aconst v -> e := Const v in
+ arg,t,eqs,vars
+ | Const v -> Aconst v,(Array.length v),eqs,vars
+
+let ( ++ ) a b =
+ ref (Eq (fun eqs vars ->
+ let arga,ta,eqs,vars = calc eqs vars a in
+ let argb,tb,eqs,vars = calc eqs vars b in
+ let res = id "" in
+ Avar res, (ta+tb), (res,Econcat (arga, argb))::eqs, Idm.add res (ta+tb) vars))
+
+let ( ^^ ) a b = ref (Eq (fun eqs vars ->
+ let arga,ta,eqs,vars = calc eqs vars a in
+ let argb,tb,eqs,vars = calc eqs vars b in
+ if ta = tb then
+ let res = id "" in
+ Avar res, (ta), (res,Ebinop (Xor,arga, argb))::eqs, Idm.add res (ta) vars
+ else assert false))
+
+let ( ^| ) a b = ref (Eq (fun eqs vars ->
+ let arga,ta,eqs,vars = calc eqs vars a in
+ let argb,tb,eqs,vars = calc eqs vars b in
+ if ta = tb then
+ let res = id "" in
+ Avar res, (ta), (res,Ebinop (Or,arga, argb))::eqs, Idm.add res (ta) vars
+ else assert false))
+
+let ( ^& ) a b = ref (Eq (fun eqs vars ->
+ let arga,ta,eqs,vars = calc eqs vars a in
+ let argb,tb,eqs,vars = calc eqs vars b in
+ if ta = tb then
+ let res = id "" in
+ Avar res, (ta), (res,Ebinop (And,arga, argb))::eqs, Idm.add res (ta) vars
+ else assert false))
+
+let ( ^$ ) a b = ref (Eq (fun eqs vars ->
+ let arga,ta,eqs,vars = calc eqs vars a in
+ let argb,tb,eqs,vars = calc eqs vars b in
+ if ta = tb then
+ let res = id "" in
+ Avar res, (ta), (res,Ebinop (Nand,arga, argb))::eqs, Idm.add res (ta) vars
+ else assert false))
+
+let not a = ref (Eq (fun eqs vars ->
+ let arga,ta,eqs,vars = calc eqs vars a in
+ let res = id "" in
+ Avar res, ta, (res,Enot arga)::eqs, Idm.add res ta vars))
+
+let mux a b c = ref (Eq (fun eqs vars ->
+ let arga,ta,eqs,vars = calc eqs vars a in
+ let argb,tb,eqs,vars = calc eqs vars b in
+ let argc,tc,eqs,vars = calc eqs vars c in
+ if ta = 1 && tb = tc then
+ let res = id "" in
+ Avar res, tb, (res,Emux (arga,argb,argc))::eqs, Idm.add res tb vars
+ else assert false))
+
+let ( ** ) a n = ref (Eq (fun eqs vars ->
+ let arga,ta,eqs,vars = calc eqs vars a in
+ if n >= ta then assert false
+ else if ta = 1 then arga,ta,eqs,vars
+ else let res = id "" in
+ Avar res, 1, (res,Eselect (n,arga))::eqs, Idm.add res 1 vars))
+
+let ( % ) a (i,j) = ref (Eq (fun eqs vars ->
+ let arga,ta,eqs,vars = calc eqs vars a in
+ if j > ta then assert false
+ else if i > j then assert false
+ else if j-i+1 = ta then arga,ta,eqs,vars
+ else let res = id "" in
+ Avar res, (j-i+1), (res,Eslice (i,j,arga))::eqs, Idm.add res (j-i+1) vars))
+
+let rom name a_s w_s a = ref (Eq (fun eqs vars ->
+ let arga,ta,eqs,vars = calc eqs vars a in
+ if ta = a_s && w_s > 0 then
+ let res = id name in
+ Avar res, w_s, (res,Erom (a_s,w_s,arga))::eqs, Idm.add res w_s vars
+ else assert false))
+
+let ram a_s w_s ra we wa d = ref (Eq (fun eqs vars ->
+ let argra,tra,eqs,vars = calc eqs vars ra in
+ let argwe,twe,eqs,vars = calc eqs vars we in
+ let argwa,twa,eqs,vars = calc eqs vars wa in
+ let argd,td,eqs,vars = calc eqs vars d in
+ if tra = a_s && twa = a_s && td = w_s && twe = 1 then
+ let res = id "" in
+ Avar res, w_s, (res,Eram (a_s,w_s,argra,argwe,argwa,argd))::eqs, Idm.add res w_s vars
+ else assert false))
+
+let init_string n f =
+ let s = String.make n 'a' in
+ for i = 0 to n - 1 do
+ s.[i] <- f i
+ done;
+ s
+
+(* value to string *)
+let vts bits =
+ init_string (Array.length bits) (fun i ->
+ if bits.(i) then '1' else '0')
+
+(* argument to string *)
+let ats = function
+ | Avar id -> id
+ | Aconst n -> vts n
+
+let s_op = function
+ | Or -> "OR"
+ | Xor -> "XOR"
+ | And -> "AND"
+ | Nand -> "NAND"
+
+let print oc p =
+ let print_eq oc (s,e) =
+ let s_e =
+ match e with
+ | Earg a -> ats a
+ | Ereg s -> "REG " ^ s
+ | Enot a -> "NOT " ^ (ats a)
+ | Ebinop (b,a1,a2) -> (s_op b) ^ " " ^ (ats a1) ^ " " ^ (ats a2)
+ | Emux (a1,a2,a3) ->
+ "MUX " ^ (ats a1) ^ " " ^ (ats a2) ^ " " ^ (ats a3)
+ | Erom (n1,n2,a3) ->
+ "ROM " ^ (string_of_int n1) ^ " " ^ (string_of_int n2) ^
+ " " ^ (ats a3)
+ | Eram (n1,n2,a3,a4,a5,a6) ->
+ "RAM " ^ (string_of_int n1) ^ " " ^ (string_of_int n2) ^
+ " " ^ (ats a3) ^ " " ^ (ats a4) ^ " " ^ (ats a5) ^
+ " " ^ (ats a6)
+ | Econcat (a1,a2) -> "CONCAT " ^ (ats a1) ^ " " ^ (ats a2)
+ | Eslice (n1,n2,a3) -> "SLICE " ^ (string_of_int n1) ^ " " ^
+ (string_of_int n2) ^ " " ^ (ats a3)
+ | Eselect (n,a) -> "SELECT " ^ (string_of_int n) ^ " " ^ (ats a) in
+ Printf.fprintf oc "%s = %s\n" s s_e in
+ Printf.fprintf oc "INPUT ";
+ if p.p_inputs <> [] then
+ (Printf.fprintf oc "%s" (List.hd p.p_inputs); List.iter
+ (Printf.fprintf oc ", %s") (List.tl p.p_inputs));
+ Printf.fprintf oc "\nOUTPUT ";
+ if p.p_outputs <> [] then
+ (Printf.fprintf oc "%s" (List.hd p.p_outputs); List.iter
+ (Printf.fprintf oc ", %s") (List.tl p.p_outputs));
+ Printf.fprintf oc "\nVAR ";
+ let stts s t = if t = 1 then s else s ^ " : " ^ (string_of_int t) in
+ ignore (Idm.fold (fun s t b ->
+ if b then Printf.fprintf oc "%s" (stts s t)
+ else Printf.fprintf oc ", %s" (stts s t);
+ false) p.p_vars true);
+ Printf.fprintf oc "\nIN\n";
+ List.iter (print_eq oc) p.p_eqs