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 "opcodes/HC05_opcode_base.ma".
24 include "opcodes/HC08_opcode_base.ma".
25 include "opcodes/HCS08_opcode_base.ma".
26 include "opcodes/RS08_opcode_base.ma".
27 include "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 ≝
41 ndefinition eq_mcutype ≝
44 [ HC05 ⇒ match m2 with [ HC05 ⇒ true | _ ⇒ false ]
45 | HC08 ⇒ match m2 with [ HC08 ⇒ true | _ ⇒ false ]
46 | HCS08 ⇒ match m2 with [ HCS08 ⇒ true | _ ⇒ false ]
47 | RS08 ⇒ match m2 with [ RS08 ⇒ true | _ ⇒ false ]
50 ndefinition aux_op_type ≝
51 λmcu:mcu_type.match mcu with
54 | HCS08 ⇒ HCS08_opcode
58 ndefinition aux_im_type ≝
59 λmcu:mcu_type.match mcu with
60 [ HC05 ⇒ HC05_instr_mode
61 | HC08 ⇒ HC08_instr_mode
62 | HCS08 ⇒ HCS08_instr_mode
63 | RS08 ⇒ RS08_instr_mode
69 return λm.aux_op_type m → aux_op_type m → bool
80 return λm.aux_im_type m → aux_im_type m → bool
88 ndefinition forall_op ≝
91 return λm.(aux_op_type m → bool) → bool
93 [ HC05 ⇒ forall_HC05_op
94 | HC08 ⇒ forall_HC08_op
95 | HCS08 ⇒ forall_HCS08_op
96 | RS08 ⇒ forall_RS08_op
99 ndefinition forall_im ≝
102 return λm.(aux_im_type m → bool) → bool
104 [ HC05 ⇒ forall_HC05_im
105 | HC08 ⇒ forall_HC08_im
106 | HCS08 ⇒ forall_HCS08_im
107 | RS08 ⇒ forall_RS08_im
110 (* ********************************************* *)
111 (* STRUMENTI PER LE DIMOSTRAZIONI DI CORRETTEZZA *)
112 (* ********************************************* *)
114 ndefinition aux_table_type ≝ λmcu:mcu_type.Prod4T (aux_op_type mcu) (aux_im_type mcu) byte8_or_word16 byte8.
116 (* su tutta la lista quante volte compare il byte *)
117 nlet rec get_byte_count (m:mcu_type) (b:byte8) (c:word16) (l:list (aux_table_type m)) on l ≝
120 | cons hd tl ⇒ match thd4T … hd with
121 [ Byte b' ⇒ match eq_b8 b b' with
122 [ true ⇒ get_byte_count m b (succ_w16 c) tl
123 | false ⇒ get_byte_count m b c tl
125 | Word _ ⇒ get_byte_count m b c tl
129 (* su tutta la lista quante volte compare la word (0x9E+byte) *)
130 nlet rec get_word_count (m:mcu_type) (b:byte8) (c:word16) (l:list (aux_table_type m)) on l ≝
133 | cons hd tl ⇒ match thd4T … hd with
134 [ Byte _ ⇒ get_word_count m b c tl
135 | Word w ⇒ match eq_w16 〈〈x9,xE〉:b〉 w with
136 [ true ⇒ get_word_count m b (succ_w16 c) tl
137 | false ⇒ get_word_count m b c tl
142 (* su tutta la lista quante volte compare lo pseudocodice *)
143 nlet rec get_pseudo_count (m:mcu_type) (o:aux_op_type m) (c:word16) (l:list (aux_table_type m)) on l ≝
146 | cons hd tl ⇒ match eq_op m o (fst4T … hd) with
147 [ true ⇒ get_pseudo_count m o (succ_w16 c) tl
148 | false ⇒ get_pseudo_count m o c tl
152 (* su tutta la lista quante volte compare la modalita' *)
153 nlet rec get_mode_count (m:mcu_type) (i:aux_im_type m) (c:word16) (l:list (aux_table_type m)) on l ≝
156 | cons hd tl ⇒ match eq_im m i (snd4T … hd) with
157 [ true ⇒ get_mode_count m i (succ_w16 c) tl
158 | false ⇒ get_mode_count m i c tl
162 (* b e' non implementato? *)
163 nlet rec test_not_impl_byte (b:byte8) (l:list byte8) on l ≝
166 | cons hd tl ⇒ match eq_b8 b hd with
168 | false ⇒ test_not_impl_byte b tl
172 (* o e' non implementato? *)
173 nlet rec test_not_impl_pseudo (m:mcu_type) (o:aux_op_type m) (l:list (aux_op_type m)) on l ≝
176 | cons hd tl ⇒ match eq_op m o hd with
178 | false ⇒ test_not_impl_pseudo m o tl
182 (* i e' non implementato? *)
183 nlet rec test_not_impl_mode (m:mcu_type) (i:aux_im_type m) (l:list (aux_im_type m)) on l ≝
186 | cons hd tl ⇒ match eq_im m i hd with
188 | false ⇒ test_not_impl_mode m i tl
192 (* su tutta la lista quante volte compare la coppia opcode,instr_mode *)
193 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 ≝
197 match (eq_op m o (fst4T … hd)) ⊗
198 (eq_im m i (snd4T … hd)) with
199 [ true ⇒ get_OpIm_count m o i (succ_w16 c) tl
200 | false ⇒ get_OpIm_count m o i c tl