aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2020-05-04 16:13:16 +0100
committerYann Herklotz <git@yannherklotz.com>2020-05-04 16:13:16 +0100
commit5cfa4af9c6e4d9703e3142c24ae78c7da0ac575f (patch)
treead12dbe508a4bcb9ab1c29854074650b534e55c5
parentdfef69f7844a67210032bfe2597ba5d6b6702469 (diff)
downloadvericert-5cfa4af9c6e4d9703e3142c24ae78c7da0ac575f.tar.gz
vericert-5cfa4af9c6e4d9703e3142c24ae78c7da0ac575f.zip
Add equality check for value
-rw-r--r--src/Compiler.v2
-rw-r--r--src/Simulator.v2
-rw-r--r--src/extraction/Extraction.v2
-rw-r--r--src/translation/Veriloggen.v2
-rw-r--r--src/translation/Veriloggenproof.v2
-rw-r--r--src/verilog/Value.v36
-rw-r--r--src/verilog/Verilog.v2
7 files changed, 27 insertions, 21 deletions
diff --git a/src/Compiler.v b/src/Compiler.v
index 697732d..e998521 100644
--- a/src/Compiler.v
+++ b/src/Compiler.v
@@ -1,4 +1,4 @@
-(* -*- mode: coq -*-
+(*
* CoqUp: Verified high-level synthesis.
* Copyright (C) 2019-2020 Yann Herklotz <yann@yannherklotz.com>
*
diff --git a/src/Simulator.v b/src/Simulator.v
index 6849f80..930971b 100644
--- a/src/Simulator.v
+++ b/src/Simulator.v
@@ -1,4 +1,4 @@
-(* -*- mode: coq -*-
+(*
* CoqUp: Verified high-level synthesis.
* Copyright (C) 2020 Yann Herklotz <yann@yannherklotz.com>
*
diff --git a/src/extraction/Extraction.v b/src/extraction/Extraction.v
index 319e2eb..0028fcb 100644
--- a/src/extraction/Extraction.v
+++ b/src/extraction/Extraction.v
@@ -1,4 +1,4 @@
-(* -*- mode: coq -*-
+(*
* CoqUp: Verified high-level synthesis.
* Copyright (C) 2019-2020 Yann Herklotz <yann@yannherklotz.com>
*
diff --git a/src/translation/Veriloggen.v b/src/translation/Veriloggen.v
index 40876f7..f127b11 100644
--- a/src/translation/Veriloggen.v
+++ b/src/translation/Veriloggen.v
@@ -1,4 +1,4 @@
-(* -*- mode: coq -*-
+(*
* CoqUp: Verified high-level synthesis.
* Copyright (C) 2020 Yann Herklotz <yann@yannherklotz.com>
*
diff --git a/src/translation/Veriloggenproof.v b/src/translation/Veriloggenproof.v
index cc884b4..942a83a 100644
--- a/src/translation/Veriloggenproof.v
+++ b/src/translation/Veriloggenproof.v
@@ -1,4 +1,4 @@
-(* -*- mode: coq -*-
+(*
* CoqUp: Verified high-level synthesis.
* Copyright (C) 2020 Yann Herklotz <yann@yannherklotz.com>
*
diff --git a/src/verilog/Value.v b/src/verilog/Value.v
index 21e59be..4cacab5 100644
--- a/src/verilog/Value.v
+++ b/src/verilog/Value.v
@@ -1,4 +1,4 @@
-(* -*- mode: coq -*-
+(*
* CoqUp: Verified high-level synthesis.
* Copyright (C) 2020 Yann Herklotz <yann@yannherklotz.com>
*
@@ -149,24 +149,30 @@ Definition eq_to_opt (v1 v2 : value) (f : vsize v1 = vsize v2 -> value)
| _ => None
end.
-Lemma eqvalue {sz : nat} (x y : word sz) : x = y -> (mkvalue sz x = mkvalue sz y).
-Proof. intros. subst. reflexivity. Qed.
-Lemma nevalue {sz : nat} (x y : word sz) : x <> y -> (mkvalue sz x <> mkvalue sz y).
-Proof. Admitted.
+Lemma eqvalue {sz : nat} (x y : word sz) : x = y <-> mkvalue sz x = mkvalue sz y.
+Proof.
+ split; intros.
+ subst. reflexivity. inversion H. apply existT_wordToZ in H1.
+ apply wordToZ_inj. assumption.
+Qed.
+
+Lemma eqvaluef {sz : nat} (x y : word sz) : x = y -> mkvalue sz x = mkvalue sz y.
+Proof. apply eqvalue. Qed.
+
+Lemma nevalue {sz : nat} (x y : word sz) : x <> y <-> mkvalue sz x <> mkvalue sz y.
+Proof. split; intros; intuition. apply H. apply eqvalue. assumption.
+ apply H. rewrite H0. trivial.
+Qed.
-Definition valueEqCheck (sz : nat) (x y : word sz) :
+Lemma nevaluef {sz : nat} (x y : word sz) : x <> y -> mkvalue sz x <> mkvalue sz y.
+Proof. apply nevalue. Qed.
+
+Definition valueEq (sz : nat) (x y : word sz) :
{mkvalue sz x = mkvalue sz y} + {mkvalue sz x <> mkvalue sz y} :=
match weq x y with
- | left eq => left (eqvalue x y eq)
- | right ne => right (nevalue x y ne)
- end.
-
-Definition valueEq (x y : value) (EQ : vsize x = vsize y): {x = y} + {x <> y} :=
- let unif_y := unify_word (vsize x) (vsize y) (vword y) EQ in
- match weq (vword x) unif_y with
- | left _ => left _
- | right _ => right _
+ | left eq => left (eqvaluef x y eq)
+ | right ne => right (nevaluef x y ne)
end.
(** Arithmetic operations over [value], interpreting them as signed or unsigned
diff --git a/src/verilog/Verilog.v b/src/verilog/Verilog.v
index a927eac..756dc12 100644
--- a/src/verilog/Verilog.v
+++ b/src/verilog/Verilog.v
@@ -1,4 +1,4 @@
-(* -*- mode: coq -*-
+(*
* CoqUp: Verified high-level synthesis.
* Copyright (C) 2019-2020 Yann Herklotz <yann@yannherklotz.com>
*