Skip to content
Snippets Groups Projects
Commit 22a16c7b authored by Florian Brandner's avatar Florian Brandner
Browse files

correct T_RC parameter for FIFO, some more proofs.

parent 7b480278
No related branches found
No related tags found
No related merge requests found
Set Warnings "-notation-overridden,-parsing". Set Warnings "-notation-overridden,-parsing".
From mathcomp Require Export ssreflect ssrnat ssrbool seq. From mathcomp Require Export ssreflect ssrnat ssrbool seq eqtype.
Definition Bank_number_t := {B : nat | B <> 0}.
Definition Timing_parameter_t := {T : nat | T <> 0}.
Class Bank_configuration := Class Bank_configuration :=
{ {
BANKS : Bank_number_t; BANKS : nat;
T_RC : nat; (* ACT to ACT delay intra-bank *)
T_RC : Timing_parameter_t (* ACT to ACT delay intra-bank *) BANKS_pos : BANKS != 0;
T_RC_pos : T_RC != 0
}. }.
Section Banks. Section Banks.
Context {BANK_CFG : Bank_configuration}. Context {BANK_CFG : Bank_configuration}.
Definition BANKS_NAT := proj1_sig BANKS. Definition Bank_t := { a : nat | a < BANKS }.
Definition T_RC_NAT := proj1_sig T_RC.
Definition Bank_t := { a : nat | a < BANKS_NAT }.
Program Definition Nat_to_bank a : Bank_t := Program Definition Nat_to_bank a : Bank_t :=
match a < BANKS_NAT with match a < BANKS with
| true => (exist _ a _) | true => (exist _ a _)
| false => (exist _ (BANKS_NAT - 1) _) | false => (exist _ (BANKS - 1) _)
end. end.
Next Obligation. Next Obligation.
unfold BANKS_NAT in *. rewrite subn1 ltn_predL lt0n.
destruct BANKS. simpl in *. by specialize BANKS_pos.
apply PeanoNat.Nat.lt_pred_l in n as H. move : H => /ltP H. by rewrite subn1.
Qed. Qed.
Definition Bank_to_nat (a : Bank_t) : nat := Definition Bank_to_nat (a : Bank_t) : nat :=
proj1_sig a. proj1_sig a.
Notation "'#B' b" := (Nat_to_bank b) (only parsing, at level 0).
Notation "'#B' b" := ((exist _ b _) Bank_t) (only printing, at level 0).
Definition Banks_t := seq Bank_t. Definition Banks_t := seq Bank_t.
Definition All_banks : Banks_t := Definition All_banks : Banks_t :=
map Nat_to_bank (iota 0 BANKS_NAT). map Nat_to_bank (iota 0 BANKS).
End Banks. End Banks.
...@@ -71,6 +71,9 @@ Section Commands. ...@@ -71,6 +71,9 @@ Section Commands.
| WR => CWR | WR => CWR
end. end.
Definition isACT (cmd : Command_t) :=
cmd.(CKind) == ACT.
Definition PRE_of_req req t := Definition PRE_of_req req t :=
mkCmd t PRE req. mkCmd t PRE req.
...@@ -80,6 +83,17 @@ Section Commands. ...@@ -80,6 +83,17 @@ Section Commands.
Definition Cmd_of_req req t := Definition Cmd_of_req req t :=
mkCmd t (Kind_of_req req) req. mkCmd t (Kind_of_req req) req.
Lemma Command_nisACT_PRE req t: ~ isACT (PRE_of_req req t).
Proof.
by unfold isACT, PRE_of_req.
Qed.
Lemma Command_nisACT_CMD req t: ~ isACT (Cmd_of_req req t).
Proof.
unfold isACT, Cmd_of_req, Kind_of_req.
by destruct (Kind req).
Qed.
Lemma Command_neq_ACT_PRE reqa ta reqb tb: Lemma Command_neq_ACT_PRE reqa ta reqb tb:
(ACT_of_req reqa ta) != (PRE_of_req reqb tb). (ACT_of_req reqa ta) != (PRE_of_req reqb tb).
Proof. Proof.
......
...@@ -7,8 +7,12 @@ Section FIFO. ...@@ -7,8 +7,12 @@ Section FIFO.
Class FIFO_configuration := Class FIFO_configuration :=
{ {
FIFO_wait : {T : nat | 3 < T (* have to issue at least 3 commands *) FIFO_wait : nat;
/\ T_RC_NAT <= T (* have to respect T_RC *)}
(* have to issue at least 3 commands *)
FIFO_cmds : 3 < FIFO_wait;
(* have to respect T_RC *)
FIFO_T_RC : T_RC < FIFO_wait;
}. }.
Context {FIFO_CFG : FIFO_configuration }. Context {FIFO_CFG : FIFO_configuration }.
...@@ -19,8 +23,7 @@ Section FIFO. ...@@ -19,8 +23,7 @@ Section FIFO.
Time : nat; Time : nat;
}. }.
Local Definition FIFO_req req State : FIFO_state_t :=
Local Program Definition FIFO_req req State : FIFO_state_t :=
let time := maxn State.(Time) req.(Date) in let time := maxn State.(Time) req.(Date) in
let PRE_date := time + 1 in let PRE_date := time + 1 in
let ACT_date := time + 2 in let ACT_date := time + 2 in
...@@ -40,33 +43,39 @@ Section FIFO. ...@@ -40,33 +43,39 @@ Section FIFO.
Lemma FIFO_trace_time_monotone req Reqs: Lemma FIFO_trace_time_monotone req Reqs:
(FIFO_trace Reqs).(Time) < (FIFO_trace (req::Reqs)).(Time). (FIFO_trace Reqs).(Time) < (FIFO_trace (req::Reqs)).(Time).
Proof. Proof.
simpl. destruct FIFO_wait. simpl. simpl.
apply proj1 in a as H. specialize FIFO_cmds as H.
apply ltn_trans with (m := 0) in H. apply ltn_trans with (m := 0) in H.
by move : H => /nat_ltmaxn_l_add H. - by move : H => /nat_ltmaxn_l_add H.
auto. - auto.
Qed.
Lemma FIFO_trace_dist req Reqs:
(FIFO_trace Reqs).(Time) + FIFO_wait <= (FIFO_trace (req::Reqs)).(Time).
Proof.
simpl.
apply nat_le_add_lemaxn_add.
apply leqnn.
Qed. Qed.
Lemma FIFO_trace_time_ok Reqs: Lemma FIFO_trace_time_ok Reqs:
forall cmd, cmd \in (FIFO_trace Reqs).(Cmds) -> cmd.(CDate) <= (FIFO_trace Reqs).(Time). forall cmd, cmd \in (FIFO_trace Reqs).(Cmds) -> cmd.(CDate) <= (FIFO_trace Reqs).(Time).
Proof. Proof.
intros. intros.
specialize FIFO_cmds as Hc.
induction Reqs. induction Reqs.
- auto. - auto.
- simpl. destruct FIFO_wait. simpl in *. - simpl in *.
rewrite -> 3 in_cons in H. rewrite -> 3 in_cons in H.
move : H => /orP [/eqP H | /orP [ /eqP H | /orP [/eqP H | H]]]; subst; simpl. move : H => /orP [/eqP H | /orP [ /eqP H | /orP [/eqP H | H]]]; subst; simpl.
- rewrite leq_add2l. - rewrite leq_add2l.
apply proj1 in a0 as H. by apply ltn_trans with (m := 2) in Hc.
by apply ltn_trans with (m := 2) in H.
- rewrite leq_add2l. - rewrite leq_add2l.
apply proj1 in a0 as H. by apply ltn_trans with (m := 1) in Hc.
by apply ltn_trans with (m := 1) in H.
- rewrite leq_add2l. - rewrite leq_add2l.
apply proj1 in a0 as H. by apply ltn_trans with (m := 0) in Hc.
by apply ltn_trans with (m := 0) in H.
- apply IHReqs in H. - apply IHReqs in H.
by apply nat_le_lemaxn_add with (x := x) (o := (Date a)) in H. by apply nat_le_lemaxn_add with (x := FIFO_wait) (o := (Date a)) in H.
Qed. Qed.
Lemma FIFO_trace_cmd_notin cmd Reqs: Lemma FIFO_trace_cmd_notin cmd Reqs:
...@@ -84,6 +93,7 @@ Section FIFO. ...@@ -84,6 +93,7 @@ Section FIFO.
Lemma FIFO_trace_uniq req Reqs: Lemma FIFO_trace_uniq req Reqs:
is_true (uniq (FIFO_trace Reqs).(Cmds)) -> is_true (uniq (FIFO_trace (req::Reqs)).(Cmds)). is_true (uniq (FIFO_trace Reqs).(Cmds)) -> is_true (uniq (FIFO_trace (req::Reqs)).(Cmds)).
Proof.
intros. intros.
simpl. simpl.
apply /andP; split. apply /andP; split.
...@@ -107,9 +117,8 @@ Section FIFO. ...@@ -107,9 +117,8 @@ Section FIFO.
Lemma FIFO_trace_T_RC_ok Reqs: Lemma FIFO_trace_T_RC_ok Reqs:
forall a b, a \in (FIFO_trace Reqs).(Cmds) -> b \in (FIFO_trace Reqs).(Cmds) -> forall a b, a \in (FIFO_trace Reqs).(Cmds) -> b \in (FIFO_trace Reqs).(Cmds) ->
ACT_to_ACT a b -> Same_Bank a b -> Before a b -> ACT_to_ACT a b -> Same_Bank a b -> Before a b ->
Apart a b T_RC_NAT. Apart a b T_RC.
Proof. Proof.
set T := (FIFO_trace (Reqs)).(Time).
induction Reqs as [| req Reqs']. induction Reqs as [| req Reqs'].
- auto. - auto.
- intros a b Ia Ib AtA SB aBb. - intros a b Ia Ib AtA SB aBb.
...@@ -151,7 +160,15 @@ Section FIFO. ...@@ -151,7 +160,15 @@ Section FIFO.
- contradict AtA. subst a. - contradict AtA. subst a.
unfold ACT_to_ACT, isACT, Cmd_of_req, Kind_of_req. simpl. unfold ACT_to_ACT, isACT, Cmd_of_req, Kind_of_req. simpl.
by destruct (Kind req). by destruct (Kind req).
- admit. - contradict aBb. subst a.
apply /negP.
unfold Before, ACT_of_req. rewrite <- leqNgt. simpl.
apply (FIFO_trace_time_ok Reqs') in Ib.
apply leq_trans with (p := maxn (Time (FIFO_trace Reqs')) (Date req)) in Ib.
- apply leq_add with (m2 := 0) (n2 := 2) in Ib.
- by rewrite addn0 in Ib.
- by apply leq0n.
apply leq_maxl.
- contradict AtA. subst a. - contradict AtA. subst a.
unfold ACT_to_ACT, isACT, Cmd_of_req, Kind_of_req. simpl. unfold ACT_to_ACT, isACT, Cmd_of_req, Kind_of_req. simpl.
by destruct (Kind req). by destruct (Kind req).
...@@ -162,11 +179,12 @@ Section FIFO. ...@@ -162,11 +179,12 @@ Section FIFO.
let State := FIFO_trace Requests in let State := FIFO_trace Requests in
mkTrace State.(Cmds) State.(Time) _ (FIFO_trace_time_ok Requests) (FIFO_trace_T_RC_ok Requests). mkTrace State.(Cmds) State.(Time) _ (FIFO_trace_time_ok Requests) (FIFO_trace_T_RC_ok Requests).
Next Obligation. Next Obligation.
induction Requests; auto. induction Requests.
by apply (FIFO_trace_uniq a) in IHl. - auto.
- by apply (FIFO_trace_uniq a) in IHl.
Qed. Qed.
Program Lemma FIFO_arbiter_handled req: Lemma FIFO_arbiter_handled req:
req \in Requests -> exists cmd : Command_t, cmd \in FIFO_arbitrate.(Commands) -> req \in Requests -> exists cmd : Command_t, cmd \in FIFO_arbitrate.(Commands) ->
Match req cmd. Match req cmd.
Proof. Proof.
...@@ -229,7 +247,7 @@ Section Test. ...@@ -229,7 +247,7 @@ Section Test.
- by contradict Ha. - by contradict Ha.
Qed. Qed.
Definition test (A := FIFO_arbiter) :=Arbitrate.(Commands). Definition test (Input : Requests_t) (A := FIFO_arbiter) := Arbitrate.(Commands).
Compute test. Compute test Input.
End Test. End Test.
...@@ -20,8 +20,8 @@ Section Requests. ...@@ -20,8 +20,8 @@ Section Requests.
Proof. Proof.
unfold Equality.axiom. intros. unfold Equality.axiom. intros.
destruct (Request_kind_eqdef x y) eqn:H; unfold Request_kind_eqdef in *. destruct (Request_kind_eqdef x y) eqn:H; unfold Request_kind_eqdef in *.
apply ReflectT. destruct x, y; inversion H; auto. - apply ReflectT. destruct x, y; inversion H; auto.
apply ReflectF; destruct x, y; inversion H; unfold not; intros; inversion H0. - apply ReflectF; destruct x, y; inversion H; unfold not; intros; inversion H0.
Qed. Qed.
Canonical Request_kind_eqMixin := EqMixin Request_kind_eqn. Canonical Request_kind_eqMixin := EqMixin Request_kind_eqn.
......
...@@ -5,9 +5,6 @@ From sdram Require Export Commands Bank. ...@@ -5,9 +5,6 @@ From sdram Require Export Commands Bank.
Section Trace. Section Trace.
Context {BANK_CFG : Bank_configuration}. Context {BANK_CFG : Bank_configuration}.
Definition isACT (cmd : Command_t) :=
cmd.(CKind) == ACT.
Definition Same_Bank (a b : Command_t) := Definition Same_Bank (a b : Command_t) :=
a.(Request).(Bank) == b.(Request).(Bank). a.(Request).(Bank) == b.(Request).(Bank).
...@@ -34,7 +31,7 @@ Section Trace. ...@@ -34,7 +31,7 @@ Section Trace.
(* Ensure that the time between two ACT commands respects T_RC *) (* Ensure that the time between two ACT commands respects T_RC *)
Cmds_T_RC_ok : forall a b, a \in Commands -> b \in Commands -> Cmds_T_RC_ok : forall a b, a \in Commands -> b \in Commands ->
ACT_to_ACT a b -> Same_Bank a b -> Before a b -> ACT_to_ACT a b -> Same_Bank a b -> Before a b ->
Apart a b T_RC_NAT; Apart a b T_RC;
}. }.
Program Definition Trace_empty := mkTrace [::] 0 _ _ _. Program Definition Trace_empty := mkTrace [::] 0 _ _ _.
......
...@@ -29,14 +29,34 @@ Proof. ...@@ -29,14 +29,34 @@ Proof.
by apply (ltn_trans (m := a) (n := a+x)) in H. by apply (ltn_trans (m := a) (n := a+x)) in H.
Qed. Qed.
Lemma nat_le_lemaxn_add n m o: forall x, (n <= m) -> (n <= (maxn m o) + x). Lemma nat_le_lemaxn n m o: (n <= m) -> (n <= (maxn m o)).
Proof.
intros.
unfold maxn.
destruct (m < o) eqn:Hlt.
- move : H => /leP /(PeanoNat.Nat.le_trans n m o) H.
by move : Hlt => /ltP /PeanoNat.Nat.lt_le_incl /H /leP.
- auto.
Qed.
Lemma nat_le_add_lemaxn_add n m o: forall x, (n <= m + x) -> is_true (n <= (maxn m o) + x).
Proof. Proof.
intros. intros.
unfold maxn. unfold maxn.
destruct (m < o) eqn:Hlt. destruct (m < o) eqn:Hlt.
- move : H => /leP /(PeanoNat.Nat.le_trans n m o) H. - rewrite <- (ltn_add2r x m o) in Hlt.
by move : Hlt => /ltP /PeanoNat.Nat.lt_le_incl /H /(Plus.le_plus_trans n o x) /leP. apply ltnW in Hlt.
- by move : H => /leP /(Plus.le_plus_trans n m x) /leP. by apply leq_trans with (n := m + x) (m := n) (p := o + x) in Hlt.
- auto.
Qed.
Lemma nat_le_lemaxn_add n m o: forall x, (n <= m) -> (n <= (maxn m o) + x).
Proof.
intros.
apply nat_le_lemaxn with (o := o) in H.
apply leq_trans with (p := (maxn m o) + x) in H.
- auto.
- apply leq_addr.
Qed. Qed.
Lemma all_filter [T : eqType] a (p : pred T) S: Lemma all_filter [T : eqType] a (p : pred T) S:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment