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 (* *********************************** *)
30 nrecord alu_HC05: Type ≝
32 (* A: registo accumulatore *)
33 acc_low_reg_HC05 : byte8;
34 (* X: registro indice *)
35 indX_low_reg_HC05 : byte8;
36 (* SP: registo stack pointer *)
38 (* modificatori di SP: per esempio e' definito come 0000000011xxxxxxb *)
39 (* la logica della sua costruzione e' quindi (SP∧mask)∨fix *)
40 (* totalmente racchiusa nella ALU, bastera' fare get(set(SP)) *)
41 sp_mask_HC05 : word16;
43 (* PC: registro program counter *)
45 (* modificatore di PC: per esempio e' definito come 00xxxxxxxxxxxxxxb *)
46 (* la logica della sua costruzione e' quindi (PC∧mask) *)
47 (* totalmente racchiusa nella ALU, bastera' fare get(set(PC)) *)
48 pc_mask_HC05 : word16;
50 (* H: flag semi-carry (somma nibble basso) *)
52 (* I: flag mascheramento degli interrupt mascherabili: 1=mascherati *)
54 (* N: flag segno/negativita' *)
61 (* IRQ: flag che simula il pin esterno IRQ *)
65 notation "{hvbox('A_Reg' ≝ acclow ; break 'X_Reg' ≝ indxlow ; break 'Sp_Reg' ≝ sp ; break 'Sp_Mask' ≝ spm ; break 'Sp_Fix' ≝ spf ; break 'Pc_Reg' ≝ pc ; break 'Pc_Mask' ≝ pcm ; break 'H_Flag' ≝ hfl ; break 'I_Flag' ≝ ifl ; break 'N_Flag' ≝ nfl ; break 'Z_Flag' ≝ zfl ; break 'C_Flag' ≝ cfl ; break 'IRQ_Flag' ≝ irqfl)}"
66 non associative with precedence 80 for
67 @{ 'mk_alu_HC05 $acclow $indxlow $sp $spm $spf $pc $pcm $hfl $ifl $nfl $zfl $cfl $irqfl }.
68 interpretation "mk_alu_HC05" 'mk_alu_HC05 acclow indxlow sp spm spf pc pcm hfl ifl nfl zfl cfl irqfl =
69 (mk_alu_HC05 acclow indxlow sp spm spf pc pcm hfl ifl nfl zfl cfl irqfl).
75 (* setter specifico HC05 di A *)
76 ndefinition set_acc_8_low_reg_HC05 ≝
80 (indX_low_reg_HC05 alu)
93 (* setter specifico HC05 di X *)
94 ndefinition set_indX_8_low_reg_HC05 ≝
97 (acc_low_reg_HC05 alu)
111 (* setter specifico HC05 di SP, effettua (SP∧mask)∨fix *)
112 ndefinition set_sp_reg_HC05 ≝
115 (acc_low_reg_HC05 alu)
116 (indX_low_reg_HC05 alu)
117 (or_w16 (and_w16 sp' (sp_mask_HC05 alu)) (sp_fix_HC05 alu))
129 (* setter specifico HC05 di PC, effettua PC∧mask *)
130 ndefinition set_pc_reg_HC05 ≝
133 (acc_low_reg_HC05 alu)
134 (indX_low_reg_HC05 alu)
138 (and_w16 pc' (pc_mask_HC05 alu))
147 (* setter specifico HC05 di H *)
148 ndefinition set_h_flag_HC05 ≝
151 (acc_low_reg_HC05 alu)
152 (indX_low_reg_HC05 alu)
165 (* setter specifico HC05 di I *)
166 ndefinition set_i_flag_HC05 ≝
169 (acc_low_reg_HC05 alu)
170 (indX_low_reg_HC05 alu)
183 (* setter specifico HC05 di N *)
184 ndefinition set_n_flag_HC05 ≝
187 (acc_low_reg_HC05 alu)
188 (indX_low_reg_HC05 alu)
201 (* setter specifico HC05 di Z *)
202 ndefinition set_z_flag_HC05 ≝
205 (acc_low_reg_HC05 alu)
206 (indX_low_reg_HC05 alu)
219 (* setter specifico HC05 di C *)
220 ndefinition set_c_flag_HC05 ≝
223 (acc_low_reg_HC05 alu)
224 (indX_low_reg_HC05 alu)
237 (* setter specifico HC05 di IRQ *)
238 ndefinition set_irq_flag_HC05 ≝
241 (acc_low_reg_HC05 alu)
242 (indX_low_reg_HC05 alu)
255 (* ***************** *)
256 (* CONFRONTO FRA ALU *)
257 (* ***************** *)
259 (* confronto registro per registro dell'HC05 *)
260 ndefinition eq_HC05_alu ≝
262 (eq_b8 (acc_low_reg_HC05 alu1) (acc_low_reg_HC05 alu2)) ⊗
263 (eq_b8 (indX_low_reg_HC05 alu1) (indX_low_reg_HC05 alu2)) ⊗
264 (eq_w16 (sp_reg_HC05 alu1) (sp_reg_HC05 alu2)) ⊗
265 (eq_w16 (sp_mask_HC05 alu1) (sp_mask_HC05 alu2)) ⊗
266 (eq_w16 (sp_fix_HC05 alu1) (sp_fix_HC05 alu2)) ⊗
267 (eq_w16 (pc_reg_HC05 alu1) (pc_reg_HC05 alu2)) ⊗
268 (eq_w16 (pc_mask_HC05 alu1) (pc_mask_HC05 alu2)) ⊗
269 (eq_bool (h_flag_HC05 alu1) (h_flag_HC05 alu2)) ⊗
270 (eq_bool (i_flag_HC05 alu1) (i_flag_HC05 alu2)) ⊗
271 (eq_bool (n_flag_HC05 alu1) (n_flag_HC05 alu2)) ⊗
272 (eq_bool (z_flag_HC05 alu1) (z_flag_HC05 alu2)) ⊗
273 (eq_bool (c_flag_HC05 alu1) (c_flag_HC05 alu2)) ⊗
274 (eq_bool (irq_flag_HC05 alu1) (irq_flag_HC05 alu2)).