]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/contribs/ng_assembly/emulator/status/status_setter.ma
freescale porting
[helm.git] / helm / software / matita / contribs / ng_assembly / emulator / status / status_setter.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/status/status.ma".
24
25 (* ***************************** *)
26 (* SETTER SPECIFICI FORTI/DEBOLI *)
27 (* ***************************** *)
28
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
32                | IP2022 ⇒ alu_IP2022 ]
33   → x →
34   match m with [ HC05 ⇒ alu_HC05 | HC08 ⇒ alu_HC08 | HCS08 ⇒ alu_HC08 | RS08 ⇒ alu_RS08
35                | IP2022 ⇒ alu_IP2022 ].
36
37 (* funzione ausiliaria per il tipaggio dei setter deboli *)
38 ndefinition aux_set_type_opt ≝ λx:Type.λm:mcu_type.option
39  (match m with [ HC05 ⇒ alu_HC05 | HC08 ⇒ alu_HC08 | HCS08 ⇒ alu_HC08 | RS08 ⇒ alu_RS08
40                | IP2022 ⇒ alu_IP2022 ]
41   → x →
42   match m with [ HC05 ⇒ alu_HC05 | HC08 ⇒ alu_HC08 | HCS08 ⇒ alu_HC08 | RS08 ⇒ alu_RS08
43                | IP2022 ⇒ alu_IP2022 ]).
44
45 (* DESCRITTORI ESTERNI ALLA ALU *)
46
47 (* setter forte della ALU *)
48 ndefinition set_alu ≝
49 λm:mcu_type.λt:memory_impl.λs:any_status m t.λalu'.
50  mk_any_status m t alu' (mem_desc m t s) (chk_desc m t s) (clk_desc m t s).
51
52 (* setter forte della memoria *)
53 ndefinition set_mem_desc ≝
54 λm:mcu_type.λt:memory_impl.λs:any_status m t.λmem':aux_mem_type t.
55  mk_any_status m t (alu m t s) mem' (chk_desc m t s) (clk_desc m t s).
56
57 (* setter forte del descrittore *)
58 ndefinition set_chk_desc ≝
59 λm:mcu_type.λt:memory_impl.λs:any_status m t.λchk':aux_chk_type t.
60  mk_any_status m t (alu m t s) (mem_desc m t s) chk' (clk_desc m t s).
61
62 (* setter forte del clik *)
63 ndefinition set_clk_desc ≝
64 λm:mcu_type.λt:memory_impl.λs:any_status m t.
65 λclk':option (aux_clk_type m).
66  mk_any_status m t (alu m t s) (mem_desc m t s) (chk_desc m t s) clk'.
67
68 (* REGISTRO A *)
69
70 (* setter forte di A *)
71 ndefinition set_acc_8_low_reg ≝
72 λm:mcu_type.λt:memory_impl.λs:any_status m t.λacclow':byte8.
73  set_alu m t s 
74  (match m return aux_set_type byte8 with
75   [ HC05 ⇒ set_acc_8_low_reg_HC05
76   | HC08 ⇒ set_acc_8_low_reg_HC08
77   | HCS08 ⇒ set_acc_8_low_reg_HC08
78   | RS08 ⇒ set_acc_8_low_reg_RS08
79   | IP2022 ⇒ set_acc_8_low_reg_IP2022
80   ] (alu m t s) acclow').
81
82 (* REGISTRO X *)
83
84 (* setter forte di X *)
85 ndefinition set_indX_8_low_reg ≝
86 λm:mcu_type.λt:memory_impl.λs:any_status m t.λindxlow':byte8.
87  opt_map … (match m return aux_set_type_opt byte8 with
88              [ HC05 ⇒ Some ? set_indX_8_low_reg_HC05
89              | HC08 ⇒ Some ? set_indX_8_low_reg_HC08
90              | HCS08 ⇒ Some ? set_indX_8_low_reg_HC08
91              | RS08 ⇒ None ?
92              | IP2022 ⇒ None ? ])
93  (λf.Some ? (set_alu m t s (f (alu m t s) indxlow'))).
94
95 (* setter debole di X *)
96 ndefinition setweak_indX_8_low_reg ≝
97 λm:mcu_type.λt:memory_impl.λs:any_status m t.λindxlow':byte8.
98  match set_indX_8_low_reg m t s indxlow' with
99   [ None ⇒ s | Some s' ⇒ s' ].
100
101 (* REGISTRO H *)
102
103 (* setter forte di H *)
104 ndefinition set_indX_8_high_reg ≝
105 λm:mcu_type.λt:memory_impl.λs:any_status m t.λindxhigh':byte8.
106  opt_map … (match m return aux_set_type_opt byte8 with
107              [ HC05 ⇒ None ?
108              | HC08 ⇒ Some ? set_indX_8_high_reg_HC08
109              | HCS08 ⇒ Some ? set_indX_8_high_reg_HC08
110              | RS08 ⇒ None ?
111              | IP2022 ⇒ None ? ])
112  (λf.Some ? (set_alu m t s (f (alu m t s) indxhigh'))).
113
114 (* setter debole di H *)
115 ndefinition setweak_indX_8_high_reg ≝
116 λm:mcu_type.λt:memory_impl.λs:any_status m t.λindxhigh':byte8.
117  match set_indX_8_high_reg m t s indxhigh' with
118   [ None ⇒ s | Some s' ⇒ s' ].
119
120 (* REGISTRO H:X *)
121
122 (* setter forte di H:X *)
123 ndefinition set_indX_16_reg ≝
124 λm:mcu_type.λt:memory_impl.λs:any_status m t.λindx16:word16.
125  opt_map … (match m return aux_set_type_opt word16 with
126              [ HC05 ⇒ None ?
127              | HC08 ⇒ Some ? set_indX_16_reg_HC08
128              | HCS08 ⇒ Some ? set_indX_16_reg_HC08
129              | RS08 ⇒ None ?
130              | IP2022 ⇒ None ? ])
131  (λf.Some ? (set_alu m t s (f (alu m t s) indx16))).
132
133 (* setter debole di H:X *)
134 ndefinition setweak_indX_16_reg ≝
135 λm:mcu_type.λt:memory_impl.λs:any_status m t.λindx16:word16.
136  match set_indX_16_reg m t s indx16 with
137   [ None ⇒ s | Some s' ⇒ s' ].
138
139 (* REGISTRO SP *)
140
141 (* setter forte di SP *)
142 ndefinition set_sp_reg ≝
143 λm:mcu_type.λt:memory_impl.λs:any_status m t.λsp':word16.
144  opt_map … (match m return aux_set_type_opt word16 with
145              [ HC05 ⇒ Some ? set_sp_reg_HC05
146              | HC08 ⇒ Some ? set_sp_reg_HC08
147              | HCS08 ⇒ Some ? set_sp_reg_HC08
148              | RS08 ⇒ None ?
149              | IP2022 ⇒ Some ? set_sp_reg_IP2022 ])
150  (λf.Some ? (set_alu m t s (f (alu m t s) sp'))).
151
152 (* setter debole di SP *)
153 ndefinition setweak_sp_reg ≝
154 λm:mcu_type.λt:memory_impl.λs:any_status m t.λsp':word16.
155  match set_sp_reg m t s sp' with
156   [ None ⇒ s | Some s' ⇒ s' ].
157
158 (* REGISTRO PC *)
159
160 (* setter forte di PC *)
161 ndefinition set_pc_reg ≝
162 λm:mcu_type.λt:memory_impl.λs:any_status m t.λpc':word16.
163  set_alu m t s 
164  (match m return aux_set_type word16 with
165   [ HC05 ⇒ set_pc_reg_HC05
166   | HC08 ⇒ set_pc_reg_HC08
167   | HCS08 ⇒ set_pc_reg_HC08
168   | RS08 ⇒ set_pc_reg_RS08
169   | IP2022 ⇒ set_pc_reg_IP2022
170   ] (alu m t s) pc').
171
172 (* REGISTRO SPC *)
173
174 (* setter forte di SPC *)
175 ndefinition set_spc_reg ≝
176 λm:mcu_type.λt:memory_impl.λs:any_status m t.λspc':word16.
177  opt_map … (match m return aux_set_type_opt word16 with
178              [ HC05 ⇒ None ?
179              | HC08 ⇒ None ?
180              | HCS08 ⇒ None ?
181              | RS08 ⇒ Some ? set_spc_reg_RS08
182              | IP2022 ⇒ None ? ])
183  (λf.Some ? (set_alu m t s (f (alu m t s) spc'))).
184
185 (* setter debole di SPC *)
186 ndefinition setweak_spc_reg ≝
187 λm:mcu_type.λt:memory_impl.λs:any_status m t.λspc':word16.
188  match set_spc_reg m t s spc' with
189   [ None ⇒ s | Some s' ⇒ s' ].
190
191 (* REGISTRO MULH *)
192
193 (* setter forte di MULH *)
194 ndefinition set_mulh_reg ≝
195 λm:mcu_type.λt:memory_impl.λs:any_status m t.λmulh':byte8.
196  opt_map … (match m return aux_set_type_opt byte8 with
197              [ HC05 ⇒ None ?
198              | HC08 ⇒ None ?
199              | HCS08 ⇒ None ?
200              | RS08 ⇒ None ?
201              | IP2022 ⇒ Some ? set_mulh_reg_IP2022 ])
202  (λf.Some ? (set_alu m t s (f (alu m t s) mulh'))).
203
204 (* setter debole di MULH *)
205 ndefinition setweak_mulh_reg ≝
206 λm:mcu_type.λt:memory_impl.λs:any_status m t.λmulh':byte8.
207  match set_mulh_reg m t s mulh' with
208   [ None ⇒ s | Some s' ⇒ s' ].
209
210 (* REGISTRO ADDRSEL *)
211
212 (* setter forte di ADDRSEL *)
213 ndefinition set_addrsel_reg ≝
214 λm:mcu_type.λt:memory_impl.λs:any_status m t.λaddrsel':byte8.
215  opt_map … (match m return aux_set_type_opt byte8 with
216              [ HC05 ⇒ None ?
217              | HC08 ⇒ None ?
218              | HCS08 ⇒ None ?
219              | RS08 ⇒ None ?
220              | IP2022 ⇒ Some ? set_addrsel_reg_IP2022 ])
221  (λf.Some ? (set_alu m t s (f (alu m t s) addrsel'))).
222
223 (* setter debole di ADDRSEL *)
224 ndefinition setweak_addrsel_reg ≝
225 λm:mcu_type.λt:memory_impl.λs:any_status m t.λaddrsel':byte8.
226  match set_addrsel_reg m t s addrsel' with
227   [ None ⇒ s | Some s' ⇒ s' ].
228
229 (* REGISTRO ADDR *)
230
231 (* setter forte di ADDR *)
232 ndefinition set_addr_reg ≝
233 λm:mcu_type.λt:memory_impl.λs:any_status m t.λaddr':word24.
234  opt_map … (match m return aux_set_type_opt word24 with
235              [ HC05 ⇒ None ?
236              | HC08 ⇒ None ?
237              | HCS08 ⇒ None ?
238              | RS08 ⇒ None ?
239              | IP2022 ⇒ Some ? set_addr_reg_IP2022 ])
240  (λf.Some ? (set_alu m t s (f (alu m t s) addr'))).
241
242 (* setter debole di ADDR *)
243 ndefinition setweak_addr_reg ≝
244 λm:mcu_type.λt:memory_impl.λs:any_status m t.λaddr':word24.
245  match set_addr_reg m t s addr' with
246   [ None ⇒ s | Some s' ⇒ s' ].
247
248 (* REGISTRO CALL *)
249
250 (* setter forte di CALL *)
251 ndefinition set_call_reg ≝
252 λm:mcu_type.λt:memory_impl.λs:any_status m t.λcall':word16.
253  opt_map … (match m return aux_set_type_opt word16 with
254              [ HC05 ⇒ None ?
255              | HC08 ⇒ None ?
256              | HCS08 ⇒ None ?
257              | RS08 ⇒ None ?
258              | IP2022 ⇒ Some ? set_call_reg_IP2022 ])
259  (λf.Some ? (set_alu m t s (f (alu m t s) call'))).
260
261 (* setter debole di CALL *)
262 ndefinition setweak_call_reg ≝
263 λm:mcu_type.λt:memory_impl.λs:any_status m t.λcall':word16.
264  match set_call_reg m t s call' with
265   [ None ⇒ s | Some s' ⇒ s' ].
266
267 (* push forte di CALL *)
268 ndefinition push_call_reg ≝
269 λm:mcu_type.λt:memory_impl.λs:any_status m t.λcall':word16.
270  opt_map … (match m return aux_set_type_opt word16 with
271              [ HC05 ⇒ None ?
272              | HC08 ⇒ None ?
273              | HCS08 ⇒ None ?
274              | RS08 ⇒ None ?
275              | IP2022 ⇒ Some ? push_call_reg_IP2022 ])
276  (λf.Some ? (set_alu m t s (f (alu m t s) call'))).
277
278 (* push debole di CALL *)
279 ndefinition pushweak_call_reg ≝
280 λm:mcu_type.λt:memory_impl.λs:any_status m t.λcall':word16.
281  match push_call_reg m t s call' with
282   [ None ⇒ s | Some s' ⇒ s' ].
283
284 (* REGISTRO IP *)
285
286 (* setter forte di IP *)
287 ndefinition set_ip_reg ≝
288 λm:mcu_type.λt:memory_impl.λs:any_status m t.λip':word16.
289  opt_map … (match m return aux_set_type_opt word16 with
290              [ HC05 ⇒ None ?
291              | HC08 ⇒ None ?
292              | HCS08 ⇒ None ?
293              | RS08 ⇒ None ?
294              | IP2022 ⇒ Some ? set_ip_reg_IP2022 ])
295  (λf.Some ? (set_alu m t s (f (alu m t s) ip'))).
296
297 (* setter debole di IP *)
298 ndefinition setweak_ip_reg ≝
299 λm:mcu_type.λt:memory_impl.λs:any_status m t.λip':word16.
300  match set_ip_reg m t s ip' with
301   [ None ⇒ s | Some s' ⇒ s' ].
302
303 (* REGISTRO DP *)
304
305 (* setter forte di DP *)
306 ndefinition set_dp_reg ≝
307 λm:mcu_type.λt:memory_impl.λs:any_status m t.λdp':word16.
308  opt_map … (match m return aux_set_type_opt word16 with
309              [ HC05 ⇒ None ?
310              | HC08 ⇒ None ?
311              | HCS08 ⇒ None ?
312              | RS08 ⇒ None ?
313              | IP2022 ⇒ Some ? set_dp_reg_IP2022 ])
314  (λf.Some ? (set_alu m t s (f (alu m t s) dp'))).
315
316 (* setter debole di DP *)
317 ndefinition setweak_dp_reg ≝
318 λm:mcu_type.λt:memory_impl.λs:any_status m t.λdp':word16.
319  match set_dp_reg m t s dp' with
320   [ None ⇒ s | Some s' ⇒ s' ].
321
322 (* REGISTRO DATA *)
323
324 (* setter forte di DATA *)
325 ndefinition set_data_reg ≝
326 λm:mcu_type.λt:memory_impl.λs:any_status m t.λdata':word16.
327  opt_map … (match m return aux_set_type_opt word16 with
328              [ HC05 ⇒ None ?
329              | HC08 ⇒ None ?
330              | HCS08 ⇒ None ?
331              | RS08 ⇒ None ?
332              | IP2022 ⇒ Some ? set_data_reg_IP2022 ])
333  (λf.Some ? (set_alu m t s (f (alu m t s) data'))).
334
335 (* setter debole di DATA *)
336 ndefinition setweak_data_reg ≝
337 λm:mcu_type.λt:memory_impl.λs:any_status m t.λdata':word16.
338  match set_data_reg m t s data' with
339   [ None ⇒ s | Some s' ⇒ s' ].
340
341 (* REGISTRO SPEED *)
342
343 (* setter forte di SPEED *)
344 ndefinition set_speed_reg ≝
345 λm:mcu_type.λt:memory_impl.λs:any_status m t.λspeed':exadecim.
346  opt_map … (match m return aux_set_type_opt exadecim with
347              [ HC05 ⇒ None ?
348              | HC08 ⇒ None ?
349              | HCS08 ⇒ None ?
350              | RS08 ⇒ None ?
351              | IP2022 ⇒ Some ? set_speed_reg_IP2022 ])
352  (λf.Some ? (set_alu m t s (f (alu m t s) speed'))).
353
354 (* setter debole di SPEED *)
355 ndefinition setweak_speed_reg ≝
356 λm:mcu_type.λt:memory_impl.λs:any_status m t.λspeed':exadecim.
357  match set_speed_reg m t s speed' with
358   [ None ⇒ s | Some s' ⇒ s' ].
359
360 (* REGISTRO PAGE *)
361
362 (* setter forte di PAGE *)
363 ndefinition set_page_reg ≝
364 λm:mcu_type.λt:memory_impl.λs:any_status m t.λpage':oct.
365  opt_map … (match m return aux_set_type_opt oct with
366              [ HC05 ⇒ None ?
367              | HC08 ⇒ None ?
368              | HCS08 ⇒ None ?
369              | RS08 ⇒ None ?
370              | IP2022 ⇒ Some ? set_page_reg_IP2022 ])
371  (λf.Some ? (set_alu m t s (f (alu m t s) page'))).
372
373 (* setter debole di PAGE *)
374 ndefinition setweak_page_reg ≝
375 λm:mcu_type.λt:memory_impl.λs:any_status m t.λpage':oct.
376  match set_page_reg m t s page' with
377   [ None ⇒ s | Some s' ⇒ s' ].
378
379 (* REGISTRO MEMORY MAPPED X *)
380
381 (* setter forte di memory mapped X *)
382 ndefinition set_x_map ≝
383 λm:mcu_type.λt:memory_impl.λs:any_status m t.λxm':byte8.
384  opt_map … (match m return aux_set_type_opt byte8 with
385              [ HC05 ⇒ None ?
386              | HC08 ⇒ None ?
387              | HCS08 ⇒ None ?
388              | RS08 ⇒ Some ? set_x_map_RS08
389              | IP2022 ⇒ None ? ])
390  (λf.Some ? (set_alu m t s (f (alu m t s) xm'))).
391
392 (* setter debole di memory mapped X *)
393 ndefinition setweak_x_map ≝
394 λm:mcu_type.λt:memory_impl.λs:any_status m t.λxm':byte8.
395  match set_x_map m t s xm' with
396   [ None ⇒ s | Some s' ⇒ s' ].
397
398 (* REGISTRO MEMORY MAPPED PS *)
399
400 (* setter forte di memory mapped PS *)
401 ndefinition set_ps_map ≝
402 λm:mcu_type.λt:memory_impl.λs:any_status m t.λpsm':byte8.
403  opt_map … (match m return aux_set_type_opt byte8 with
404              [ HC05 ⇒ None ?
405              | HC08 ⇒ None ?
406              | HCS08 ⇒ None ?
407              | RS08 ⇒ Some ? set_ps_map_RS08
408              | IP2022 ⇒ None ? ])
409  (λf.Some ? (set_alu m t s (f (alu m t s) psm'))).
410
411 (* setter debole di memory mapped PS *)
412 ndefinition setweak_ps_map ≝
413 λm:mcu_type.λt:memory_impl.λs:any_status m t.λpsm':byte8.
414  match set_ps_map m t s psm' with
415   [ None ⇒ s | Some s' ⇒ s' ].
416
417 (* MODALITA SKIP *)
418
419 (* setter forte di SKIP *)
420 ndefinition set_skip_mode ≝
421 λm:mcu_type.λt:memory_impl.λs:any_status m t.λskipmode':bool.
422  opt_map … (match m return aux_set_type_opt bool with
423              [ HC05 ⇒ None ?
424              | HC08 ⇒ None ?
425              | HCS08 ⇒ None ?
426              | RS08 ⇒ None ?
427              | IP2022 ⇒ Some ? set_skip_mode_IP2022 ])
428  (λf.Some ? (set_alu m t s (f (alu m t s) skipmode'))).
429
430 (* setter debole  di SKIP *)
431 ndefinition setweak_skip_mode ≝
432 λm:mcu_type.λt:memory_impl.λs:any_status m t.λskipmode':bool.
433  match set_skip_mode m t s skipmode' with
434   [ None ⇒ s | Some s' ⇒ s' ].
435
436 (* FLAG V *)
437
438 (* setter forte di V *)
439 ndefinition set_v_flag ≝
440 λm:mcu_type.λt:memory_impl.λs:any_status m t.λvfl':bool.
441  opt_map … (match m return aux_set_type_opt bool with
442              [ HC05 ⇒ None ?
443              | HC08 ⇒ Some ? set_v_flag_HC08
444              | HCS08 ⇒ Some ? set_v_flag_HC08
445              | RS08 ⇒ None ?
446              | IP2022 ⇒ None ? ])
447  (λf.Some ? (set_alu m t s (f (alu m t s) vfl'))).
448
449 (* setter debole  di V *)
450 ndefinition setweak_v_flag ≝
451 λm:mcu_type.λt:memory_impl.λs:any_status m t.λvfl':bool.
452  match set_v_flag m t s vfl' with
453   [ None ⇒ s | Some s' ⇒ s' ].
454
455 (* FLAG H *)
456
457 (* setter forte di H *)
458 ndefinition set_h_flag ≝
459 λm:mcu_type.λt:memory_impl.λs:any_status m t.λhfl':bool.
460  opt_map … (match m return aux_set_type_opt bool with
461              [ HC05 ⇒ Some ? set_h_flag_HC05
462              | HC08 ⇒ Some ? set_h_flag_HC08
463              | HCS08 ⇒ Some ? set_h_flag_HC08
464              | RS08 ⇒ None ?
465              | IP2022 ⇒ Some ? set_h_flag_IP2022 ])
466  (λf.Some ? (set_alu m t s (f (alu m t s) hfl'))).
467
468 (* setter debole di H *)
469 ndefinition setweak_h_flag ≝
470 λm:mcu_type.λt:memory_impl.λs:any_status m t.λhfl':bool.
471  match set_h_flag m t s hfl' with
472   [ None ⇒ s | Some s' ⇒ s' ].
473
474 (* FLAG I *)
475
476 (* setter forte di I *)
477 ndefinition set_i_flag ≝
478 λm:mcu_type.λt:memory_impl.λs:any_status m t.λifl':bool.
479  opt_map … (match m return aux_set_type_opt bool with
480              [ HC05 ⇒ Some ? set_i_flag_HC05
481              | HC08 ⇒ Some ? set_i_flag_HC08
482              | HCS08 ⇒ Some ? set_i_flag_HC08
483              | RS08 ⇒ None ?
484              | IP2022 ⇒ None ? ])
485  (λf.Some ? (set_alu m t s (f (alu m t s) ifl'))).
486
487 (* setter debole di I *)
488 ndefinition setweak_i_flag ≝
489 λm:mcu_type.λt:memory_impl.λs:any_status m t.λifl':bool.
490  match set_i_flag m t s ifl' with
491   [ None ⇒ s | Some s' ⇒ s' ].
492
493 (* FLAG N *)
494
495 (* setter forte di N *)
496 ndefinition set_n_flag ≝
497 λm:mcu_type.λt:memory_impl.λs:any_status m t.λnfl':bool.
498  opt_map … (match m return aux_set_type_opt bool with
499              [ HC05 ⇒ Some ? set_n_flag_HC05
500              | HC08 ⇒ Some ? set_n_flag_HC08
501              | HCS08 ⇒ Some ? set_n_flag_HC08
502              | RS08 ⇒ None ?
503              | IP2022 ⇒ None ? ])
504  (λf.Some ? (set_alu m t s (f (alu m t s) nfl'))).
505
506 (* setter debole di N *)
507 ndefinition setweak_n_flag ≝
508 λm:mcu_type.λt:memory_impl.λs:any_status m t.λnfl':bool.
509  match set_n_flag m t s nfl' with
510   [ None ⇒ s | Some s' ⇒ s' ].
511
512 (* FLAG Z *)
513
514 (* setter forte di Z *)
515 ndefinition set_z_flag ≝
516 λm:mcu_type.λt:memory_impl.λs:any_status m t.λzfl':bool.
517  set_alu m t s 
518  (match m return aux_set_type bool with
519   [ HC05 ⇒ set_z_flag_HC05
520   | HC08 ⇒ set_z_flag_HC08
521   | HCS08 ⇒ set_z_flag_HC08
522   | RS08 ⇒ set_z_flag_RS08
523   | IP2022 ⇒ set_z_flag_IP2022
524   ] (alu m t s) zfl').
525
526 (* FLAG C *)
527
528 (* setter forte di C *)
529 ndefinition set_c_flag ≝
530 λm:mcu_type.λt:memory_impl.λs:any_status m t.λcfl':bool.
531  set_alu m t s 
532  (match m return aux_set_type bool with
533   [ HC05 ⇒ set_c_flag_HC05
534   | HC08 ⇒ set_c_flag_HC08
535   | HCS08 ⇒ set_c_flag_HC08
536   | RS08 ⇒ set_c_flag_RS08
537   | IP2022 ⇒ set_c_flag_IP2022
538   ] (alu m t s) cfl').
539
540 (* FLAG IRQ *)
541
542 (* setter forte di IRQ *)
543 ndefinition set_irq_flag ≝
544 λm:mcu_type.λt:memory_impl.λs:any_status m t.λirqfl':bool.
545  opt_map … (match m return aux_set_type_opt bool with
546              [ HC05 ⇒ Some ? set_irq_flag_HC05
547              | HC08 ⇒ Some ? set_irq_flag_HC08
548              | HCS08 ⇒ Some ? set_irq_flag_HC08
549              | RS08 ⇒ None ?
550              | IP2022 ⇒ None ? ])
551  (λf.Some ? (set_alu m t s (f (alu m t s) irqfl'))).
552
553 (* setter debole di IRQ *)
554 ndefinition setweak_irq_flag ≝
555 λm:mcu_type.λt:memory_impl.λs:any_status m t.λirqfl':bool.
556  match set_irq_flag m t s irqfl' with
557   [ None ⇒ s | Some s' ⇒ s' ].