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/opcodes/Freescale_pseudo.ma".
24 include "emulator/opcodes/Freescale_instr_mode.ma".
25 include "emulator/opcodes/IP2022_pseudo.ma".
26 include "emulator/opcodes/IP2022_instr_mode.ma".
27 include "emulator/opcodes/byte_or_word.ma".
28 include "common/list.ma".
30 (* ********************************************** *)
31 (* MATTONI BASE PER DEFINIRE LE TABELLE DELLE MCU *)
32 (* ********************************************** *)
34 (* enumerazione delle ALU *)
35 ninductive mcu_type: Type ≝
42 ndefinition eq_mcutype ≝
45 [ HC05 ⇒ match m2 with [ HC05 ⇒ true | _ ⇒ false ]
46 | HC08 ⇒ match m2 with [ HC08 ⇒ true | _ ⇒ false ]
47 | HCS08 ⇒ match m2 with [ HCS08 ⇒ true | _ ⇒ false ]
48 | RS08 ⇒ match m2 with [ RS08 ⇒ true | _ ⇒ false ]
49 | IP2022 ⇒ match m2 with [ IP2022 ⇒ true | _ ⇒ false ]
52 ndefinition aux_pseudo_type ≝
53 λmcu:mcu_type.match mcu with
54 [ HC05 ⇒ Freescale_pseudo
55 | HC08 ⇒ Freescale_pseudo
56 | HCS08 ⇒ Freescale_pseudo
57 | RS08 ⇒ Freescale_pseudo
58 | IP2022 ⇒ IP2022_pseudo
61 ndefinition pseudo_is_comparable: mcu_type → comparable.
62 #mcu; @ (aux_pseudo_type mcu)
64 ##[ ##1,2,3,4: napply (zeroc Freescalepseudo_is_comparable)
65 ##| ##5: napply (zeroc IP2022pseudo_is_comparable) ##]
67 ##[ ##1,2,3,4: napply (forallc Freescalepseudo_is_comparable)
68 ##| ##5: napply (forallc IP2022pseudo_is_comparable) ##]
70 ##[ ##1,2,3,4: napply (eqc Freescalepseudo_is_comparable)
71 ##| ##5: napply (eqc IP2022pseudo_is_comparable) ##]
73 ##[ ##1,2,3,4: napply (eqc_to_eq Freescalepseudo_is_comparable)
74 ##| ##5: napply (eqc_to_eq IP2022pseudo_is_comparable) ##]
76 ##[ ##1,2,3,4: napply (eq_to_eqc Freescalepseudo_is_comparable)
77 ##| ##5: napply (eq_to_eqc IP2022pseudo_is_comparable) ##]
79 ##[ ##1,2,3,4: napply (neqc_to_neq Freescalepseudo_is_comparable)
80 ##| ##5: napply (neqc_to_neq IP2022pseudo_is_comparable) ##]
82 ##[ ##1,2,3,4: napply (neq_to_neqc Freescalepseudo_is_comparable)
83 ##| ##5: napply (neq_to_neqc IP2022pseudo_is_comparable) ##]
85 ##[ ##1,2,3,4: napply (decidable_c Freescalepseudo_is_comparable)
86 ##| ##5: napply (decidable_c IP2022pseudo_is_comparable) ##]
88 ##[ ##1,2,3,4: napply (symmetric_eqc Freescalepseudo_is_comparable)
89 ##| ##5: napply (symmetric_eqc IP2022pseudo_is_comparable) ##]
93 unification hint 0 ≔ M:mcu_type ⊢ carr (pseudo_is_comparable M) ≡ aux_pseudo_type M.
95 ndefinition aux_im_type ≝
96 λmcu:mcu_type.match mcu with
97 [ HC05 ⇒ Freescale_instr_mode
98 | HC08 ⇒ Freescale_instr_mode
99 | HCS08 ⇒ Freescale_instr_mode
100 | RS08 ⇒ Freescale_instr_mode
101 | IP2022 ⇒ IP2022_instr_mode
104 ndefinition im_is_comparable: mcu_type → comparable.
105 #mcu; @ (aux_im_type mcu)
107 ##[ ##1,2,3,4: napply (zeroc Freescaleim_is_comparable)
108 ##| ##5: napply (zeroc IP2022im_is_comparable) ##]
110 ##[ ##1,2,3,4: napply (forallc Freescaleim_is_comparable)
111 ##| ##5: napply (forallc IP2022im_is_comparable) ##]
113 ##[ ##1,2,3,4: napply (eqc Freescaleim_is_comparable)
114 ##| ##5: napply (eqc IP2022im_is_comparable) ##]
116 ##[ ##1,2,3,4: napply (eqc_to_eq Freescaleim_is_comparable)
117 ##| ##5: napply (eqc_to_eq IP2022im_is_comparable) ##]
119 ##[ ##1,2,3,4: napply (eq_to_eqc Freescaleim_is_comparable)
120 ##| ##5: napply (eq_to_eqc IP2022im_is_comparable) ##]
122 ##[ ##1,2,3,4: napply (neqc_to_neq Freescaleim_is_comparable)
123 ##| ##5: napply (neqc_to_neq IP2022im_is_comparable) ##]
125 ##[ ##1,2,3,4: napply (neq_to_neqc Freescaleim_is_comparable)
126 ##| ##5: napply (neq_to_neqc IP2022im_is_comparable) ##]
128 ##[ ##1,2,3,4: napply (decidable_c Freescaleim_is_comparable)
129 ##| ##5: napply (decidable_c IP2022im_is_comparable) ##]
131 ##[ ##1,2,3,4: napply (symmetric_eqc Freescaleim_is_comparable)
132 ##| ##5: napply (symmetric_eqc IP2022im_is_comparable) ##]
136 unification hint 0 ≔ M:mcu_type ⊢ carr (im_is_comparable M) ≡ aux_im_type M.
138 (* ********************************************* *)
139 (* STRUMENTI PER LE DIMOSTRAZIONI DI CORRETTEZZA *)
140 (* ********************************************* *)
142 ndefinition aux_table_type ≝ λmcu:mcu_type.Prod4T (aux_pseudo_type mcu) (aux_im_type mcu) byte8_or_word16 nat.
144 (* su tutta la lista quante volte compare il byte *)
145 nlet rec get_byte_count (m:mcu_type) (b:byte8) (c:word16) (l:list (aux_table_type m)) on l ≝
148 | cons hd tl ⇒ match thd4T … hd with
149 [ Byte b' ⇒ match eqc ? b b' with
150 [ true ⇒ get_byte_count m b (succc ? c) tl
151 | false ⇒ get_byte_count m b c tl
153 | Word _ ⇒ get_byte_count m b c tl
157 (* su tutta la lista quante volte compare la word *)
158 nlet rec get_word_count (m:mcu_type) (w:word16) (c:word16) (l:list (aux_table_type m)) on l ≝
161 | cons hd tl ⇒ match thd4T … hd with
162 [ Byte _ ⇒ get_word_count m w c tl
163 | Word w' ⇒ match eqc ? w w' with
164 [ true ⇒ get_word_count m w (succc ? c) tl
165 | false ⇒ get_word_count m w c tl
170 (* su tutta la lista quante volte compare lo pseudocodice *)
171 nlet rec get_pseudo_count (m:mcu_type) (o:aux_pseudo_type m) (c:word16) (l:list (aux_table_type m)) on l ≝
174 | cons hd tl ⇒ match eqc ? o (fst4T … hd) with
175 [ true ⇒ get_pseudo_count m o (succc ? c) tl
176 | false ⇒ get_pseudo_count m o c tl
180 (* su tutta la lista quante volte compare la modalita' *)
181 nlet rec get_mode_count (m:mcu_type) (i:aux_im_type m) (c:word16) (l:list (aux_table_type m)) on l ≝
184 | cons hd tl ⇒ match eqc ? i (snd4T … hd) with
185 [ true ⇒ get_mode_count m i (succc ? c) tl
186 | false ⇒ get_mode_count m i c tl
190 (* b e' non implementato? *)
191 nlet rec test_not_impl_byte (b:byte8) (l:list byte8) on l ≝
194 | cons hd tl ⇒ match eqc ? b hd with
196 | false ⇒ test_not_impl_byte b tl
200 (* su tutta la lista quante volte compare la coppia pseudo,instr_mode *)
201 nlet rec get_PsIm_count (m:mcu_type) (o:aux_pseudo_type m) (i:aux_im_type m) (c:word16) (l:list (aux_table_type m)) on l ≝
205 match (eqc ? o (fst4T … hd)) ⊗
206 (eqc ? i (snd4T … hd)) with
207 [ true ⇒ get_PsIm_count m o i (succc ? c) tl
208 | false ⇒ get_PsIm_count m o i c tl
212 (* o e' non implementato? *)
213 nlet rec test_not_impl_pseudo (m:mcu_type) (o:aux_pseudo_type m) (l:list (aux_pseudo_type m)) on l ≝
216 | cons hd tl ⇒ match eqc ? o hd with
218 | false ⇒ test_not_impl_pseudo m o tl
222 (* i e' non implementato? *)
223 nlet rec test_not_impl_mode (m:mcu_type) (i:aux_im_type m) (l:list (aux_im_type m)) on l ≝
226 | cons hd tl ⇒ match eqc ? i hd with
228 | false ⇒ test_not_impl_mode m i tl