]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/contribs/ng_assembly/freescale_tests/micro_tests1.ma
Additional contribs.
[helm.git] / helm / software / matita / contribs / ng_assembly / freescale_tests / micro_tests1.ma
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 (* ********************************************************************** *)
16 (*                          Progetto FreeScale                            *)
17 (*                                                                        *)
18 (*   Sviluppato da: Ing. Cosimo Oliboni, oliboni@cs.unibo.it              *)
19 (*   Ultima modifica: 05/08/2009                                          *)
20 (*                                                                        *)
21 (* ********************************************************************** *)
22
23 include "freescale_tests/micro_tests_tools.ma".
24 include "freescale/multivm.ma".
25 include "freescale/status_lemmas.ma".
26
27 (* ****************************************** *)
28 (* MICRO TEST DI CORRETTEZZA DELLE ISTRUZIONI *)
29 (* ****************************************** *)
30
31 (* ********* *)
32 (* HCS08 ADC *)
33 (* ********* *)
34
35 ndefinition mTest_HCS08_ADC_source ≝ let m ≝ HCS08 in source_to_byte8 m (
36 (* testa la logica di ADC e le modalita' IMM1,DIR1/2,IX0/1/2,SP1/2 *)
37 (* BEFORE: A=0x00 H:X=0xFF50 PC=0x1860 SP=0x0110 C=true *)
38 (* [0x1860] 2clk *) (compile m ? ADC (maIMM1 〈xA,xA〉) I) @           (* AFTER1: imm1=0xAA quindi 0x00+imm1+true=A:0xAB C:false *)
39 (* [0x1862] 3clk *) (compile m ? ADC (maDIR1 〈xF,xF〉) I) @           (* AFTER2: dir1=[0x00FF]=0x8F quindi 0xAB+dir1+false=A:0x3A C:true *)
40 (* [0x1864] 4clk *) (compile m ? ADC (maDIR2 〈〈xF,xF〉:〈x1,x1〉〉) I) @ (* AFTER3: dir2=[0xFF11]=0x11 quindi 0x3A+dir2+true=A:0x4C C:false *)
41 (* [0x1867] 4clk *) (compile m ? ADC (maIX2 〈〈xF,xF〉:〈xF,x0〉〉) I) @  (* AFTER4: ix2=[X+0xFFF0]=[0xFF40]=0x40 quindi 0x4C+ix2+false=A:0x8C C:false *)
42 (* [0x186A] 3clk *) (compile m ? ADC (maIX1 〈x2,x4〉) I) @            (* AFTER5: ix1=[X+0x0024]=[0xFF74]=0x74 quindi 0x8C+ix1+false=A:0x00 C:true *)
43 (* [0x186C] 3clk *) (compile m ? ADC maIX0 I) @                      (* AFTER6: ix0=[X]=[0xFF50]=0x50 quindi 0x00+ix0+true=A:0x51 C:false *)
44 (* [0x186D] 5clk *) (compile m ? ADC (maSP2 〈〈xF,xF〉:〈x6,x1〉〉) I) @  (* AFTER7: sp2=[SP+0xFF61]=[0x0071]=0x01 quindi 0x51+sp2+false=A:0x52 C:false *)
45 (* [0x1871] 4clk *) (compile m ? ADC (maSP1 〈x2,x4〉) I)              (* AFTER8: sp1=[SP+0x0024]=[0x0134]=0xC4 quindi 0x52+sp1+false=A:0x16 C:true *)
46 (* [0x1874] si puo' quindi enunciare che dopo 2+3+4+4+3+3+5+4=28 clk *)
47 (*          A<-0x16 PC<-0x1874 *)
48 ).
49
50 (* creazione del processore+caricamento+impostazione registri *)
51 ndefinition mTest_HCS08_ADC_status ≝
52 λt:memory_impl.
53  set_c_flag HCS08 t (* C<-true *)
54   (setweak_sp_reg HCS08 t (* SP<-0x0110 *)
55    (setweak_indX_16_reg HCS08 t (* H:X<-0xFF50 *)
56     (set_pc_reg HCS08 t (* PC<-mTest_HCS08_prog *)
57      (start_of_mcu_version_HCS08
58       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 mTest_HCS08_prog)
63          mTest_bytes mTest_HCS08_RAM)
64         mTest_bytes mTest_HCS08_data)
65       (build_memory_type_of_mcu_version (FamilyHCS08 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 *)
68      mTest_HCS08_prog)
69     (mk_word16 〈xF,xF〉 〈x5,x0〉))
70    (mk_word16 〈x0,x1〉 〈x1,x0〉))
71   true.
72
73 (* dimostrazione senza svolgimento degli stati, immediata *)
74 nlemma ok_mTest_HCS08_ADC_full :
75  ∀t:memory_impl.
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  #t; nelim t;
82  (* esempio per svoglimento degli stati manualmente
83  [ 1:
84   letin BEFORE ≝ (get_alu HCS08 MEM_FUNC (mTest_HCS08_ADC_status MEM_FUNC));
85   normalize in BEFORE:(%);
86
87  letin AFTER_ALU1 ≝ (match execute HCS08 MEM_FUNC (TickOK ? (mTest_HCS08_ADC_status MEM_FUNC)) 2 with
88   [ TickERR _ _ ⇒ BEFORE 
89   | TickSUSP _ _ ⇒ BEFORE 
90   | TickOK s ⇒ get_alu HCS08 MEM_FUNC s ]);
91  normalize in AFTER_ALU1:(%);
92
93  letin AFTER_ALU2 ≝ (match execute HCS08 MEM_FUNC (TickOK ? 
94                      (set_alu HCS08 MEM_FUNC (mTest_HCS08_ADC_status MEM_FUNC) AFTER_ALU1)) 3 with
95   [ TickERR _ _ ⇒ BEFORE 
96   | TickSUSP _ _ ⇒ BEFORE 
97   | TickOK s ⇒ get_alu HCS08 MEM_FUNC s ]);
98  normalize in AFTER_ALU2:(%);
99
100   letin AFTER_ALU3 ≝ (match execute HCS08 MEM_FUNC (TickOK ? 
101                      (set_alu HCS08 MEM_FUNC (mTest_HCS08_ADC_status MEM_FUNC) AFTER_ALU2)) 4 with
102   [ TickERR _ _ ⇒ BEFORE 
103   | TickSUSP _ _ ⇒ BEFORE 
104   | TickOK s ⇒ get_alu HCS08 MEM_FUNC s ]);
105  normalize in AFTER_ALU3:(%);  
106
107  letin AFTER_ALU4 ≝ (match execute HCS08 MEM_FUNC (TickOK ? 
108                      (set_alu HCS08 MEM_FUNC (mTest_HCS08_ADC_status MEM_FUNC) AFTER_ALU3)) 4 with
109   [ TickERR _ _ ⇒ BEFORE 
110   | TickSUSP _ _ ⇒ BEFORE 
111   | TickOK s ⇒ get_alu HCS08 MEM_FUNC s ]);
112  normalize in AFTER_ALU4:(%); 
113
114  letin AFTER_ALU5 ≝ (match execute HCS08 MEM_FUNC (TickOK ? 
115                      (set_alu HCS08 MEM_FUNC (mTest_HCS08_ADC_status MEM_FUNC) AFTER_ALU4)) 3 with
116   [ TickERR _ _ ⇒ BEFORE 
117   | TickSUSP _ _ ⇒ BEFORE 
118   | TickOK s ⇒ get_alu HCS08 MEM_FUNC s ]);
119  normalize in AFTER_ALU5:(%); 
120
121  letin AFTER_ALU6 ≝ (match execute HCS08 MEM_FUNC (TickOK ? 
122                      (set_alu HCS08 MEM_FUNC (mTest_HCS08_ADC_status MEM_FUNC) AFTER_ALU5)) 3 with
123   [ TickERR _ _ ⇒ BEFORE 
124   | TickSUSP _ _ ⇒ BEFORE 
125   | TickOK s ⇒ get_alu HCS08 MEM_FUNC s ]);
126  normalize in AFTER_ALU6:(%); 
127
128  letin AFTER_ALU7 ≝ (match execute HCS08 MEM_FUNC (TickOK ? 
129                      (set_alu HCS08 MEM_FUNC (mTest_HCS08_ADC_status MEM_FUNC) AFTER_ALU6)) 5 with
130   [ TickERR _ _ ⇒ BEFORE 
131   | TickSUSP _ _ ⇒ BEFORE 
132   | TickOK s ⇒ get_alu HCS08 MEM_FUNC s ]);
133  normalize in AFTER_ALU7:(%); 
134
135  letin AFTER_ALU8 ≝ (match execute HCS08 MEM_FUNC (TickOK ? 
136                      (set_alu HCS08 MEM_FUNC (mTest_HCS08_ADC_status MEM_FUNC) AFTER_ALU7)) 4 with
137   [ TickERR _ _ ⇒ BEFORE
138   | TickSUSP _ _ ⇒ BEFORE
139   | TickOK s ⇒ get_alu HCS08 MEM_FUNC s ]);
140  normalize in AFTER_ALU8:(%); *) 
141
142  napply refl_eq.
143 nqed.