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/HC05_opcode.ma".
24 include "emulator/opcodes/HC05_instr_mode.ma".
25 include "emulator/opcodes/HC08_opcode.ma".
26 include "emulator/opcodes/HC08_instr_mode.ma".
27 include "emulator/opcodes/HCS08_opcode.ma".
28 include "emulator/opcodes/RS08_opcode.ma".
29 include "emulator/opcodes/RS08_instr_mode.ma".
30 include "emulator/opcodes/byte_or_word.ma".
31 include "common/list.ma".
33 (* ********************************************** *)
34 (* MATTONI BASE PER DEFINIRE LE TABELLE DELLE MCU *)
35 (* ********************************************** *)
37 (* enumerazione delle ALU *)
38 ninductive mcu_type: Type ≝
44 ndefinition eq_mcutype ≝
47 [ HC05 ⇒ match m2 with [ HC05 ⇒ true | _ ⇒ false ]
48 | HC08 ⇒ match m2 with [ HC08 ⇒ true | _ ⇒ false ]
49 | HCS08 ⇒ match m2 with [ HCS08 ⇒ true | _ ⇒ false ]
50 | RS08 ⇒ match m2 with [ RS08 ⇒ true | _ ⇒ false ]
53 ndefinition aux_op_type ≝
54 λmcu:mcu_type.match mcu with
57 | HCS08 ⇒ HCS08_opcode
61 ndefinition aux_im_type ≝
62 λmcu:mcu_type.match mcu with
63 [ HC05 ⇒ HC05_instr_mode
64 | HC08 ⇒ HC08_instr_mode
65 | HCS08 ⇒ HC08_instr_mode
66 | RS08 ⇒ RS08_instr_mode
72 return λm.aux_op_type m → aux_op_type m → bool
83 return λm.aux_im_type m → aux_im_type m → bool
91 ndefinition forall_op ≝
94 return λm.(aux_op_type m → bool) → bool
96 [ HC05 ⇒ forall_HC05_op
97 | HC08 ⇒ forall_HC08_op
98 | HCS08 ⇒ forall_HCS08_op
99 | RS08 ⇒ forall_RS08_op
102 ndefinition forall_im ≝
105 return λm.(aux_im_type m → bool) → bool
107 [ HC05 ⇒ forall_HC05_im
108 | HC08 ⇒ forall_HC08_im
109 | HCS08 ⇒ forall_HC08_im
110 | RS08 ⇒ forall_RS08_im
113 (* ********************************************* *)
114 (* STRUMENTI PER LE DIMOSTRAZIONI DI CORRETTEZZA *)
115 (* ********************************************* *)
117 ndefinition aux_table_type ≝ λmcu:mcu_type.Prod4T (aux_op_type mcu) (aux_im_type mcu) byte8_or_word16 byte8.
119 (* su tutta la lista quante volte compare il byte *)
120 nlet rec get_byte_count (m:mcu_type) (b:byte8) (c:word16) (l:list (aux_table_type m)) on l ≝
123 | cons hd tl ⇒ match thd4T … hd with
124 [ Byte b' ⇒ match eq_b8 b b' with
125 [ true ⇒ get_byte_count m b (succ_w16 c) tl
126 | false ⇒ get_byte_count m b c tl
128 | Word _ ⇒ get_byte_count m b c tl
132 (* su tutta la lista quante volte compare la word (0x9E+byte) *)
133 nlet rec get_word_count (m:mcu_type) (b:byte8) (c:word16) (l:list (aux_table_type m)) on l ≝
136 | cons hd tl ⇒ match thd4T … hd with
137 [ Byte _ ⇒ get_word_count m b c tl
138 | Word w ⇒ match eq_w16 〈〈x9,xE〉:b〉 w with
139 [ true ⇒ get_word_count m b (succ_w16 c) tl
140 | false ⇒ get_word_count m b c tl
145 (* su tutta la lista quante volte compare lo pseudocodice *)
146 nlet rec get_pseudo_count (m:mcu_type) (o:aux_op_type m) (c:word16) (l:list (aux_table_type m)) on l ≝
149 | cons hd tl ⇒ match eq_op m o (fst4T … hd) with
150 [ true ⇒ get_pseudo_count m o (succ_w16 c) tl
151 | false ⇒ get_pseudo_count m o c tl
155 (* su tutta la lista quante volte compare la modalita' *)
156 nlet rec get_mode_count (m:mcu_type) (i:aux_im_type m) (c:word16) (l:list (aux_table_type m)) on l ≝
159 | cons hd tl ⇒ match eq_im m i (snd4T … hd) with
160 [ true ⇒ get_mode_count m i (succ_w16 c) tl
161 | false ⇒ get_mode_count m i c tl
165 (* b e' non implementato? *)
166 nlet rec test_not_impl_byte (b:byte8) (l:list byte8) on l ≝
169 | cons hd tl ⇒ match eq_b8 b hd with
171 | false ⇒ test_not_impl_byte b tl
175 (* o e' non implementato? *)
176 nlet rec test_not_impl_pseudo (m:mcu_type) (o:aux_op_type m) (l:list (aux_op_type m)) on l ≝
179 | cons hd tl ⇒ match eq_op m o hd with
181 | false ⇒ test_not_impl_pseudo m o tl
185 (* i e' non implementato? *)
186 nlet rec test_not_impl_mode (m:mcu_type) (i:aux_im_type m) (l:list (aux_im_type m)) on l ≝
189 | cons hd tl ⇒ match eq_im m i hd with
191 | false ⇒ test_not_impl_mode m i tl
195 (* su tutta la lista quante volte compare la coppia opcode,instr_mode *)
196 nlet rec get_OpIm_count (m:mcu_type) (o:aux_op_type m) (i:aux_im_type m) (c:word16) (l:list (aux_table_type m)) on l ≝
200 match (eq_op m o (fst4T … hd)) ⊗
201 (eq_im m i (snd4T … hd)) with
202 [ true ⇒ get_OpIm_count m o i (succ_w16 c) tl
203 | false ⇒ get_OpIm_count m o i c tl