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/tests/micro_tests_tools.ma".
24 include "emulator/multivm/multivm.ma".
25 include "emulator/status/status_lemmas.ma".
26 include "emulator/model/model.ma".
28 (* ****************************************** *)
29 (* MICRO TEST DI CORRETTEZZA DELLE ISTRUZIONI *)
30 (* ****************************************** *)
36 ndefinition mTest_HCS08_ADC_source ≝ source_to_byte8 HCS08 (
37 (* testa la logica di ADC e le modalita' IMM1,DIR1/2,IX0/1/2,SP1/2 *)
38 (* BEFORE: A=0x00 H:X=0xFF50 PC=0x1860 SP=0x0110 C=true *)
39 (* [0x1860] 2clk *) (compile HCS08 ? ADC (maIMM1 〈xA,xA〉) ?) @ (* AFTER1: imm1=0xAA quindi 0x00+imm1+true=A:0xAB C:false *)
40 (* [0x1862] 3clk *) (compile HCS08 ? ADC (maDIR1 〈xF,xF〉) ?) @ (* AFTER2: dir1=[0x00FF]=0x8F quindi 0xAB+dir1+false=A:0x3A C:true *)
41 (* [0x1864] 4clk *) (compile HCS08 ? ADC (maDIR2 〈〈xF,xF〉:〈x1,x1〉〉) ?) @ (* AFTER3: dir2=[0xFF11]=0x11 quindi 0x3A+dir2+true=A:0x4C C:false *)
42 (* [0x1867] 4clk *) (compile HCS08 ? ADC (maIX2 〈〈xF,xF〉:〈xF,x0〉〉) ?) @ (* AFTER4: ix2=[X+0xFFF0]=[0xFF40]=0x40 quindi 0x4C+ix2+false=A:0x8C C:false *)
43 (* [0x186A] 3clk *) (compile HCS08 ? ADC (maIX1 〈x2,x4〉) ?) @ (* AFTER5: ix1=[X+0x0024]=[0xFF74]=0x74 quindi 0x8C+ix1+false=A:0x00 C:true *)
44 (* [0x186C] 3clk *) (compile HCS08 ? ADC maIX0 ?) @ (* AFTER6: ix0=[X]=[0xFF50]=0x50 quindi 0x00+ix0+true=A:0x51 C:false *)
45 (* [0x186D] 5clk *) (compile HCS08 ? ADC (maSP2 〈〈xF,xF〉:〈x6,x1〉〉) ?) @ (* AFTER7: sp2=[SP+0xFF61]=[0x0071]=0x01 quindi 0x51+sp2+false=A:0x52 C:false *)
46 (* [0x1871] 4clk *) (compile HCS08 ? ADC (maSP1 〈x2,x4〉) ?) (* AFTER8: sp1=[SP+0x0024]=[0x0134]=0xC4 quindi 0x52+sp1+false=A:0x16 C:true *)
47 (* [0x1874] si puo' quindi enunciare che dopo 2+3+4+4+3+3+5+4=28 clk *)
48 (* A<-0x16 PC<-0x1874 *)
51 (* creazione del processore+caricamento+impostazione registri *)
52 ndefinition mTest_HCS08_ADC_status ≝
54 set_c_flag HCS08 t (* C<-true *)
55 (setweak_sp_reg HCS08 t (* SP<-0x0110 *)
56 (setweak_indX_16_reg HCS08 t (* H:X<-0xFF50 *)
57 (set_pc_reg HCS08 t (* PC<-mTest_HCS08_prog *)
58 (start_of_model HCS08 MC9S08AW60 t
59 (load_from_source_at t (* carica mTest_bytes in ROM:mTest_HCS08_data *)
60 (load_from_source_at t (* carica mTest_bytes in RAM:mTest_HCS08_RAM *)
61 (load_from_source_at t (zero_memory t) (* carica source in ROM:mTest_HCS08_prog *)
62 mTest_HCS08_ADC_source (extu_w32 mTest_HCS08_prog))
63 mTest_bytes (extu_w32 mTest_HCS08_RAM))
64 mTest_bytes (extu_w32 mTest_HCS08_data))
65 (build_memory_type_of_model HCS08 MC9S08AW60 t)
66 (mk_byte8 x0 x0) (mk_byte8 x0 x0) (* non deterministici tutti a 0 *)
67 false false false false false false) (* non deterministici tutti a 0 *)
69 (mk_word16 〈xF,xF〉 〈x5,x0〉))
70 (mk_word16 〈x0,x1〉 〈x1,x0〉))
73 (* dimostrazione senza svolgimento degli stati, immediata *)
74 nlemma ok_mTest_HCS08_ADC_full :
76 execute HCS08 t (TickOK ? (mTest_HCS08_ADC_status t)) nat28 =
77 (* NB: V,N,Z sono tornati false C e' tornato true *)
78 TickOK ? (set_pc_reg HCS08 t (* nuovo PC *)
79 (set_acc_8_low_reg HCS08 t (mTest_HCS08_ADC_status t) 〈x1,x6〉) (* nuovo A *)
80 (mk_word16 〈x1,x8〉 〈x7,x4〉)).
81 (* esempio per svoglimento degli stati manualmente*)
82 nletin BEFORE ≝ (alu HCS08 t (mTest_HCS08_ADC_status t));
83 nnormalize in BEFORE:(%);
85 nletin AFTER_ALU1 ≝ (match execute HCS08 t (TickOK ? (mTest_HCS08_ADC_status t)) nat2 with
86 [ TickERR _ _ ⇒ BEFORE
87 | TickSUSP _ _ ⇒ BEFORE
88 | TickOK s ⇒ alu HCS08 t s ]);
89 nnormalize in AFTER_ALU1:(%);
91 nletin AFTER_ALU2 ≝ (match execute HCS08 t (TickOK ?
92 (set_alu HCS08 t (mTest_HCS08_ADC_status t) AFTER_ALU1)) nat3 with
93 [ TickERR _ _ ⇒ BEFORE
94 | TickSUSP _ _ ⇒ BEFORE
95 | TickOK s ⇒ alu HCS08 t s ]);
96 nnormalize in AFTER_ALU2:(%);
98 nletin AFTER_ALU3 ≝ (match execute HCS08 t (TickOK ?
99 (set_alu HCS08 t (mTest_HCS08_ADC_status t) AFTER_ALU2)) nat4 with
100 [ TickERR _ _ ⇒ BEFORE
101 | TickSUSP _ _ ⇒ BEFORE
102 | TickOK s ⇒ alu HCS08 t s ]);
103 nnormalize in AFTER_ALU3:(%);
105 nletin AFTER_ALU4 ≝ (match execute HCS08 t (TickOK ?
106 (set_alu HCS08 t (mTest_HCS08_ADC_status t) AFTER_ALU3)) nat4 with
107 [ TickERR _ _ ⇒ BEFORE
108 | TickSUSP _ _ ⇒ BEFORE
109 | TickOK s ⇒ alu HCS08 t s ]);
110 nnormalize in AFTER_ALU4:(%);
112 nletin AFTER_ALU5 ≝ (match execute HCS08 t (TickOK ?
113 (set_alu HCS08 t (mTest_HCS08_ADC_status t) AFTER_ALU4)) nat3 with
114 [ TickERR _ _ ⇒ BEFORE
115 | TickSUSP _ _ ⇒ BEFORE
116 | TickOK s ⇒ alu HCS08 t s ]);
117 nnormalize in AFTER_ALU5:(%);
119 nletin AFTER_ALU6 ≝ (match execute HCS08 t (TickOK ?
120 (set_alu HCS08 t (mTest_HCS08_ADC_status t) AFTER_ALU5)) nat3 with
121 [ TickERR _ _ ⇒ BEFORE
122 | TickSUSP _ _ ⇒ BEFORE
123 | TickOK s ⇒ alu HCS08 t s ]);
124 nnormalize in AFTER_ALU6:(%);
126 nletin AFTER_ALU7 ≝ (match execute HCS08 t (TickOK ?
127 (set_alu HCS08 t (mTest_HCS08_ADC_status t) AFTER_ALU6)) nat5 with
128 [ TickERR _ _ ⇒ BEFORE
129 | TickSUSP _ _ ⇒ BEFORE
130 | TickOK s ⇒ alu HCS08 t s ]);
131 nnormalize in AFTER_ALU7:(%);
133 nletin AFTER_ALU8 ≝ (match execute HCS08 t (TickOK ?
134 (set_alu HCS08 t (mTest_HCS08_ADC_status t) AFTER_ALU7)) nat4 with
135 [ TickERR _ _ ⇒ BEFORE
136 | TickSUSP _ _ ⇒ BEFORE
137 | TickOK s ⇒ alu HCS08 t s ]);
138 nnormalize in AFTER_ALU8:(%); *)