summaryrefslogtreecommitdiff
path: root/simul/main.ml
blob: 4c9a2433970921b7ae4cbb2b2d91ff598ab86f38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
open Scheme
open Loggenerator

let pathfilename = "paths"

let estXNL a =
  if (String.length a < 4) then
    false
  else
    (String.sub a ((String.length a) - 4) 4) = ".xnl"

let simap_to_ismap simap =
  Imap.fold (fun x y l -> Smap.add y x l) simap Smap.empty

let audit = ref false
let nameGen = ref "generated"

let opts = [
 ("--audit", Arg.Set audit , "Audit mode");
 ("-a", Arg.Set audit , "Audit mode");
 ("-o", Arg.Set_string nameGen, "Generated file name");
 ("--debug", Arg.Unit (fun () -> setDebug true), "Generate a log_debug file");
 ("--verbose", Arg.Unit (fun () -> setVerbose true),"Verbose the stderr stream")
]

let _ =
  try
    let pathfile = open_in pathfilename in
    let paths = LexerPaths.read pathfile in
      
      Hashtbl.iter (fun path _ ->
		      print_log ("Path : " ^ path);
		      let files = Sys.readdir path in
			for i = 0 to Array.length files - 1 do
			  if estXNL files.(i) then begin
			    Compil.regCircuit (Reader.parse_file (path ^ files.(i)));
			    print_log ("Loaded : " ^ path ^ files.(i))
			  end
			done
		   ) paths;
      let nameCircuit = ref "" in
	Arg.parse opts (fun str -> nameCircuit := str) "";
	if !nameCircuit = "" then
	  failwith "Argument manquant : nom du circuit à compiler.";
	let schMain  = Compil.findSchema (!nameCircuit) in
	let schMain2 = delesscheme schMain in
	  Printf.fprintf stderr "Compilation : %f\n" (Sys.time());
	  let t = Compil.completeGraphe
 	    schMain2 ""
	    Imap.empty
	    Imap.empty in
	    Printf.fprintf stderr "Tritopo %f\n" (Sys.time());
	    let t = Compil.triTopo t in
	      Printf.fprintf stderr "Fin %f\n" (Sys.time());
	      Compil.cbGenereCode
		t
		(simap_to_ismap schMain.entrees)
		(simap_to_ismap schMain.sorties)
		!nameGen
		!audit;
  with
    |a -> print_logs (); raise a