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/status/status.ma".
25 (* **************** *)
26 (* GETTER SPECIFICI *)
27 (* **************** *)
29 (* funzione ausiliaria per il tipaggio dei getter *)
30 ndefinition aux_get_type ≝ λx:Type.λm:mcu_type.match m with
31 [ HC05 ⇒ alu_HC05 | HC08 ⇒ alu_HC08 | HCS08 ⇒ alu_HC08 | RS08 ⇒ alu_RS08 ] → x.
35 (* getter di A, esiste sempre *)
36 ndefinition get_acc_8_low_reg ≝
37 λm:mcu_type.λt:memory_impl.λs:any_status m t.
39 return aux_get_type byte8 with
40 [ HC05 ⇒ acc_low_reg_HC05
41 | HC08 ⇒ acc_low_reg_HC08
42 | HCS08 ⇒ acc_low_reg_HC08
43 | RS08 ⇒ acc_low_reg_RS08 ]
46 (* getter di X, non esiste sempre *)
47 ndefinition get_indX_8_low_reg ≝
48 λm:mcu_type.λt:memory_impl.λs:any_status m t.
50 return aux_get_type (option byte8) with
51 [ HC05 ⇒ λalu.Some ? (indX_low_reg_HC05 alu)
52 | HC08 ⇒ λalu.Some ? (indX_low_reg_HC08 alu)
53 | HCS08 ⇒ λalu.Some ? (indX_low_reg_HC08 alu)
54 | RS08 ⇒ λalu.None ? ]
57 (* getter di H, non esiste sempre *)
58 ndefinition get_indX_8_high_reg ≝
59 λm:mcu_type.λt:memory_impl.λs:any_status m t.
61 return aux_get_type (option byte8) with
63 | HC08 ⇒ λalu.Some ? (indX_high_reg_HC08 alu)
64 | HCS08 ⇒ λalu.Some ? (indX_high_reg_HC08 alu)
65 | RS08 ⇒ λalu.None ? ]
68 (* getter di H:X, non esiste sempre *)
69 ndefinition get_indX_16_reg ≝
70 λm:mcu_type.λt:memory_impl.λs:any_status m t.
72 return aux_get_type (option word16) with
74 | HC08 ⇒ λalu.Some ? (mk_word16 (indX_high_reg_HC08 alu) (indX_low_reg_HC08 alu))
75 | HCS08 ⇒ λalu.Some ? (mk_word16 (indX_high_reg_HC08 alu) (indX_low_reg_HC08 alu))
76 | RS08 ⇒ λalu.None ? ]
79 (* getter di SP, non esiste sempre *)
80 ndefinition get_sp_reg ≝
81 λm:mcu_type.λt:memory_impl.λs:any_status m t.
83 return aux_get_type (option word16) with
84 [ HC05 ⇒ λalu.Some ? (sp_reg_HC05 alu)
85 | HC08 ⇒ λalu.Some ? (sp_reg_HC08 alu)
86 | HCS08 ⇒ λalu.Some ? (sp_reg_HC08 alu)
87 | RS08 ⇒ λalu.None ? ]
90 (* getter di PC, esiste sempre *)
91 ndefinition get_pc_reg ≝
92 λm:mcu_type.λt:memory_impl.λs:any_status m t.
94 return aux_get_type word16 with
98 | RS08 ⇒ pc_reg_RS08 ]
101 (* getter di SPC, non esiste sempre *)
102 ndefinition get_spc_reg ≝
103 λm:mcu_type.λt:memory_impl.λs:any_status m t.
105 return aux_get_type (option word16) with
108 | HCS08 ⇒ λalu.None ?
109 | RS08 ⇒ λalu.Some ? (spc_reg_RS08 alu) ]
112 (* REGISTRI MEMORY MAPPED *)
114 (* getter di memory mapped X, non esiste sempre *)
115 ndefinition get_x_map ≝
116 λm:mcu_type.λt:memory_impl.λs:any_status m t.
118 return aux_get_type (option byte8) with
121 | HCS08 ⇒ λalu.None ?
122 | RS08 ⇒ λalu.Some ? (x_map_RS08 alu) ]
125 (* getter di memory mapped PS, non esiste sempre *)
126 ndefinition get_ps_map ≝
127 λm:mcu_type.λt:memory_impl.λs:any_status m t.
129 return aux_get_type (option byte8) with
132 | HCS08 ⇒ λalu.None ?
133 | RS08 ⇒ λalu.Some ? (ps_map_RS08 alu) ]
138 (* getter di V, non esiste sempre *)
139 ndefinition get_v_flag ≝
140 λm:mcu_type.λt:memory_impl.λs:any_status m t.
142 return aux_get_type (option bool) with
144 | HC08 ⇒ λalu.Some ? (v_flag_HC08 alu)
145 | HCS08 ⇒ λalu.Some ? (v_flag_HC08 alu)
146 | RS08 ⇒ λalu.None ? ]
149 (* getter di H, non esiste sempre *)
150 ndefinition get_h_flag ≝
151 λm:mcu_type.λt:memory_impl.λs:any_status m t.
153 return aux_get_type (option bool) with
154 [ HC05 ⇒ λalu.Some ? (h_flag_HC05 alu)
155 | HC08 ⇒ λalu.Some ? (h_flag_HC08 alu)
156 | HCS08 ⇒ λalu.Some ? (h_flag_HC08 alu)
157 | RS08 ⇒ λalu.None ? ]
160 (* getter di I, non esiste sempre *)
161 ndefinition get_i_flag ≝
162 λm:mcu_type.λt:memory_impl.λs:any_status m t.
164 return aux_get_type (option bool) with
165 [ HC05 ⇒ λalu.Some ? (i_flag_HC05 alu)
166 | HC08 ⇒ λalu.Some ? (i_flag_HC08 alu)
167 | HCS08 ⇒ λalu.Some ? (i_flag_HC08 alu)
168 | RS08 ⇒ λalu.None ? ]
171 (* getter di N, non esiste sempre *)
172 ndefinition get_n_flag ≝
173 λm:mcu_type.λt:memory_impl.λs:any_status m t.
175 return aux_get_type (option bool) with
176 [ HC05 ⇒ λalu.Some ? (n_flag_HC05 alu)
177 | HC08 ⇒ λalu.Some ? (n_flag_HC08 alu)
178 | HCS08 ⇒ λalu.Some ? (n_flag_HC08 alu)
179 | RS08 ⇒ λalu.None ? ]
182 (* getter di Z, esiste sempre *)
183 ndefinition get_z_flag ≝
184 λm:mcu_type.λt:memory_impl.λs:any_status m t.
186 return aux_get_type bool with
189 | HCS08 ⇒ z_flag_HC08
190 | RS08 ⇒ z_flag_RS08 ]
193 (* getter di C, esiste sempre *)
194 ndefinition get_c_flag ≝
195 λm:mcu_type.λt:memory_impl.λs:any_status m t.
197 return aux_get_type bool with
200 | HCS08 ⇒ c_flag_HC08
201 | RS08 ⇒ c_flag_RS08 ]
204 (* getter di IRQ, non esiste sempre *)
205 ndefinition get_irq_flag ≝
206 λm:mcu_type.λt:memory_impl.λs:any_status m t.
208 return aux_get_type (option bool) with
209 [ HC05 ⇒ λalu.Some ? (irq_flag_HC05 alu)
210 | HC08 ⇒ λalu.Some ? (irq_flag_HC08 alu)
211 | HCS08 ⇒ λalu.Some ? (irq_flag_HC08 alu)
212 | RS08 ⇒ λalu.None ? ]