]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/contribs/ng_assembly2/emulator/opcodes/pseudo.ma
...
[helm.git] / helm / software / matita / contribs / ng_assembly2 / emulator / opcodes / pseudo.ma
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 (* ********************************************************************** *)
16 (*                          Progetto FreeScale                            *)
17 (*                                                                        *)
18 (*   Sviluppato da: Ing. Cosimo Oliboni, oliboni@cs.unibo.it              *)
19 (*   Sviluppo: 2008-2010                                                  *)
20 (*                                                                        *)
21 (* ********************************************************************** *)
22
23 include "emulator/opcodes/Freescale_pseudo.ma".
24 include "emulator/opcodes/Freescale_instr_mode.ma".
25 include "emulator/opcodes/IP2022_pseudo.ma".
26 include "emulator/opcodes/IP2022_instr_mode.ma".
27 include "emulator/opcodes/byte_or_word.ma".
28 include "common/list.ma".
29
30 (* ********************************************** *)
31 (* MATTONI BASE PER DEFINIRE LE TABELLE DELLE MCU *)
32 (* ********************************************** *)
33
34 (* enumerazione delle ALU *)
35 ninductive mcu_type: Type ≝
36   HC05   : mcu_type
37 | HC08   : mcu_type
38 | HCS08  : mcu_type
39 | RS08   : mcu_type
40 | IP2022 : mcu_type.
41
42 ndefinition eq_mcutype ≝
43 λm1,m2:mcu_type.
44  match m1 with
45   [ HC05 ⇒ match m2 with [ HC05 ⇒ true | _ ⇒ false ]
46   | HC08 ⇒ match m2 with [ HC08 ⇒ true | _ ⇒ false ]
47   | HCS08 ⇒ match m2 with [ HCS08 ⇒ true | _ ⇒ false ]
48   | RS08 ⇒ match m2 with [ RS08 ⇒ true | _ ⇒ false ]
49   | IP2022 ⇒ match m2 with [ IP2022 ⇒ true | _ ⇒ false ]
50   ].
51
52 ndefinition aux_pseudo_type ≝
53 λmcu:mcu_type.match mcu with
54  [ HC05 ⇒ Freescale_pseudo
55  | HC08 ⇒ Freescale_pseudo
56  | HCS08 ⇒ Freescale_pseudo
57  | RS08 ⇒ Freescale_pseudo
58  | IP2022 ⇒ IP2022_pseudo
59  ].
60
61 ndefinition aux_im_type ≝
62 λmcu:mcu_type.match mcu with
63  [ HC05 ⇒ Freescale_instr_mode
64  | HC08 ⇒ Freescale_instr_mode
65  | HCS08 ⇒ Freescale_instr_mode
66  | RS08 ⇒ Freescale_instr_mode
67  | IP2022 ⇒ IP2022_instr_mode
68  ].
69
70 (* ********************************************* *)
71 (* STRUMENTI PER LE DIMOSTRAZIONI DI CORRETTEZZA *)
72 (* ********************************************* *)
73
74 ndefinition aux_table_type ≝ λmcu:mcu_type.Prod4T (aux_pseudo_type mcu) (aux_im_type mcu) byte8_or_word16 byte8.
75
76 naxiom daemon: False.
77
78 ndefinition pseudo_is_comparable: mcu_type → comparable.
79  #mcu; 
80  @ (aux_pseudo_type mcu)
81   ##[ napply (match mcu return λmcu. aux_pseudo_type mcu with
82         [ HC05 ⇒ zeroc Freescalepseudo_is_comparable
83         | HC08 ⇒ zeroc Freescalepseudo_is_comparable
84         | HCS08 ⇒ zeroc Freescalepseudo_is_comparable
85         | RS08 ⇒ zeroc Freescalepseudo_is_comparable
86         | IP2022 ⇒ zeroc IP2022pseudo_is_comparable
87         ])
88     | napply (match mcu return λmcu. (aux_pseudo_type mcu → bool) → bool with
89         [ HC05 ⇒ forallc Freescalepseudo_is_comparable
90         | HC08 ⇒ forallc Freescalepseudo_is_comparable
91         | HCS08 ⇒ forallc Freescalepseudo_is_comparable
92         | RS08 ⇒ forallc Freescalepseudo_is_comparable
93         | IP2022 ⇒ forallc IP2022pseudo_is_comparable
94         ])
95      | napply (match mcu return λmcu. aux_pseudo_type mcu → aux_pseudo_type mcu → bool with
96         [ HC05 ⇒ eqc Freescalepseudo_is_comparable
97         | HC08 ⇒ eqc Freescalepseudo_is_comparable
98         | HCS08 ⇒ eqc Freescalepseudo_is_comparable
99         | RS08 ⇒ eqc Freescalepseudo_is_comparable
100         | IP2022 ⇒ eqc IP2022pseudo_is_comparable
101         ])
102      |##*: ncases daemon ]
103 nqed.
104        
105
106 (* come suggerire di unificare?
107    carr (pseudo_is_comparable M) = aux_pseudo_type M *)
108
109 unification hint 0 ≔  MCU:mcu_type ⊢
110    carr (pseudo_is_comparable MCU) ≡ aux_pseudo_type MCU.
111
112 (* su tutta la lista quante volte compare lo pseudocodice *)
113 nlet rec get_pseudo_count (m:mcu_type) (o:aux_pseudo_type m) (c:word16) (l:list (aux_table_type m)) on l ≝
114  match l with
115   [ nil ⇒ c
116   | cons hd tl ⇒ match eqc ? o (fst4T … hd) with
117    [ true ⇒ get_pseudo_count m o (succc ? c) tl
118    | false ⇒ get_pseudo_count m o c tl
119    ]
120   ].