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 "num/word16.ma".
25 (* *********************************** *)
26 (* STATUS INTERNO DEL PROCESSORE (ALU) *)
27 (* *********************************** *)
29 (* ALU dell'HC08/HCS08 *)
30 nrecord alu_HC08: Type ≝
32 (* A: registo accumulatore *)
33 acc_low_reg_HC08 : byte8;
34 (* X: registro indice parte bassa *)
35 indX_low_reg_HC08 : byte8;
36 (* H: registro indice parte alta *)
37 indX_high_reg_HC08 : byte8;
38 (* SP: registo stack pointer *)
40 (* PC: registro program counter *)
43 (* V: flag overflow *)
45 (* H: flag semi-carry (somma nibble basso) *)
47 (* I: flag mascheramento degli interrupt mascherabili: 1=mascherati *)
49 (* N: flag segno/negativita' *)
56 (* IRQ: flag che simula il pin esterno IRQ *)
60 notation "{hvbox('A_Reg' ≝ acclow ; break 'X_Reg' ≝ indxlow ; break 'H_Reg' ≝ indxhigh ; break 'Sp_Reg' ≝ sp ; break 'Pc_Reg' ≝ pc ; break 'V_Flag' ≝ vfl ; break 'H_Flag' ≝ hfl ; break 'I_Flag' ≝ ifl ; break 'N_Flag' ≝ nfl ; break 'Z_Flag' ≝ zfl ; break 'C_Flag' ≝ cfl ; break 'IRQ_Flag' ≝ irqfl)}"
61 non associative with precedence 80 for
62 @{ 'mk_alu_HC08 $acclow $indxlow $indxhigh $sp $pc $vfl $hfl $ifl $nfl $zfl $cfl $irqfl }.
63 interpretation "mk_alu_HC08" 'mk_alu_HC08 acclow indxlow indxhigh sp pc vfl hfl ifl nfl zfl cfl irqfl =
64 (mk_alu_HC08 acclow indxlow indxhigh sp pc vfl hfl ifl nfl zfl cfl irqfl).
70 (* setter specifico HC08/HCS08 di A *)
71 ndefinition set_acc_8_low_reg_HC08 ≝
75 (indX_low_reg_HC08 alu)
76 (indX_high_reg_HC08 alu)
87 (* setter specifico HC08/HCS08 di X *)
88 ndefinition set_indX_8_low_reg_HC08 ≝
91 (acc_low_reg_HC08 alu)
93 (indX_high_reg_HC08 alu)
104 (* setter specifico HC08/HCS08 di H *)
105 ndefinition set_indX_8_high_reg_HC08 ≝
106 λalu.λindxhigh':byte8.
108 (acc_low_reg_HC08 alu)
109 (indX_low_reg_HC08 alu)
121 (* setter specifico HC08/HCS08 di H:X *)
122 ndefinition set_indX_16_reg_HC08 ≝
125 (acc_low_reg_HC08 alu)
138 (* setter specifico HC08/HCS08 di SP *)
139 ndefinition set_sp_reg_HC08 ≝
142 (acc_low_reg_HC08 alu)
143 (indX_low_reg_HC08 alu)
144 (indX_high_reg_HC08 alu)
155 (* setter specifico HC08/HCS08 di PC *)
156 ndefinition set_pc_reg_HC08 ≝
159 (acc_low_reg_HC08 alu)
160 (indX_low_reg_HC08 alu)
161 (indX_high_reg_HC08 alu)
172 (* setter specifico HC08/HCS08 di V *)
173 ndefinition set_v_flag_HC08 ≝
176 (acc_low_reg_HC08 alu)
177 (indX_low_reg_HC08 alu)
178 (indX_high_reg_HC08 alu)
189 (* setter specifico HC08/HCS08 di H *)
190 ndefinition set_h_flag_HC08 ≝
193 (acc_low_reg_HC08 alu)
194 (indX_low_reg_HC08 alu)
195 (indX_high_reg_HC08 alu)
206 (* setter specifico HC08/HCS08 di I *)
207 ndefinition set_i_flag_HC08 ≝
210 (acc_low_reg_HC08 alu)
211 (indX_low_reg_HC08 alu)
212 (indX_high_reg_HC08 alu)
223 (* setter specifico HC08/HCS08 di N *)
224 ndefinition set_n_flag_HC08 ≝
227 (acc_low_reg_HC08 alu)
228 (indX_low_reg_HC08 alu)
229 (indX_high_reg_HC08 alu)
240 (* setter specifico HC08/HCS08 di Z *)
241 ndefinition set_z_flag_HC08 ≝
244 (acc_low_reg_HC08 alu)
245 (indX_low_reg_HC08 alu)
246 (indX_high_reg_HC08 alu)
257 (* setter specifico HC08/HCS08 di C *)
258 ndefinition set_c_flag_HC08 ≝
261 (acc_low_reg_HC08 alu)
262 (indX_low_reg_HC08 alu)
263 (indX_high_reg_HC08 alu)
274 (* setter specifico HC08/HCS08 di IRQ *)
275 ndefinition set_irq_flag_HC08 ≝
278 (acc_low_reg_HC08 alu)
279 (indX_low_reg_HC08 alu)
280 (indX_high_reg_HC08 alu)
291 (* ***************** *)
292 (* CONFRONTO FRA ALU *)
293 (* ***************** *)
295 (* confronto registro per registro dell'HC08 *)
296 ndefinition eq_HC08_alu ≝
298 (eqc ? (acc_low_reg_HC08 alu1) (acc_low_reg_HC08 alu2)) ⊗
299 (eqc ? (indX_low_reg_HC08 alu1) (indX_low_reg_HC08 alu2)) ⊗
300 (eqc ? (indX_high_reg_HC08 alu1) (indX_high_reg_HC08 alu2)) ⊗
301 (eqc ? (sp_reg_HC08 alu1) (sp_reg_HC08 alu2)) ⊗
302 (eqc ? (pc_reg_HC08 alu1) (pc_reg_HC08 alu2)) ⊗
303 (eqc ? (v_flag_HC08 alu1) (v_flag_HC08 alu2)) ⊗
304 (eqc ? (h_flag_HC08 alu1) (h_flag_HC08 alu2)) ⊗
305 (eqc ? (i_flag_HC08 alu1) (i_flag_HC08 alu2)) ⊗
306 (eqc ? (n_flag_HC08 alu1) (n_flag_HC08 alu2)) ⊗
307 (eqc ? (z_flag_HC08 alu1) (z_flag_HC08 alu2)) ⊗
308 (eqc ? (c_flag_HC08 alu1) (c_flag_HC08 alu2)) ⊗
309 (eqc ? (irq_flag_HC08 alu1) (irq_flag_HC08 alu2)).
311 ndefinition forall_HC08_alu ≝ λP:alu_HC08 → bool.
312 forallc ? (λr1.forallc ? (λr2.
313 forallc ? (λr3.forallc ? (λr4.
314 forallc ? (λr5.forallc ? (λr6.
315 forallc ? (λr7.forallc ? (λr8.
316 forallc ? (λr9.forallc ? (λr10.
317 forallc ? (λr11.forallc ? (λr12.
318 P (mk_alu_HC08 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12))))))))))))).