]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/ng_assembly2/emulator/read_write/read_write.ma
arithmetics for λδ
[helm.git] / matita / matita / contribs / ng_assembly2 / emulator / read_write / read_write.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/read_write/RS08_read_write.ma".
24 include "emulator/read_write/IP2022_read_write.ma".
25
26 (* filtraggio avviene sempre sul segmento 0 *)
27
28 (* in caso di RS08/IP2022 si dirotta sul filtro, altrimenti si legge direttamente *)
29 ndefinition memory_filter_read ≝
30 λm:mcu_type.λt:memory_impl.match m return λm:mcu_type.any_status m t → word16 → option byte8 with
31  [ HC05 ⇒ λs:any_status HC05 t.
32   mem_read t (mem_desc … s) (chk_desc … s) o0
33  | HC08 ⇒ λs:any_status HC08 t.
34   mem_read t (mem_desc … s) (chk_desc … s) o0
35  | HCS08 ⇒ λs:any_status HCS08 t.
36   mem_read t (mem_desc … s) (chk_desc … s) o0
37  | RS08 ⇒ RS08_memory_filter_read t
38  | IP2022 ⇒ IP2022_memory_filter_read t
39  ].
40
41 ndefinition memory_filter_read_bit ≝
42 λm:mcu_type.λt:memory_impl.match m return λm:mcu_type.any_status m t → word16 → oct → option bool with
43  [ HC05 ⇒ λs:any_status HC05 t.
44   mem_read_bit t (mem_desc … s) (chk_desc … s) o0
45  | HC08 ⇒ λs:any_status HC08 t.
46   mem_read_bit t (mem_desc … s) (chk_desc … s) o0
47  | HCS08 ⇒ λs:any_status HCS08 t.
48   mem_read_bit t (mem_desc … s) (chk_desc … s) o0
49  | RS08 ⇒ RS08_memory_filter_read_bit t
50  | IP2022 ⇒ IP2022_memory_filter_read_bit t
51  ].
52
53 ndefinition memory_filter_write ≝
54 λm:mcu_type.λt:memory_impl.match m
55  return λm:mcu_type.any_status m t → word16 → aux_mod_type → byte8 → option (any_status m t) with
56  [ HC05 ⇒ λs:any_status HC05 t.λaddr:word16.λflag:aux_mod_type.λval:byte8.
57   opt_map … (mem_update t (mem_desc … s) (chk_desc … s) o0 addr val)
58    (λmem.Some ? (set_mem_desc … s mem))
59  | HC08 ⇒ λs:any_status HC08 t.λaddr:word16.λflag:aux_mod_type.λval:byte8.
60   opt_map … (mem_update t (mem_desc … s) (chk_desc … s) o0 addr val)
61    (λmem.Some ? (set_mem_desc … s mem))
62  | HCS08 ⇒ λs:any_status HCS08 t.λaddr:word16.λflag:aux_mod_type.λval:byte8.
63   opt_map … (mem_update t (mem_desc … s) (chk_desc … s) o0 addr val)
64    (λmem.Some ? (set_mem_desc … s mem))
65  | RS08 ⇒ λs:any_status RS08 t.λaddr:word16.λflag:aux_mod_type.
66   RS08_memory_filter_write t s addr
67  | IP2022 ⇒ IP2022_memory_filter_write t
68  ].
69
70 ndefinition memory_filter_write_bit ≝
71 λm:mcu_type.λt:memory_impl.match m
72  return λm:mcu_type.any_status m t → word16 → oct → bool → option (any_status m t) with
73  [ HC05 ⇒ λs:any_status HC05 t.λaddr:word16.λsub:oct.λval:bool.
74   opt_map … (mem_update_bit t (mem_desc … s) (chk_desc … s) o0 addr sub val)
75     (λmem.Some ? (set_mem_desc … s mem))
76  | HC08 ⇒ λs:any_status HC08 t.λaddr:word16.λsub:oct.λval:bool.
77   opt_map … (mem_update_bit t (mem_desc … s) (chk_desc … s) o0 addr sub val)
78     (λmem.Some ? (set_mem_desc … s mem))
79  | HCS08 ⇒ λs:any_status HCS08 t.λaddr:word16.λsub:oct.λval:bool.
80   opt_map … (mem_update_bit t (mem_desc … s) (chk_desc … s) o0 addr sub val)
81    (λmem.Some ? (set_mem_desc … s mem)) 
82  | RS08 ⇒ RS08_memory_filter_write_bit t
83  | IP2022 ⇒ IP2022_memory_filter_write_bit t
84  ].