+++ /dev/null
-(**************************************************************************)
-(* ___ *)
-(* ||M|| *)
-(* ||A|| A project by Andrea Asperti *)
-(* ||T|| *)
-(* ||I|| Developers: *)
-(* ||T|| The HELM team. *)
-(* ||A|| http://helm.cs.unibo.it *)
-(* \ / *)
-(* \ / This file is distributed under the terms of the *)
-(* v GNU General Public License Version 2 *)
-(* *)
-(**************************************************************************)
-
-(* ********************************************************************** *)
-(* Progetto FreeScale *)
-(* *)
-(* Sviluppato da: Ing. Cosimo Oliboni, oliboni@cs.unibo.it *)
-(* Ultima modifica: 05/08/2009 *)
-(* *)
-(* ********************************************************************** *)
-
-include "freescale_tests/micro_tests_tools.ma".
-include "freescale/multivm.ma".
-include "freescale/status_lemmas.ma".
-include "common/nat_to_num.ma".
-
-(* ****************************************** *)
-(* MICRO TEST DI CORRETTEZZA DELLE ISTRUZIONI *)
-(* ****************************************** *)
-
-(* ********************* *)
-(* TEOREMA MULT PER RS08 *)
-(* ********************* *)
-
-ndefinition mTest_RS08_mult_source ≝ let m ≝ RS08 in source_to_byte8 m (
-(*
- ZH:ZL=X*Y con [0x0020-0x004F] X ≝ [0x0020] Y ≝ [0x0021] ZH ≝ [0x0022] ZL ≝ [0x0023]
-*)
-(* [0x3800] ZH <- 0 3clk *) (compile m ? CLR (maDIR1 〈x2,x2〉) I) @
-(* [0x3802] ZL <- 0 3clk *) (compile m ? CLR (maDIR1 〈x2,x3〉) I) @
-(* [0x3804] (l1) A <- Y 3clk *) (compile m ? LDA (maDIR1 〈x2,x1〉) I) @
-(* [0x3806] A=0 goto l2 3clk *) (compile m ? BEQ (maIMM1 〈x0,xE〉) I) @
-(* [0x3808] A <- ZL 3clk *) (compile m ? LDA (maDIR1 〈x2,x3〉) I) @
-(* [0x380A] Y -- 5clk *) (compile m ? DEC (maDIR1 〈x2,x1〉) I) @
-(* [0x380C] A += X 3clk *) (compile m ? ADD (maDIR1 〈x2,x0〉) I) @
-(* [0x380E] C=0 goto l3 3clk *) (compile m ? BCC (maIMM1 〈x0,x2〉) I) @
-(* [0x3810] ZH ++ 5clk *) (compile m ? INC (maDIR1 〈x2,x2〉) I) @
-(* [0x3812] (l3) ZL <- A 3clk *) (compile m ? STA (maDIR1 〈x2,x3〉) I) @
-(* [0x3814] goto l1 3clk *) (compile m ? BRA (maIMM1 〈xE,xE〉) I)
-(* [0x3816] (l2) si puo' quindi enunciare che
- - il caso base X * 0 richiede 12 cicli
- - bisogna aggiungere Y * 26 cicli, Y>0
- - bisogna aggiungere ZH * 5 cicli, X * Y > 0xFF *)
-).
-
-(* creazione del processore+caricamento+impostazione registri *)
-ndefinition mTest_RS08_mult_status ≝
-λt:memory_impl.
-λb1,b2,b3,b4:byte8.
- set_z_flag RS08 t (* Z<-true *)
- (set_pc_reg RS08 t (* PC<-mTest_RS08_prog *)
- (start_of_mcu_version_RS08
- MC9RS08KA2 t
- (load_from_source_at t (* carica X,Y,ZH,ZL:mTest_RS08_RAM *)
- (load_from_source_at t (zero_memory t) (* carica source in ROM:mTest_RS08_prog *)
- mTest_RS08_mult_source mTest_RS08_prog)
- [ b1 ; b2 ; b3 ; b4 ] mTest_RS08_RAM)
- (build_memory_type_of_mcu_version (FamilyRS08 MC9RS08KA2) t)
- (mk_byte8 x0 x0) (mk_byte8 x0 x0) (* non deterministici tutti a 0 *)
- false false false false false false (* non deterministici tutti a 0 *)
- ) mTest_RS08_prog)
- true.
-
-(* parametrizzazione dell'enunciato del teorema mult *)
-(* NB: la memoria e' cambiata e bisogna applicare eq_status *)
-ndefinition ok_mTest_RS08_mult_full_aux ≝
-λt:memory_impl.λX,Y:byte8.
- eq_anystatus RS08 t
- (match execute RS08 t (TickOK ? (mTest_RS08_mult_status t X Y 〈x0,x0〉 〈x0,x0〉))
- (nat12 + (nat26 * (nat_of_b8 Y)) + (nat5 * (nat_of_b8 (w16h (mul_b8 X Y)))))
- (* FIXME: alla ALU azzero C perche' la funzione che ne descrive il valore finale e' MOLTO complessa *)
- with [ TickERR s _ ⇒ s | TickSUSP s _ ⇒ s | TickOK s ⇒ set_c_flag RS08 t s false ])
- (set_pc_reg RS08 t (mTest_RS08_mult_status t X 〈x0,x0〉 (w16h (mul_b8 X Y)) (w16l (mul_b8 X Y))) 〈〈x3,x8〉:〈x1,x6〉〉)
- (* controllo che coincidano X,Y,ZH,ZL *)
- [ 〈〈x0,x0〉:〈x2,x0〉〉 ; 〈〈x0,x0〉:〈x2,x1〉〉 ; 〈〈x0,x0〉:〈x2,x2〉〉 ; 〈〈x0,x0〉:〈x2,x3〉〉 ] = true.
-
-nlemma ok_mTest_RS08_mult_full :
-let X ≝ 〈xF,xF〉 in
-let Y ≝ 〈x1,xE〉 in
- ∀t:memory_impl.
- ok_mTest_RS08_mult_full_aux t X Y.
- #t;
- nletin X ≝ (〈xF,xF〉);
- nletin Y ≝ (〈x1,xE〉);
- napply (eq_to_eqanystatus_weak [ 〈〈x0,x0〉:〈x2,x0〉〉 ; 〈〈x0,x0〉:〈x2,x1〉〉 ; 〈〈x0,x0〉:〈x2,x2〉〉 ; 〈〈x0,x0〉:〈x2,x3〉〉 ] RS08 t
- (match execute RS08 t (TickOK ? (mTest_RS08_mult_status t X Y 〈x0,x0〉 〈x0,x0〉))
- (nat12 + (nat26 * (nat_of_b8 Y)) + (nat5 * (nat_of_b8 (w16h (mul_b8 X Y)))))
- with [ TickERR s _ ⇒ s | TickSUSP s _ ⇒ s | TickOK s ⇒ set_c_flag RS08 t s false ])
- (set_pc_reg RS08 t (mTest_RS08_mult_status t X 〈x0,x0〉 (w16h (mul_b8 X Y)) (w16l (mul_b8 X Y))) 〈〈x3,x8〉:〈x1,x6〉〉));
- nelim t;
- nnormalize in ⊢ (? ? ? %);
- napply refl_eq.
-nqed.