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 (* SETTER SPECIFICI FORTI/DEBOLI *)
27 (* ***************************** *)
29 (* funzione ausiliaria per il tipaggio dei setter forti *)
30 ndefinition aux_set_type ≝ λx:Type.λm:mcu_type.
31 match m with [ HC05 ⇒ alu_HC05 | HC08 ⇒ alu_HC08 | HCS08 ⇒ alu_HC08 | RS08 ⇒ alu_RS08 ]
33 match m with [ HC05 ⇒ alu_HC05 | HC08 ⇒ alu_HC08 | HCS08 ⇒ alu_HC08 | RS08 ⇒ alu_RS08 ].
35 (* funzione ausiliaria per il tipaggio dei setter deboli *)
36 ndefinition aux_set_type_opt ≝ λx:Type.λm:mcu_type.option
37 (match m with [ HC05 ⇒ alu_HC05 | HC08 ⇒ alu_HC08 | HCS08 ⇒ alu_HC08 | RS08 ⇒ alu_RS08 ]
39 match m with [ HC05 ⇒ alu_HC05 | HC08 ⇒ alu_HC08 | HCS08 ⇒ alu_HC08 | RS08 ⇒ alu_RS08 ]).
41 (* DESCRITTORI ESTERNI ALLA ALU *)
43 (* setter forte della ALU *)
45 λm:mcu_type.λt:memory_impl.λs:any_status m t.λalu'.
46 mk_any_status m t alu' (mem_desc m t s) (chk_desc m t s) (clk_desc m t s).
48 (* setter forte della memoria *)
49 ndefinition set_mem_desc ≝
50 λm:mcu_type.λt:memory_impl.λs:any_status m t.λmem':aux_mem_type t.
51 mk_any_status m t (alu m t s) mem' (chk_desc m t s) (clk_desc m t s).
53 (* setter forte del descrittore *)
54 ndefinition set_chk_desc ≝
55 λm:mcu_type.λt:memory_impl.λs:any_status m t.λchk':aux_chk_type t.
56 mk_any_status m t (alu m t s) (mem_desc m t s) chk' (clk_desc m t s).
58 (* setter forte del clik *)
59 ndefinition set_clk_desc ≝
60 λm:mcu_type.λt:memory_impl.λs:any_status m t.
61 λclk':option (aux_clk_type m).
62 mk_any_status m t (alu m t s) (mem_desc m t s) (chk_desc m t s) clk'.
66 (* setter specifico HC05 di A *)
67 ndefinition set_acc_8_low_reg_HC05 ≝
71 (indX_low_reg_HC05 alu)
84 (* setter specifico HC08/HCS08 di A *)
85 ndefinition set_acc_8_low_reg_HC08 ≝
89 (indX_low_reg_HC08 alu)
90 (indX_high_reg_HC08 alu)
101 (* setter specifico RS08 di A *)
102 ndefinition set_acc_8_low_reg_RS08 ≝
114 (* setter forte di A *)
115 ndefinition set_acc_8_low_reg ≝
116 λm:mcu_type.λt:memory_impl.λs:any_status m t.λacclow':byte8.
118 (match m return aux_set_type byte8 with
119 [ HC05 ⇒ set_acc_8_low_reg_HC05
120 | HC08 ⇒ set_acc_8_low_reg_HC08
121 | HCS08 ⇒ set_acc_8_low_reg_HC08
122 | RS08 ⇒ set_acc_8_low_reg_RS08
123 ] (alu m t s) acclow').
127 (* setter specifico HC05 di X *)
128 ndefinition set_indX_8_low_reg_HC05 ≝
129 λalu.λindxlow':byte8.
131 (acc_low_reg_HC05 alu)
145 (* setter specifico HC08/HCS08 di X *)
146 ndefinition set_indX_8_low_reg_HC08 ≝
147 λalu.λindxlow':byte8.
149 (acc_low_reg_HC08 alu)
151 (indX_high_reg_HC08 alu)
162 (* setter forte di X *)
163 ndefinition set_indX_8_low_reg ≝
164 λm:mcu_type.λt:memory_impl.λs:any_status m t.λindxlow':byte8.
165 opt_map … (match m return aux_set_type_opt byte8 with
166 [ HC05 ⇒ Some ? set_indX_8_low_reg_HC05
167 | HC08 ⇒ Some ? set_indX_8_low_reg_HC08
168 | HCS08 ⇒ Some ? set_indX_8_low_reg_HC08
170 (λf.Some ? (set_alu m t s (f (alu m t s) indxlow'))).
172 (* setter debole di X *)
173 ndefinition setweak_indX_8_low_reg ≝
174 λm:mcu_type.λt:memory_impl.λs:any_status m t.λindxlow':byte8.
175 match set_indX_8_low_reg m t s indxlow' with
176 [ None ⇒ s | Some s' ⇒ s' ].
180 (* setter specifico HC08/HCS08 di H *)
181 ndefinition set_indX_8_high_reg_HC08 ≝
182 λalu.λindxhigh':byte8.
184 (acc_low_reg_HC08 alu)
185 (indX_low_reg_HC08 alu)
197 (* setter forte di H *)
198 ndefinition set_indX_8_high_reg ≝
199 λm:mcu_type.λt:memory_impl.λs:any_status m t.λindxhigh':byte8.
200 opt_map … (match m return aux_set_type_opt byte8 with
202 | HC08 ⇒ Some ? set_indX_8_high_reg_HC08
203 | HCS08 ⇒ Some ? set_indX_8_high_reg_HC08
205 (λf.Some ? (set_alu m t s (f (alu m t s) indxhigh'))).
207 (* setter debole di H *)
208 ndefinition setweak_indX_8_high_reg ≝
209 λm:mcu_type.λt:memory_impl.λs:any_status m t.λindxhigh':byte8.
210 match set_indX_8_high_reg m t s indxhigh' with
211 [ None ⇒ s | Some s' ⇒ s' ].
215 (* setter specifico HC08/HCS08 di H:X *)
216 ndefinition set_indX_16_reg_HC08 ≝
219 (acc_low_reg_HC08 alu)
232 (* setter forte di H:X *)
233 ndefinition set_indX_16_reg ≝
234 λm:mcu_type.λt:memory_impl.λs:any_status m t.λindx16:word16.
235 opt_map … (match m return aux_set_type_opt word16 with
237 | HC08 ⇒ Some ? set_indX_16_reg_HC08
238 | HCS08 ⇒ Some ? set_indX_16_reg_HC08
240 (λf.Some ? (set_alu m t s (f (alu m t s) indx16))).
242 (* setter debole di H:X *)
243 ndefinition setweak_indX_16_reg ≝
244 λm:mcu_type.λt:memory_impl.λs:any_status m t.λindx16:word16.
245 match set_indX_16_reg m t s indx16 with
246 [ None ⇒ s | Some s' ⇒ s' ].
250 (* setter specifico HC05 di SP, effettua (SP∧mask)∨fix *)
251 ndefinition set_sp_reg_HC05 ≝
254 (acc_low_reg_HC05 alu)
255 (indX_low_reg_HC05 alu)
256 (or_w16 (and_w16 sp' (sp_mask_HC05 alu)) (sp_fix_HC05 alu))
268 (* setter specifico HC08/HCS08 di SP *)
269 ndefinition set_sp_reg_HC08 ≝
272 (acc_low_reg_HC08 alu)
273 (indX_low_reg_HC08 alu)
274 (indX_high_reg_HC08 alu)
285 (* setter forte di SP *)
286 ndefinition set_sp_reg ≝
287 λm:mcu_type.λt:memory_impl.λs:any_status m t.λsp':word16.
288 opt_map … (match m return aux_set_type_opt word16 with
289 [ HC05 ⇒ Some ? set_sp_reg_HC05
290 | HC08 ⇒ Some ? set_sp_reg_HC08
291 | HCS08 ⇒ Some ? set_sp_reg_HC08
293 (λf.Some ? (set_alu m t s (f (alu m t s) sp'))).
295 (* setter debole di SP *)
296 ndefinition setweak_sp_reg ≝
297 λm:mcu_type.λt:memory_impl.λs:any_status m t.λsp':word16.
298 match set_sp_reg m t s sp' with
299 [ None ⇒ s | Some s' ⇒ s' ].
303 (* setter specifico HC05 di PC, effettua PC∧mask *)
304 ndefinition set_pc_reg_HC05 ≝
307 (acc_low_reg_HC05 alu)
308 (indX_low_reg_HC05 alu)
312 (and_w16 pc' (pc_mask_HC05 alu))
321 (* setter specifico HC08/HCS08 di PC *)
322 ndefinition set_pc_reg_HC08 ≝
325 (acc_low_reg_HC08 alu)
326 (indX_low_reg_HC08 alu)
327 (indX_high_reg_HC08 alu)
338 (* setter specifico RS08 di PC, effettua PC∧mask *)
339 ndefinition set_pc_reg_RS08 ≝
342 (acc_low_reg_RS08 alu)
343 (and_w16 pc' (pc_mask_RS08 alu))
351 (* setter forte di PC *)
352 ndefinition set_pc_reg ≝
353 λm:mcu_type.λt:memory_impl.λs:any_status m t.λpc':word16.
355 (match m return aux_set_type word16 with
356 [ HC05 ⇒ set_pc_reg_HC05
357 | HC08 ⇒ set_pc_reg_HC08
358 | HCS08 ⇒ set_pc_reg_HC08
359 | RS08 ⇒ set_pc_reg_RS08
364 (* setter specifico RS08 di SPC, effettua SPC∧mask *)
365 ndefinition set_spc_reg_RS08 ≝
368 (acc_low_reg_RS08 alu)
371 (and_w16 spc' (pc_mask_RS08 alu))
377 (* setter forte di SPC *)
378 ndefinition set_spc_reg ≝
379 λm:mcu_type.λt:memory_impl.λs:any_status m t.λspc':word16.
380 opt_map … (match m return aux_set_type_opt word16 with
384 | RS08 ⇒ Some ? set_spc_reg_RS08 ])
385 (λf.Some ? (set_alu m t s (f (alu m t s) spc'))).
387 (* setter debole di SPC *)
388 ndefinition setweak_spc_reg ≝
389 λm:mcu_type.λt:memory_impl.λs:any_status m t.λspc':word16.
390 match set_spc_reg m t s spc' with
391 [ None ⇒ s | Some s' ⇒ s' ].
393 (* REGISTRO MEMORY MAPPED X *)
395 (* setter specifico RS08 di memory mapped X *)
396 ndefinition set_x_map_RS08 ≝
399 (acc_low_reg_RS08 alu)
408 (* setter forte di memory mapped X *)
409 ndefinition set_x_map ≝
410 λm:mcu_type.λt:memory_impl.λs:any_status m t.λxm':byte8.
411 opt_map … (match m return aux_set_type_opt byte8 with
415 | RS08 ⇒ Some ? set_x_map_RS08 ])
416 (λf.Some ? (set_alu m t s (f (alu m t s) xm'))).
418 (* setter debole di memory mapped X *)
419 ndefinition setweak_x_map ≝
420 λm:mcu_type.λt:memory_impl.λs:any_status m t.λxm':byte8.
421 match set_x_map m t s xm' with
422 [ None ⇒ s | Some s' ⇒ s' ].
424 (* REGISTRO MEMORY MAPPED PS *)
426 (* setter specifico RS08 di memory mapped PS *)
427 ndefinition set_ps_map_RS08 ≝
430 (acc_low_reg_RS08 alu)
439 (* setter forte di memory mapped PS *)
440 ndefinition set_ps_map ≝
441 λm:mcu_type.λt:memory_impl.λs:any_status m t.λpsm':byte8.
442 opt_map … (match m return aux_set_type_opt byte8 with
446 | RS08 ⇒ Some ? set_ps_map_RS08 ])
447 (λf.Some ? (set_alu m t s (f (alu m t s) psm'))).
449 (* setter debole di memory mapped PS *)
450 ndefinition setweak_ps_map ≝
451 λm:mcu_type.λt:memory_impl.λs:any_status m t.λpsm':byte8.
452 match set_ps_map m t s psm' with
453 [ None ⇒ s | Some s' ⇒ s' ].
457 (* setter specifico HC08/HCS08 di V *)
458 ndefinition set_v_flag_HC08 ≝
461 (acc_low_reg_HC08 alu)
462 (indX_low_reg_HC08 alu)
463 (indX_high_reg_HC08 alu)
474 (* setter forte di V *)
475 ndefinition set_v_flag ≝
476 λm:mcu_type.λt:memory_impl.λs:any_status m t.λvfl':bool.
477 opt_map … (match m return aux_set_type_opt bool with
479 | HC08 ⇒ Some ? set_v_flag_HC08
480 | HCS08 ⇒ Some ? set_v_flag_HC08
482 (λf.Some ? (set_alu m t s (f (alu m t s) vfl'))).
484 (* setter debole di V *)
485 ndefinition setweak_v_flag ≝
486 λm:mcu_type.λt:memory_impl.λs:any_status m t.λvfl':bool.
487 match set_v_flag m t s vfl' with
488 [ None ⇒ s | Some s' ⇒ s' ].
492 (* setter specifico HC05 di H *)
493 ndefinition set_h_flag_HC05 ≝
496 (acc_low_reg_HC05 alu)
497 (indX_low_reg_HC05 alu)
510 (* setter specifico HC08/HCS08 di H *)
511 ndefinition set_h_flag_HC08 ≝
514 (acc_low_reg_HC08 alu)
515 (indX_low_reg_HC08 alu)
516 (indX_high_reg_HC08 alu)
527 (* setter forte di H *)
528 ndefinition set_h_flag ≝
529 λm:mcu_type.λt:memory_impl.λs:any_status m t.λhfl':bool.
530 opt_map … (match m return aux_set_type_opt bool with
531 [ HC05 ⇒ Some ? set_h_flag_HC05
532 | HC08 ⇒ Some ? set_h_flag_HC08
533 | HCS08 ⇒ Some ? set_h_flag_HC08
535 (λf.Some ? (set_alu m t s (f (alu m t s) hfl'))).
537 (* setter debole di H *)
538 ndefinition setweak_h_flag ≝
539 λm:mcu_type.λt:memory_impl.λs:any_status m t.λhfl':bool.
540 match set_h_flag m t s hfl' with
541 [ None ⇒ s | Some s' ⇒ s' ].
545 (* setter specifico HC05 di I *)
546 ndefinition set_i_flag_HC05 ≝
549 (acc_low_reg_HC05 alu)
550 (indX_low_reg_HC05 alu)
563 (* setter specifico HC08/HCS08 di I *)
564 ndefinition set_i_flag_HC08 ≝
567 (acc_low_reg_HC08 alu)
568 (indX_low_reg_HC08 alu)
569 (indX_high_reg_HC08 alu)
580 (* setter forte di I *)
581 ndefinition set_i_flag ≝
582 λm:mcu_type.λt:memory_impl.λs:any_status m t.λifl':bool.
583 opt_map … (match m return aux_set_type_opt bool with
584 [ HC05 ⇒ Some ? set_i_flag_HC05
585 | HC08 ⇒ Some ? set_i_flag_HC08
586 | HCS08 ⇒ Some ? set_i_flag_HC08
588 (λf.Some ? (set_alu m t s (f (alu m t s) ifl'))).
590 (* setter debole di I *)
591 ndefinition setweak_i_flag ≝
592 λm:mcu_type.λt:memory_impl.λs:any_status m t.λifl':bool.
593 match set_i_flag m t s ifl' with
594 [ None ⇒ s | Some s' ⇒ s' ].
598 (* setter specifico HC05 di N *)
599 ndefinition set_n_flag_HC05 ≝
602 (acc_low_reg_HC05 alu)
603 (indX_low_reg_HC05 alu)
616 (* setter specifico HC08/HCS08 di N *)
617 ndefinition set_n_flag_HC08 ≝
620 (acc_low_reg_HC08 alu)
621 (indX_low_reg_HC08 alu)
622 (indX_high_reg_HC08 alu)
633 (* setter forte di N *)
634 ndefinition set_n_flag ≝
635 λm:mcu_type.λt:memory_impl.λs:any_status m t.λnfl':bool.
636 opt_map … (match m return aux_set_type_opt bool with
637 [ HC05 ⇒ Some ? set_n_flag_HC05
638 | HC08 ⇒ Some ? set_n_flag_HC08
639 | HCS08 ⇒ Some ? set_n_flag_HC08
641 (λf.Some ? (set_alu m t s (f (alu m t s) nfl'))).
643 (* setter debole di N *)
644 ndefinition setweak_n_flag ≝
645 λm:mcu_type.λt:memory_impl.λs:any_status m t.λnfl':bool.
646 match set_n_flag m t s nfl' with
647 [ None ⇒ s | Some s' ⇒ s' ].
651 (* setter specifico HC05 di Z *)
652 ndefinition set_z_flag_HC05 ≝
655 (acc_low_reg_HC05 alu)
656 (indX_low_reg_HC05 alu)
669 (* setter specifico HC08/HCS08 di Z *)
670 ndefinition set_z_flag_HC08 ≝
673 (acc_low_reg_HC08 alu)
674 (indX_low_reg_HC08 alu)
675 (indX_high_reg_HC08 alu)
686 (* setter sprcifico RS08 di Z *)
687 ndefinition set_z_flag_RS08 ≝
690 (acc_low_reg_RS08 alu)
699 (* setter forte di Z *)
700 ndefinition set_z_flag ≝
701 λm:mcu_type.λt:memory_impl.λs:any_status m t.λzfl':bool.
703 (match m return aux_set_type bool with
704 [ HC05 ⇒ set_z_flag_HC05
705 | HC08 ⇒ set_z_flag_HC08
706 | HCS08 ⇒ set_z_flag_HC08
707 | RS08 ⇒ set_z_flag_RS08
712 (* setter specifico HC05 di C *)
713 ndefinition set_c_flag_HC05 ≝
716 (acc_low_reg_HC05 alu)
717 (indX_low_reg_HC05 alu)
730 (* setter specifico HC08/HCS08 di C *)
731 ndefinition set_c_flag_HC08 ≝
734 (acc_low_reg_HC08 alu)
735 (indX_low_reg_HC08 alu)
736 (indX_high_reg_HC08 alu)
747 (* setter specifico RS08 di C *)
748 ndefinition set_c_flag_RS08 ≝
751 (acc_low_reg_RS08 alu)
760 (* setter forte di C *)
761 ndefinition set_c_flag ≝
762 λm:mcu_type.λt:memory_impl.λs:any_status m t.λcfl':bool.
764 (match m return aux_set_type bool with
765 [ HC05 ⇒ set_c_flag_HC05
766 | HC08 ⇒ set_c_flag_HC08
767 | HCS08 ⇒ set_c_flag_HC08
768 | RS08 ⇒ set_c_flag_RS08
773 (* setter specifico HC05 di IRQ *)
774 ndefinition set_irq_flag_HC05 ≝
777 (acc_low_reg_HC05 alu)
778 (indX_low_reg_HC05 alu)
791 (* setter specifico HC08/HCS08 di IRQ *)
792 ndefinition set_irq_flag_HC08 ≝
795 (acc_low_reg_HC08 alu)
796 (indX_low_reg_HC08 alu)
797 (indX_high_reg_HC08 alu)
808 (* setter forte di IRQ *)
809 ndefinition set_irq_flag ≝
810 λm:mcu_type.λt:memory_impl.λs:any_status m t.λirqfl':bool.
811 opt_map … (match m return aux_set_type_opt bool with
812 [ HC05 ⇒ Some ? set_irq_flag_HC05
813 | HC08 ⇒ Some ? set_irq_flag_HC08
814 | HCS08 ⇒ Some ? set_irq_flag_HC08
816 (λf.Some ? (set_alu m t s (f (alu m t s) irqfl'))).
818 (* setter debole di IRQ *)
819 ndefinition setweak_irq_flag ≝
820 λm:mcu_type.λt:memory_impl.λs:any_status m t.λirqfl':bool.
821 match set_irq_flag m t s irqfl' with
822 [ None ⇒ s | Some s' ⇒ s' ].