diff options
Diffstat (limited to 'cpu')
-rw-r--r-- | cpu/Makefile | 8 | ||||
-rw-r--r-- | cpu/cpu.ml | 18 | ||||
-rw-r--r-- | cpu/netlist_gen.ml | 3402 | ||||
-rw-r--r-- | cpu/netlist_gen.mli | 104 | ||||
-rw-r--r-- | cpu/netlist_proc.ml | 241 |
5 files changed, 276 insertions, 3497 deletions
diff --git a/cpu/Makefile b/cpu/Makefile index e2ef7a8..74bfbae 100644 --- a/cpu/Makefile +++ b/cpu/Makefile @@ -1,21 +1,23 @@ .SECONDARY: -GENERATOR=netlist_ast.ml netlist_gen.ml netlist_gen.mli netlist_proc.ml +GENERATOR=netlist_ast.ml netlist_gen.ml netlist_gen.mli AUXILLARY=alu.ml SCHED=../sched/main.byte SIM=../csim/csim +all: cpu_opt.sim + %.sim: _build/%.dumb $(SIM) $< _build/%.dumb _build/%.snet _build/%_opt.dumb _build/%_opt.snet: _build/%.net $(SCHED) $< -_build/%.net: _build/%.byte +_build/%.net: _build/%.native ./$< > $@ -_build/%.byte: $(GENERATOR) $(AUXILLARY) %.ml +_build/%.native: $(GENERATOR) $(AUXILLARY) %.ml ocamlbuild `basename $@` # remove stupid symbolic link rm `basename $@` @@ -3,13 +3,17 @@ open Netlist_gen (* Dumb CPU that just does an 8-bit addition *) let sumz n i = - let rec res = - let aux = reg n in - fun () -> fst (Alu.nadder n i (aux res) (value "0")) () - in - res + let x, set_x = loop n in + let r = reg n x in + let o1, o2 = Alu.nadder n i r (const "0") in + set_x o1, o2 let p = - main_1_1 (sumz 8) 8 + let width = 16 in + let sum, r = sumz width (get "in") in + program + [ "in", width ] + [ "out", width, sum; + "r", 1, r ] -let () = Netlist_proc.print stdout p +let () = Netlist_gen.print stdout p diff --git a/cpu/netlist_gen.ml b/cpu/netlist_gen.ml index 3e40e0f..f721997 100644 --- a/cpu/netlist_gen.ml +++ b/cpu/netlist_gen.ml @@ -1,3156 +1,250 @@ open Netlist_ast -include Netlist_proc - -type t = calc - -let main_0_1 circuit = - let eqs = [] in - let vars = Idm.empty in - let o_1 = circuit in - let arg_1,_,eqs,vars = calc Iset.empty 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 Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty 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 Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty 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 Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty 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 Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty 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 Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty 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 Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty 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 Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty eqs vars o_7 in - let arg_8,_,eqs,vars = calc Iset.empty 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 Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty eqs vars o_7 in - let arg_8,_,eqs,vars = calc Iset.empty eqs vars o_8 in - let arg_9,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let o_1 = circuit val_1 in - let arg_1,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let o_1,o_2 = circuit val_1 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let o_1,o_2,o_3 = circuit val_1 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let o_1,o_2,o_3,o_4 = circuit val_1 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let o_1,o_2,o_3,o_4,o_5 = circuit val_1 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let o_1,o_2,o_3,o_4,o_5,o_6 = circuit val_1 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let o_1,o_2,o_3,o_4,o_5,o_6,o_7 = circuit val_1 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8 = circuit val_1 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty eqs vars o_7 in - let arg_8,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8,o_9 = circuit val_1 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty eqs vars o_7 in - let arg_8,_,eqs,vars = calc Iset.empty eqs vars o_8 in - let arg_9,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let o_1 = circuit val_1 val_2 in - let arg_1,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let o_1,o_2 = circuit val_1 val_2 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let o_1,o_2,o_3 = circuit val_1 val_2 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let o_1,o_2,o_3,o_4 = circuit val_1 val_2 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let o_1,o_2,o_3,o_4,o_5 = circuit val_1 val_2 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let o_1,o_2,o_3,o_4,o_5,o_6 = circuit val_1 val_2 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let o_1,o_2,o_3,o_4,o_5,o_6,o_7 = circuit val_1 val_2 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8 = circuit val_1 val_2 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty eqs vars o_7 in - let arg_8,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8,o_9 = circuit val_1 val_2 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty eqs vars o_7 in - let arg_8,_,eqs,vars = calc Iset.empty eqs vars o_8 in - let arg_9,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let o_1 = circuit val_1 val_2 val_3 in - let arg_1,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let o_1,o_2 = circuit val_1 val_2 val_3 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let o_1,o_2,o_3 = circuit val_1 val_2 val_3 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let o_1,o_2,o_3,o_4 = circuit val_1 val_2 val_3 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let o_1,o_2,o_3,o_4,o_5 = circuit val_1 val_2 val_3 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let o_1,o_2,o_3,o_4,o_5,o_6 = circuit val_1 val_2 val_3 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let o_1,o_2,o_3,o_4,o_5,o_6,o_7 = circuit val_1 val_2 val_3 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8 = circuit val_1 val_2 val_3 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty eqs vars o_7 in - let arg_8,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8,o_9 = circuit val_1 val_2 val_3 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty eqs vars o_7 in - let arg_8,_,eqs,vars = calc Iset.empty eqs vars o_8 in - let arg_9,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let o_1 = circuit val_1 val_2 val_3 val_4 in - let arg_1,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let o_1,o_2 = circuit val_1 val_2 val_3 val_4 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let o_1,o_2,o_3 = circuit val_1 val_2 val_3 val_4 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let o_1,o_2,o_3,o_4 = circuit val_1 val_2 val_3 val_4 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let o_1,o_2,o_3,o_4,o_5 = circuit val_1 val_2 val_3 val_4 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let o_1,o_2,o_3,o_4,o_5,o_6 = circuit val_1 val_2 val_3 val_4 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let o_1,o_2,o_3,o_4,o_5,o_6,o_7 = circuit val_1 val_2 val_3 val_4 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8 = circuit val_1 val_2 val_3 val_4 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty eqs vars o_7 in - let arg_8,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8,o_9 = circuit val_1 val_2 val_3 val_4 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty eqs vars o_7 in - let arg_8,_,eqs,vars = calc Iset.empty eqs vars o_8 in - let arg_9,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let o_1 = circuit val_1 val_2 val_3 val_4 val_5 in - let arg_1,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let o_1,o_2 = circuit val_1 val_2 val_3 val_4 val_5 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let o_1,o_2,o_3 = circuit val_1 val_2 val_3 val_4 val_5 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let o_1,o_2,o_3,o_4 = circuit val_1 val_2 val_3 val_4 val_5 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let o_1,o_2,o_3,o_4,o_5 = circuit val_1 val_2 val_3 val_4 val_5 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let o_1,o_2,o_3,o_4,o_5,o_6 = circuit val_1 val_2 val_3 val_4 val_5 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let o_1,o_2,o_3,o_4,o_5,o_6,o_7 = circuit val_1 val_2 val_3 val_4 val_5 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8 = circuit val_1 val_2 val_3 val_4 val_5 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty eqs vars o_7 in - let arg_8,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8,o_9 = circuit val_1 val_2 val_3 val_4 val_5 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty eqs vars o_7 in - let arg_8,_,eqs,vars = calc Iset.empty eqs vars o_8 in - let arg_9,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let o_1 = circuit val_1 val_2 val_3 val_4 val_5 val_6 in - let arg_1,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let o_1,o_2 = circuit val_1 val_2 val_3 val_4 val_5 val_6 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let o_1,o_2,o_3 = circuit val_1 val_2 val_3 val_4 val_5 val_6 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let o_1,o_2,o_3,o_4 = circuit val_1 val_2 val_3 val_4 val_5 val_6 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let o_1,o_2,o_3,o_4,o_5 = circuit val_1 val_2 val_3 val_4 val_5 val_6 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let o_1,o_2,o_3,o_4,o_5,o_6 = circuit val_1 val_2 val_3 val_4 val_5 val_6 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let o_1,o_2,o_3,o_4,o_5,o_6,o_7 = circuit val_1 val_2 val_3 val_4 val_5 val_6 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8 = circuit val_1 val_2 val_3 val_4 val_5 val_6 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty eqs vars o_7 in - let arg_8,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8,o_9 = circuit val_1 val_2 val_3 val_4 val_5 val_6 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty eqs vars o_7 in - let arg_8,_,eqs,vars = calc Iset.empty eqs vars o_8 in - let arg_9,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let val_7 = - let res_7 = ref (Arg (Avar i_7,t_7)) in - fun () -> res_7 in - let o_1 = circuit val_1 val_2 val_3 val_4 val_5 val_6 val_7 in - let arg_1,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let val_7 = - let res_7 = ref (Arg (Avar i_7,t_7)) in - fun () -> res_7 in - let o_1,o_2 = circuit val_1 val_2 val_3 val_4 val_5 val_6 val_7 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let val_7 = - let res_7 = ref (Arg (Avar i_7,t_7)) in - fun () -> res_7 in - let o_1,o_2,o_3 = circuit val_1 val_2 val_3 val_4 val_5 val_6 val_7 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let val_7 = - let res_7 = ref (Arg (Avar i_7,t_7)) in - fun () -> res_7 in - let o_1,o_2,o_3,o_4 = circuit val_1 val_2 val_3 val_4 val_5 val_6 val_7 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let val_7 = - let res_7 = ref (Arg (Avar i_7,t_7)) in - fun () -> res_7 in - let o_1,o_2,o_3,o_4,o_5 = circuit val_1 val_2 val_3 val_4 val_5 val_6 val_7 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let val_7 = - let res_7 = ref (Arg (Avar i_7,t_7)) in - fun () -> res_7 in - let o_1,o_2,o_3,o_4,o_5,o_6 = circuit val_1 val_2 val_3 val_4 val_5 val_6 val_7 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let val_7 = - let res_7 = ref (Arg (Avar i_7,t_7)) in - fun () -> res_7 in - let o_1,o_2,o_3,o_4,o_5,o_6,o_7 = circuit val_1 val_2 val_3 val_4 val_5 val_6 val_7 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let val_7 = - let res_7 = ref (Arg (Avar i_7,t_7)) in - fun () -> res_7 in - let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8 = circuit val_1 val_2 val_3 val_4 val_5 val_6 val_7 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty eqs vars o_7 in - let arg_8,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let val_7 = - let res_7 = ref (Arg (Avar i_7,t_7)) in - fun () -> res_7 in - let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8,o_9 = circuit val_1 val_2 val_3 val_4 val_5 val_6 val_7 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty eqs vars o_7 in - let arg_8,_,eqs,vars = calc Iset.empty eqs vars o_8 in - let arg_9,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let val_7 = - let res_7 = ref (Arg (Avar i_7,t_7)) in - fun () -> res_7 in - let val_8 = - let res_8 = ref (Arg (Avar i_8,t_8)) in - fun () -> res_8 in - let o_1 = circuit val_1 val_2 val_3 val_4 val_5 val_6 val_7 val_8 in - let arg_1,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let val_7 = - let res_7 = ref (Arg (Avar i_7,t_7)) in - fun () -> res_7 in - let val_8 = - let res_8 = ref (Arg (Avar i_8,t_8)) in - fun () -> res_8 in - let o_1,o_2 = circuit val_1 val_2 val_3 val_4 val_5 val_6 val_7 val_8 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let val_7 = - let res_7 = ref (Arg (Avar i_7,t_7)) in - fun () -> res_7 in - let val_8 = - let res_8 = ref (Arg (Avar i_8,t_8)) in - fun () -> res_8 in - let o_1,o_2,o_3 = circuit val_1 val_2 val_3 val_4 val_5 val_6 val_7 val_8 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let val_7 = - let res_7 = ref (Arg (Avar i_7,t_7)) in - fun () -> res_7 in - let val_8 = - let res_8 = ref (Arg (Avar i_8,t_8)) in - fun () -> res_8 in - let o_1,o_2,o_3,o_4 = circuit val_1 val_2 val_3 val_4 val_5 val_6 val_7 val_8 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let val_7 = - let res_7 = ref (Arg (Avar i_7,t_7)) in - fun () -> res_7 in - let val_8 = - let res_8 = ref (Arg (Avar i_8,t_8)) in - fun () -> res_8 in - let o_1,o_2,o_3,o_4,o_5 = circuit val_1 val_2 val_3 val_4 val_5 val_6 val_7 val_8 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let val_7 = - let res_7 = ref (Arg (Avar i_7,t_7)) in - fun () -> res_7 in - let val_8 = - let res_8 = ref (Arg (Avar i_8,t_8)) in - fun () -> res_8 in - let o_1,o_2,o_3,o_4,o_5,o_6 = circuit val_1 val_2 val_3 val_4 val_5 val_6 val_7 val_8 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let val_7 = - let res_7 = ref (Arg (Avar i_7,t_7)) in - fun () -> res_7 in - let val_8 = - let res_8 = ref (Arg (Avar i_8,t_8)) in - fun () -> res_8 in - let o_1,o_2,o_3,o_4,o_5,o_6,o_7 = circuit val_1 val_2 val_3 val_4 val_5 val_6 val_7 val_8 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let val_7 = - let res_7 = ref (Arg (Avar i_7,t_7)) in - fun () -> res_7 in - let val_8 = - let res_8 = ref (Arg (Avar i_8,t_8)) in - fun () -> res_8 in - let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8 = circuit val_1 val_2 val_3 val_4 val_5 val_6 val_7 val_8 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty eqs vars o_7 in - let arg_8,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let val_7 = - let res_7 = ref (Arg (Avar i_7,t_7)) in - fun () -> res_7 in - let val_8 = - let res_8 = ref (Arg (Avar i_8,t_8)) in - fun () -> res_8 in - let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8,o_9 = circuit val_1 val_2 val_3 val_4 val_5 val_6 val_7 val_8 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty eqs vars o_7 in - let arg_8,_,eqs,vars = calc Iset.empty eqs vars o_8 in - let arg_9,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let val_7 = - let res_7 = ref (Arg (Avar i_7,t_7)) in - fun () -> res_7 in - let val_8 = - let res_8 = ref (Arg (Avar i_8,t_8)) in - fun () -> res_8 in - let val_9 = - let res_9 = ref (Arg (Avar i_9,t_9)) in - fun () -> res_9 in - let o_1 = circuit val_1 val_2 val_3 val_4 val_5 val_6 val_7 val_8 val_9 in - let arg_1,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let val_7 = - let res_7 = ref (Arg (Avar i_7,t_7)) in - fun () -> res_7 in - let val_8 = - let res_8 = ref (Arg (Avar i_8,t_8)) in - fun () -> res_8 in - let val_9 = - let res_9 = ref (Arg (Avar i_9,t_9)) in - fun () -> res_9 in - let o_1,o_2 = circuit val_1 val_2 val_3 val_4 val_5 val_6 val_7 val_8 val_9 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let val_7 = - let res_7 = ref (Arg (Avar i_7,t_7)) in - fun () -> res_7 in - let val_8 = - let res_8 = ref (Arg (Avar i_8,t_8)) in - fun () -> res_8 in - let val_9 = - let res_9 = ref (Arg (Avar i_9,t_9)) in - fun () -> res_9 in - let o_1,o_2,o_3 = circuit val_1 val_2 val_3 val_4 val_5 val_6 val_7 val_8 val_9 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let val_7 = - let res_7 = ref (Arg (Avar i_7,t_7)) in - fun () -> res_7 in - let val_8 = - let res_8 = ref (Arg (Avar i_8,t_8)) in - fun () -> res_8 in - let val_9 = - let res_9 = ref (Arg (Avar i_9,t_9)) in - fun () -> res_9 in - let o_1,o_2,o_3,o_4 = circuit val_1 val_2 val_3 val_4 val_5 val_6 val_7 val_8 val_9 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let val_7 = - let res_7 = ref (Arg (Avar i_7,t_7)) in - fun () -> res_7 in - let val_8 = - let res_8 = ref (Arg (Avar i_8,t_8)) in - fun () -> res_8 in - let val_9 = - let res_9 = ref (Arg (Avar i_9,t_9)) in - fun () -> res_9 in - let o_1,o_2,o_3,o_4,o_5 = circuit val_1 val_2 val_3 val_4 val_5 val_6 val_7 val_8 val_9 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let val_7 = - let res_7 = ref (Arg (Avar i_7,t_7)) in - fun () -> res_7 in - let val_8 = - let res_8 = ref (Arg (Avar i_8,t_8)) in - fun () -> res_8 in - let val_9 = - let res_9 = ref (Arg (Avar i_9,t_9)) in - fun () -> res_9 in - let o_1,o_2,o_3,o_4,o_5,o_6 = circuit val_1 val_2 val_3 val_4 val_5 val_6 val_7 val_8 val_9 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let val_7 = - let res_7 = ref (Arg (Avar i_7,t_7)) in - fun () -> res_7 in - let val_8 = - let res_8 = ref (Arg (Avar i_8,t_8)) in - fun () -> res_8 in - let val_9 = - let res_9 = ref (Arg (Avar i_9,t_9)) in - fun () -> res_9 in - let o_1,o_2,o_3,o_4,o_5,o_6,o_7 = circuit val_1 val_2 val_3 val_4 val_5 val_6 val_7 val_8 val_9 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let val_7 = - let res_7 = ref (Arg (Avar i_7,t_7)) in - fun () -> res_7 in - let val_8 = - let res_8 = ref (Arg (Avar i_8,t_8)) in - fun () -> res_8 in - let val_9 = - let res_9 = ref (Arg (Avar i_9,t_9)) in - fun () -> res_9 in - let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8 = circuit val_1 val_2 val_3 val_4 val_5 val_6 val_7 val_8 val_9 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty eqs vars o_7 in - let arg_8,_,eqs,vars = calc Iset.empty 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 val_1 = - let res_1 = ref (Arg (Avar i_1,t_1)) in - fun () -> res_1 in - let val_2 = - let res_2 = ref (Arg (Avar i_2,t_2)) in - fun () -> res_2 in - let val_3 = - let res_3 = ref (Arg (Avar i_3,t_3)) in - fun () -> res_3 in - let val_4 = - let res_4 = ref (Arg (Avar i_4,t_4)) in - fun () -> res_4 in - let val_5 = - let res_5 = ref (Arg (Avar i_5,t_5)) in - fun () -> res_5 in - let val_6 = - let res_6 = ref (Arg (Avar i_6,t_6)) in - fun () -> res_6 in - let val_7 = - let res_7 = ref (Arg (Avar i_7,t_7)) in - fun () -> res_7 in - let val_8 = - let res_8 = ref (Arg (Avar i_8,t_8)) in - fun () -> res_8 in - let val_9 = - let res_9 = ref (Arg (Avar i_9,t_9)) in - fun () -> res_9 in - let o_1,o_2,o_3,o_4,o_5,o_6,o_7,o_8,o_9 = circuit val_1 val_2 val_3 val_4 val_5 val_6 val_7 val_8 val_9 in - let arg_1,_,eqs,vars = calc Iset.empty eqs vars o_1 in - let arg_2,_,eqs,vars = calc Iset.empty eqs vars o_2 in - let arg_3,_,eqs,vars = calc Iset.empty eqs vars o_3 in - let arg_4,_,eqs,vars = calc Iset.empty eqs vars o_4 in - let arg_5,_,eqs,vars = calc Iset.empty eqs vars o_5 in - let arg_6,_,eqs,vars = calc Iset.empty eqs vars o_6 in - let arg_7,_,eqs,vars = calc Iset.empty eqs vars o_7 in - let arg_8,_,eqs,vars = calc Iset.empty eqs vars o_8 in - let arg_9,_,eqs,vars = calc Iset.empty 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" - +type t = program -> (arg * program) + +let id = + let cnt = ref 0 in + fun s -> + let res = s ^ "_l_" ^ (string_of_int !cnt) in + incr cnt; res + +let get_size p arg = match arg with + | Avar(id) -> Env.find id p.p_vars + | Aconst(k) -> Array.length k + +let add p id eq size = + assert (not (Env.mem id p.p_vars) + || (Env.find id p.p_vars = size)); + let new_eqs = + if List.mem_assoc id p.p_eqs + then p.p_eqs + else (id, eq)::p.p_eqs + in + { p_eqs = new_eqs; + p_inputs = p.p_inputs; + p_outputs = p.p_outputs; + p_vars = Env.add id size p.p_vars } + +let get id = + fun p -> + assert (Env.mem id p.p_vars); + (Avar id, p) + +let loop s = + let i = id "" in + (fun p -> + (Avar i), + { p_eqs = p.p_eqs; + p_inputs = p.p_inputs; + p_outputs = p.p_outputs; + p_vars = Env.add i s p.p_vars }), + (fun v1 -> + fun p -> + let x, p = v1 p in + (Avar i), add p i (Earg x) s) + +let const n = + let l = String.length n in + let v = Array.init l (fun i -> n.[i] = '1') in + fun p -> + (Aconst v, p) + +let ( ++ ) v1 v2 = + let i = id "" in + fun p -> + let x1, p = v1 p in + let x2, p = v2 p in + let sz1, sz2 = get_size p x1, get_size p x2 in + (Avar i), add p i (Econcat (x1, x2)) (sz1 + sz2) + +let ( ^| ) v1 v2 = + let i = id "" in + fun p -> + let x1, p = v1 p in + let x2, p = v2 p in + let sz = get_size p x1 in + assert (sz = get_size p x2); + (Avar i), add p i (Ebinop (Or, x1, x2)) sz + +let ( ^^ ) v1 v2 = + let i = id "" in + fun p -> + let x1, p = v1 p in + let x2, p = v2 p in + let sz = get_size p x1 in + assert (sz = get_size p x2); + (Avar i), add p i (Ebinop (Xor, x1, x2)) sz + +let ( ^& ) v1 v2 = + let i = id "" in + fun p -> + let x1, p = v1 p in + let x2, p = v2 p in + let sz = get_size p x1 in + assert (sz = get_size p x2); + (Avar i), add p i (Ebinop (And, x1, x2)) sz + +let ( ^$ ) v1 v2 = + let i = id "" in + fun p -> + let x1, p = v1 p in + let x2, p = v2 p in + let sz = get_size p x1 in + assert (sz = get_size p x2); + (Avar i), add p i (Ebinop (Nand, x1, x2)) sz + +let not v1 = + let i = id "" in + fun p -> + let x, p = v1 p in + (Avar i), add p i (Enot (x)) (get_size p x) + +let mux v1 v2 v3 = + let i = id "" in + fun p -> + let x1, p = v1 p in + let x2, p = v2 p in + let x3, p = v3 p in + let sz = get_size p x2 in + assert (get_size p x3 = sz); + assert (get_size p x1 = 1); + (Avar i), add p i (Emux (x1, x2, x3)) sz + +let ( ** ) v s = + let i = id "" in + fun p -> + let x, p = v p in + let sz = get_size p x in + assert (s >= 0 && s < sz); + (Avar i), add p i (Eselect (s, x)) 1 + +let ( % ) v (s1, s2) = + let i = id "" in + fun p -> + let x, p = v p in + let sz = get_size p x in + assert (s1 >= 0 && s2 >= s1 && sz > s2); + (Avar i), add p i (Eslice (s1, s2, x)) (s2 - s1 + 1) + +let rom i a_s w_s ra = + let i = id i in + fun p -> + let ra, p = ra p in + assert ((get_size p ra) = a_s); + (Avar i), add p i (Erom (a_s, w_s, ra)) w_s + +let ram a_s w_s ra we wa d = + let i = id "" in + fun p -> + let ra, p = ra p in + let we, p = we p in + let wa, p = wa p in + let d, p = d p in + assert ((get_size p ra) = a_s); + assert ((get_size p wa) = a_s); + assert ((get_size p we) = 1); + assert ((get_size p d) = w_s); + (Avar i), add p i (Eram (a_s, w_s, ra, we, wa, d)) w_s + + +let reg n v = + let i = id "" in + fun p -> + let v, p = v p in + assert (get_size p v = n); + match v with + | Avar j -> + (Avar i), add p i (Ereg j) n + | Aconst k -> + (Avar i), add p i (Earg v) n + + +let program entries outputs = + let p = + { p_eqs = []; + p_inputs = (List.map fst entries); + p_outputs = []; + p_vars = List.fold_left + (fun k (e, s) -> Env.add e s k) Env.empty entries } + in + let p, outputs = List.fold_left + (fun (p, outputs) (name, size, x) -> + let x, p = x p in + assert (get_size p x = size); + if x = Avar(name) then + p, name::outputs + else if name <> "" then + add p name (Earg x) size, name::outputs + else + p, outputs) + (p, []) outputs + in + { p_inputs = p.p_inputs; + p_eqs = p.p_eqs; + p_vars = p.p_vars; + p_outputs = outputs } + + +(* Netlist printer *) + +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 (Env.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 diff --git a/cpu/netlist_gen.mli b/cpu/netlist_gen.mli index 69a165a..3d40477 100644 --- a/cpu/netlist_gen.mli +++ b/cpu/netlist_gen.mli @@ -1,8 +1,13 @@ -type t = unit -> Netlist_proc.res ref +type t val print : out_channel -> Netlist_ast.program -> unit -val value : string -> t +val id : string -> Netlist_ast.ident + +val get : Netlist_ast.ident -> t +val loop : int -> (t * (t -> t)) + +val const : string -> t val ( ++ ) : t -> t -> t (* concat *) @@ -25,93 +30,8 @@ val ram : int -> int -> t -> t -> t -> t -> t val reg : int -> 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 +val program : + (Netlist_ast.ident * int) list (* liste des entrées : (nom, taille) *) + -> (Netlist_ast.ident * int * t) list (* liste des sorties : (nom de la sortie, taille, equation) *) + -> Netlist_ast.program + diff --git a/cpu/netlist_proc.ml b/cpu/netlist_proc.ml deleted file mode 100644 index ae3acdb..0000000 --- a/cpu/netlist_proc.ml +++ /dev/null @@ -1,241 +0,0 @@ -open Netlist_ast - -(* module Idm = Map.Make (String) *) -module Idm = Env -(*module Imap = Map.Make(struct type t = int let compare = compare end)*) -module Iset = Set.Make (struct type t = int let compare = compare end) - -type res = - | Arg of (arg * int) - | Calc of (Iset.t -> equation list -> int Idm.t -> - arg * int * equation list * int Idm.t) - -type calc = - unit -> res ref - -let id = - let cnt = ref 0 in - fun s -> - let res = s ^ "_xoxo_" ^ (string_of_int !cnt) in - incr cnt; res - -let id2 = - let cnt = ref 0 in - fun () -> - let v = !cnt in incr cnt; v - -let value n = - let l = String.length n in - let v = Array.init l (fun i -> n.[i] = '1') in - let res = ref (Arg (Aconst v,l)) in - fun () -> res - -let calc ids eqs vars e = - let res = e () in - match !res with - | Calc c -> - let a,t,eqs,vars = c ids eqs vars in - ( res := Arg (a,t); a, t, eqs, vars ) - | Arg (a,t) -> a,t,eqs,vars - -(*let calc_rec t ids eqs vars e = - let res,ide = e () in - try let id,_ = Imap.find ide ids in - Avar id, t, eqs, vars, ids - with Not_found -> - match !res with - | Calc c -> - let id = id "" in - let a,t,eqs,vars = c (Imap.add ide (id,t) ids) eqs vars in - ( res := Arg (a,t); a, t, eqs, vars ) - | Arg (a,t) -> a,t,eqs,vars*) - -let ( ++ ) a b = - let res = ref (Calc ( - fun ids eqs vars -> - let arga,ta,eqs,vars = calc ids eqs vars a in - let argb,tb,eqs,vars = calc ids eqs vars b in - let res = id "" in - Avar res, (ta+tb), (res,Econcat (arga, argb))::eqs, - Idm.add res (ta+tb) vars)) in - fun () -> res - -let ( ^^ ) a b = - let res = ref (Calc ( - fun ids eqs vars -> - let arga,ta,eqs,vars = calc ids eqs vars a in - let argb,tb,eqs,vars = calc ids 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)) in - fun () -> res - -let ( ^| ) a b = - let res = ref (Calc ( - fun ids eqs vars -> - let arga,ta,eqs,vars = calc ids eqs vars a in - let argb,tb,eqs,vars = calc ids 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)) in - fun () -> res - -let ( ^& ) a b = - let res = ref (Calc (fun ids eqs vars -> - let arga,ta,eqs,vars = calc ids eqs vars a in - let argb,tb,eqs,vars = calc ids 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)) in - fun () -> res - -let ( ^$ ) a b = - let res = ref (Calc (fun ids eqs vars -> - let arga,ta,eqs,vars = calc ids eqs vars a in - let argb,tb,eqs,vars = calc ids 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)) in - fun () -> res - -let not a = - let res = ref (Calc (fun ids eqs vars -> - let arga,ta,eqs,vars = calc ids eqs vars a in - let res = id "" in - Avar res, ta, (res,Enot arga)::eqs, Idm.add res ta vars)) in - fun () -> res - -let mux a b c = - let res = ref (Calc (fun ids eqs vars -> - let arga,ta,eqs,vars = calc ids eqs vars a in - let argb,tb,eqs,vars = calc ids eqs vars b in - let argc,tc,eqs,vars = calc ids 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)) in - fun () -> res - -let ( ** ) a n = - let res = ref (Calc (fun ids eqs vars -> - let arga,ta,eqs,vars = calc ids 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)) in - fun () -> res - -let ( % ) a (i,j) = - let res = ref (Calc (fun ids eqs vars -> - let arga,ta,eqs,vars = calc ids 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)) in - fun () -> res - -let rom prefix a_s w_s a = - let res = ref (Calc (fun ids eqs vars -> - let arga,ta,eqs,vars = calc ids eqs vars a in - if ta = a_s && w_s > 0 then - let res = id prefix in - Avar res, w_s, (res,Erom (a_s,w_s,arga))::eqs, Idm.add res w_s vars - else assert false)) in - fun () -> res - -let ram a_s w_s ra we wa = - let id2 = id2 () in - let id = id "" in - fun d -> - let res = ref (Calc (fun ids eqs vars -> - if Iset.mem id2 ids then Avar id, w_s, eqs, vars - else let argra,tra,eqs,vars = calc ids eqs vars ra in - let ids = Iset.add id2 ids in - let argwe,twe,eqs,vars = calc ids eqs vars we in - let argwa,twa,eqs,vars = calc ids eqs vars wa in - let argd,td,eqs,vars = calc ids eqs vars d in - if tra = a_s && twa = a_s && td = w_s && twe = 1 then - Avar id, w_s, (id,Eram (a_s,w_s,argra,argwe,argwa,argd))::eqs, Idm.add id w_s vars - else assert false)) in - fun () -> res - -let reg n = - let id2 = id2 () in - let id = id "" in fun a -> - let res = ref (Calc (fun ids eqs vars -> - if Iset.mem id2 ids then Avar id, n, eqs, vars - else let arga,ta,eqs,vars = calc (Iset.add id2 ids) eqs vars a in - if ta = n then - match arga with - | Avar id' -> Avar id, n, (id,Ereg id')::eqs, Idm.add id n vars - | _ -> assert false - else assert false)) in - fun () -> res - -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 |