Commit 503e6969 authored by Quentin Aristote's avatar Quentin Aristote
Browse files

debugging

parent 95cbeb04
......@@ -239,6 +239,7 @@ let number_steps = ref (-1)
let memory_directory = ref "./"
let frequence = ref 0
let default = [|0; 0; 0; 1; 1; 0; 0; 0|]
let debug = ref false
(* The main part of the program *)
let compile filename =
......@@ -325,10 +326,11 @@ let compile filename =
ram_size
(fun i -> Array.make word_size false) in
(* only for the clock, useless elsewhere *)
(* only for the clock, useless elsewhere ;
needs to be changed everytime microprocesseur.mj is changed *)
if List.mem id ["t0" ; "t1" ; "t2" ; "t3" ;
"t4" ; "t5" ; "t6" ; "t7" ;
"_l_329_1629" ; "_l_334_1625"] then (
"_l_317_1614" ; "_l_321_1611"] then (
for i = 8 to 15 do
for j = 0 to word_size - 1 do
r.(i).(j) <- bool_of_bit ((default.(i - 8) /
......@@ -377,7 +379,13 @@ let compile filename =
List.iter
(fun (id, expr) ->
match expr with
| Eram (_, word_size, _, write_enable, write_addr, data) -> begin
| Eram (_, word_size, _, write_enable, write_addr, data) ->
if !debug then (
Format.printf "%s@." id ;
Array.iter
(fun t -> Format.printf "%a@ " print_value (VBitArray t))
(Env.find id !rams)) ;
begin
match eval_arg !env write_enable with
| VBit true -> begin
match eval_arg !env data with
......@@ -436,10 +444,13 @@ let compile filename =
(* --- Output ---
For each variable in p.p_outputs, we print it in stdout.
We do so iff !frequence cycles have been done since the last output. *)
output !env p.p_outputs)
output !env ((if !debug then
["PC" ; "command" ; "ops" ]
else
[])@p.p_outputs)
) else
output !env p.p_outputs ;
done)
output !env p.p_outputs)
done)
let main () =
Arg.parse
......@@ -460,9 +471,9 @@ let main () =
8
(fun i ->
Arg.Int (fun n ->
default.(i) <- n))), ""]
default.(i) <- n))), "" ;
"--debug", Arg.Set debug, "Prints a handful of useful information."]
compile
""
;;
"" ;;
main ()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment