done?
This commit is contained in:
parent
61bb14b9e3
commit
ad8728bdf4
19 changed files with 335 additions and 47 deletions
30
ass2/SICocaml/sicxeDune/lib/pogajalnik.ml
Normal file
30
ass2/SICocaml/sicxeDune/lib/pogajalnik.ml
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
(*pogajalnik bo izvajal exekucijo eno za drugo*)
|
||||
|
||||
let run (state : Processor.state) (khz : float) : unit =
|
||||
let perioda_sekunde = 1.0 /. (khz *. 1000.0) in
|
||||
let rec loop state last_pc count=
|
||||
|
||||
(*izvedi ukaz*)
|
||||
Izvajalnik.execute state;
|
||||
|
||||
(*printni stanje*)
|
||||
Printf.printf "After execution:\n";
|
||||
Processor.print_regs state;
|
||||
Processor.print_memory state 50;
|
||||
flush stdout;
|
||||
|
||||
(*spi*)
|
||||
Unix.sleepf perioda_sekunde;(*mogoče spremeni na time of day approach , da se izogneš driftu*)
|
||||
|
||||
(*preveri ali je PC obtičan na istem mestu*)
|
||||
let current_pc = state.regs.pc in
|
||||
let count, last_pc =
|
||||
if current_pc = last_pc then (count + 1, last_pc)
|
||||
else (1, current_pc)
|
||||
in
|
||||
(*Nehaj rekurzijo če je PC 5x na istem mestu*)
|
||||
if count >= 5 then
|
||||
Printf.printf "PC stuck at 0x%X 5 times. Ending loop.\n" current_pc
|
||||
else
|
||||
loop state last_pc count
|
||||
in loop state state.regs.pc 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue