1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 (* ********************************************************************** *)
16 (* Progetto FreeScale *)
18 (* Sviluppato da: Ing. Cosimo Oliboni, oliboni@cs.unibo.it *)
19 (* Sviluppo: 2008-2010 *)
21 (* ********************************************************************** *)
23 include "emulator/memory/memory_abs.ma".
24 include "emulator/status/HC05_status.ma".
25 include "emulator/status/HC08_status.ma".
26 include "emulator/status/RS08_status.ma".
27 include "emulator/opcodes/opcode.ma".
29 (* *********************************** *)
30 (* STATUS INTERNO DEL PROCESSORE (ALU) *)
31 (* *********************************** *)
33 (* descrittore del click = stato di avanzamento dell'esecuzione *)
34 (* 1) None = istruzione eseguita, attesa del fetch *)
35 (* 2) Some cur_clk,pseudo,mode,clks,cur_pc = fetch eseguito *)
36 ndefinition aux_clk_type ≝ λm:mcu_type.Prod5T byte8 (aux_op_type m) (aux_im_type m) byte8 word16.
38 (* tipo processore dipendente dalla mcu, varia solo la ALU *)
39 nrecord any_status (mcu:mcu_type) (t:memory_impl): Type ≝
42 [ HC05 ⇒ alu_HC05 | HC08 ⇒ alu_HC08 | HCS08 ⇒ alu_HC08 | RS08 ⇒ alu_RS08 ];
44 (* descritore della memoria *)
45 mem_desc : aux_mem_type t;
46 (* descrittore del tipo di memoria installata *)
47 chk_desc : aux_chk_type t;
48 (* descrittore del clik *)
49 clk_desc : option (aux_clk_type mcu)
52 (* evitare di mostrare la memoria/descrittore che impalla il visualizzatore *)
53 notation > "{hvbox('Alu' ≝ alu ; break 'Clk' ≝ clk)}" non associative with precedence 80
54 for @{ 'mk_any_status $alu $mem $chk $clk }.
55 interpretation "mk_any_status" 'mk_any_status alu mem chk clk =
56 (mk_any_status alu mem chk clk).
58 (* ******************** *)
59 (* CONFRONTO FRA STATUS *)
60 (* ******************** *)
67 [ HC05 ⇒ alu_HC05 | HC08 ⇒ alu_HC08 | HCS08 ⇒ alu_HC08 | RS08 ⇒ alu_RS08 ] →
69 [ HC05 ⇒ alu_HC05 | HC08 ⇒ alu_HC08 | HCS08 ⇒ alu_HC08 | RS08 ⇒ alu_RS08 ] →
78 (* confronto di una regione di memoria [addr1 ; ... ; addrn] *)
79 nlet rec forall_memory_ranged
81 (chk1:aux_chk_type t) (chk2:aux_chk_type t)
82 (mem1:aux_mem_type t) (mem2:aux_mem_type t)
83 (addrl:list word32) on addrl ≝
84 match addrl return λ_.bool with
86 | cons hd tl ⇒ (eq_option byte8 (mem_read t mem1 chk1 hd)
87 (mem_read t mem2 chk2 hd) eq_b8) ⊗
88 (forall_memory_ranged t chk1 chk2 mem1 mem2 tl)
92 λm:mcu_type.λc1,c2:option (aux_clk_type m).
94 [ None ⇒ match c2 with
95 [ None ⇒ true | Some _ ⇒ false ]
96 | Some c1' ⇒ match c2 with
97 [ None ⇒ false | Some c2' ⇒ (eq_b8 (fst5T … c1') (fst5T … c2')) ⊗
98 (eq_op m (snd5T … c1') (snd5T … c2')) ⊗
99 (eq_im m (thd5T … c1') (thd5T … c2')) ⊗
100 (eq_b8 (fth5T … c1') (fth5T … c2')) ⊗
101 (eq_w16 (fft5T … c1') (fft5T … c2')) ]
104 (* generalizzazione del confronto fra stati *)
105 ndefinition eq_anystatus ≝
106 λm:mcu_type.λt:memory_impl.λs1,s2:any_status m t.λaddrl:list word32.
107 (* 1) confronto della ALU *)
108 (eq_alu m (alu m t s1) (alu m t s2)) ⊗
109 (* 2) confronto della memoria in [inf,inf+n] *)
110 (forall_memory_ranged t (chk_desc m t s1) (chk_desc m t s2)
111 (mem_desc m t s1) (mem_desc m t s2) addrl) ⊗
112 (* 3) confronto del clik *)
113 (eq_clk m (clk_desc m t s1) (clk_desc m t s2)).