diff options
author | Alex AUVOLAT <alex.auvolat@ens.fr> | 2013-12-17 11:37:54 +0100 |
---|---|---|
committer | Alex AUVOLAT <alex.auvolat@ens.fr> | 2013-12-17 11:37:54 +0100 |
commit | 1e5b58007da3be94755b017004cd5fe484ccbed7 (patch) | |
tree | 0b285c48f3151add05cf7c8dfbb960646c7df49f /camlsim/simulator.ml | |
parent | f91d7484c8d5af62dff97eb9ce5a5ac85aba2005 (diff) | |
download | SystDigit-Projet-1e5b58007da3be94755b017004cd5fe484ccbed7.tar.gz SystDigit-Projet-1e5b58007da3be94755b017004cd5fe484ccbed7.zip |
Tabs to spaces ; deleted Caml simulator (useless anyways)
Diffstat (limited to 'camlsim/simulator.ml')
-rw-r--r-- | camlsim/simulator.ml | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/camlsim/simulator.ml b/camlsim/simulator.ml deleted file mode 100644 index fbb831a..0000000 --- a/camlsim/simulator.ml +++ /dev/null @@ -1,67 +0,0 @@ -(* - Système Digital, cours de J.Vuillemin, 2013-2013 - Alex AUVOLAT, ENS INFO 2013 - - Circuit Simulator, main file -*) - -open Netlist_ast - -let num_steps = ref (-1) -let step = ref 0 - -let read_input = function - | (s, TBit) -> Format.printf "%s (1 bit) : @?" s; - let k = ref (read_line()) in - while String.length !k < 1 do - Format.printf "Too short. Retry : "; - k := read_line(); - done; - VBit ((!k).[0] = '1') - | (s, TBitArray(n)) -> Format.printf "%s (%d bits) : @?" s n; - let k = ref (read_line()) in - while String.length !k < 1 do - Format.printf "Too short. Retry : "; - k := read_line(); - done; - let r = Array.make n false in - for i = 0 to n-1 do - r.(i) <- ((!k).[i] = '1') - done; - VBitArray(r) - -let print_output = function - | (n, VBit (b)) -> - Format.printf "%s\t: %d@." n (if b then 1 else 0) - | (n, VBitArray (a)) -> - Format.printf "%s\t: " n; - for i = 0 to Array.length a - 1 do - Format.printf "%d" (if a.(i) then 1 else 0) - done; - Format.printf "@." - -let loadrun filename = - let p = Netlist.read_file filename in - - let machine = Machine.create p in - - while !num_steps > !step || !num_steps == -1 do - step := !step + 1; - Format.printf "Step #%d@." !step; - - Machine.read_inputs machine read_input; - Machine.step machine; - Machine.print_outputs machine print_output - done - -let () = - try - Arg.parse - ["-rom", Arg.String(Machine.load_rom), "Load one ROM file into the simulator (will be used by all ROM chips)."; - "-n", Arg.Set_int num_steps, "Number of steps to simulate"] - loadrun - "" - with - | Netlist.Parse_error s -> Format.eprintf "An error occurred: %s@." s; exit 2 - | Machine.Error s -> Format.eprintf "An error occurred: %s@." s; exit 2 - |