summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sched/main.ml58
-rw-r--r--sched/simplify.ml13
2 files changed, 37 insertions, 34 deletions
diff --git a/sched/main.ml b/sched/main.ml
index 326a2bd..6da57ad 100644
--- a/sched/main.ml
+++ b/sched/main.ml
@@ -5,35 +5,42 @@ let dumb_down = ref false
let compile filename =
try
+ Format.printf("Reading netlist...%!");
let p = Netlist.read_file filename in
+ Format.printf("done.\n%!");
+
let out_name = (Filename.chop_suffix filename ".net") ^ ".snet" in
- let dumb_out_name = (Filename.chop_suffix filename ".net") ^ ".dumb" in
+ let dumb_out_name = (Filename.chop_suffix filename ".net") ^ ".dumb" in
let out_opt_name = (Filename.chop_suffix filename ".net") ^ "_opt.snet" in
- let dumb_opt_out_name = (Filename.chop_suffix filename ".net") ^ "_opt.dumb" in
- let q, q_opt = ref p, ref p in
+ let dumb_opt_out_name = (Filename.chop_suffix filename ".net") ^ "_opt.dumb" in
+ let q, q_opt = ref p, ref p in
begin try
- q := Scheduler.schedule p;
- q_opt := Simplify.simplify p
- with
- | Scheduler.Combinational_cycle ->
- Format.eprintf "The netlist has a combinatory cycle.@.";
- exit 2;
+ Format.printf("Topological sort on non-simplified netlist...%!");
+ q := Scheduler.schedule p;
+ Format.printf("done.\n%!");
+ Format.printf("Dong simplifications...\n%!");
+ q_opt := Simplify.simplify (!q);
+ Format.printf("Simplifications done.\n%!")
+ with
+ | Scheduler.Combinational_cycle ->
+ Format.eprintf "The netlist has a combinatory cycle.@.";
+ exit 2;
end;
let out = open_out out_name in
Netlist_printer.print_program out !q;
- close_out out;
- let dumb_out = open_out dumb_out_name in
- Netlist_dumb.print_program dumb_out !q;
- close_out dumb_out;
-
- let out_opt = open_out out_opt_name in
- Netlist_printer.print_program out_opt !q_opt;
- close_out out_opt;
- let dumb_opt_out = open_out dumb_opt_out_name in
- Netlist_dumb.print_program dumb_opt_out !q_opt;
- close_out dumb_opt_out;
+ close_out out;
+ let dumb_out = open_out dumb_out_name in
+ Netlist_dumb.print_program dumb_out !q;
+ close_out dumb_out;
+
+ let out_opt = open_out out_opt_name in
+ Netlist_printer.print_program out_opt !q_opt;
+ close_out out_opt;
+ let dumb_opt_out = open_out dumb_opt_out_name in
+ Netlist_dumb.print_program dumb_opt_out !q_opt;
+ close_out dumb_opt_out;
if !simulate then (
let simulator =
@@ -50,11 +57,10 @@ let compile filename =
let main () =
Arg.parse
["-s", Arg.Set simulate, "Launch the simulator";
- "-sim", Arg.Set_string sim_path, "Path to the circuit simulator";
- "-d", Arg.Set dumb_down, "Pass the dumbed-down netlist to the simulator (for the C simulator)";
- "-n", Arg.Set_int number_steps, "Number of steps to simulate"]
- compile
+ "-sim", Arg.Set_string sim_path, "Path to the circuit simulator";
+ "-d", Arg.Set dumb_down, "Pass the dumbed-down netlist to the simulator (for the C simulator)";
+ "-n", Arg.Set_int number_steps, "Number of steps to simulate"]
+ compile
""
-;;
-main ()
+let () = main ()
diff --git a/sched/simplify.ml b/sched/simplify.ml
index ef2f0dc..a2c7770 100644
--- a/sched/simplify.ml
+++ b/sched/simplify.ml
@@ -22,7 +22,7 @@ module Smap = Map.Make(String)
(* Simplify cascade slicing/selecting *)
let cascade_slices p =
let usefull = ref false in
- let slices = Hashtbl.create 42 in
+ let slices = Hashtbl.create (Env.cardinal p.p_vars / 12) in
let eqs_new = List.map
(fun (n, eq) -> (n, match eq with
| Eslice(u, v, Avar(x)) ->
@@ -61,7 +61,7 @@ let cascade_slices p =
*)
let pass_concat p =
let usefull = ref false in
- let concats = Hashtbl.create 42 in
+ let concats = Hashtbl.create (Env.cardinal p.p_vars / 12) in
List.iter (fun (n, eq) -> match eq with
| Econcat(x, y) ->
let s1 = match x with
@@ -198,7 +198,7 @@ let same_eq_simplify p =
let usefull = ref false in
let id_outputs =
(List.fold_left (fun x k -> Sset.add k x) Sset.empty p.p_outputs) in
- let eq_map = Hashtbl.create 42 in
+ let eq_map = Hashtbl.create (List.length p.p_eqs) in
List.iter
(fun (n, eq) -> if Sset.mem n id_outputs then
Hashtbl.add eq_map eq n)
@@ -328,17 +328,15 @@ let topo_sort p =
let rec simplify_with steps p =
let pp, use = List.fold_left
(fun (x, u) (f, n) ->
+ Format.printf "%s...%!" n;
let xx, uu = f x in
- print_endline (if uu then n ^ " *" else n);
+ Format.printf "%s\n%!" (if uu then " *" else "");
(xx, u || uu))
(p, false) steps in
if use then simplify_with steps pp else pp
let simplify p =
let p = simplify_with [
- topo_sort, "topo_sort";
- ] p in
- let p = simplify_with [
cascade_slices, "cascade_slices";
pass_concat, "pass_concat";
select_to_id, "select_to_id";
@@ -350,7 +348,6 @@ let simplify p =
eliminate_id, "eliminate_id";
] p in
let p = simplify_with [
- topo_sort, "topo_sort";
cascade_slices, "cascade_slices";
pass_concat, "pass_concat";
arith_simplify, "arith_simplify";