-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModCompare.v
55 lines (41 loc) · 1.98 KB
/
ModCompare.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
Require Import FpuKami.Definitions String Kami.AllNotations FpuKami.Compare.
Section Compare.
Variable name: string.
Variable expWidthMinus2 sigWidthMinus2: nat.
Local Notation "^ x" := (name ++ "#" ++ x)%string (at level 100).
Open Scope kami_expr.
Definition CompareModFN :=
MODULE {
Rule ^"CompareFN" :=
Call inputA: FN expWidthMinus2 sigWidthMinus2 <- "inputA" ();
Call inputB: FN expWidthMinus2 sigWidthMinus2 <- "inputB" ();
LET inputANF: NF expWidthMinus2 sigWidthMinus2 <- getNF_from_FN #inputA;
LET inputBNF: NF expWidthMinus2 sigWidthMinus2 <- getNF_from_FN #inputB;
LETA compareOutput <- Compare_action #inputANF #inputBNF;
Call "exceptionFlags" (#compareOutput @% "exceptionFlags": _) ;
Call "gt" (((#compareOutput @% "gt")): _);
Call "lt" (((#compareOutput @% "lt")): _);
Call "eq" (((#compareOutput @% "eq")): _);
Retv
}.
Definition CompareModRecFN :=
MODULE {
Rule ^"CompareRecFN" :=
Call inputA: RecFN expWidthMinus2 sigWidthMinus2 <- "inputA" ();
Call inputB: RecFN expWidthMinus2 sigWidthMinus2 <- "inputB" ();
LET inputANF: NF expWidthMinus2 sigWidthMinus2 <- getNF_from_RecFN #inputA;
LET inputBNF: NF expWidthMinus2 sigWidthMinus2 <- getNF_from_RecFN #inputB;
LETA compareOutput <- Compare_action #inputANF #inputBNF;
Call "exceptionFlags" (#compareOutput @% "exceptionFlags": _) ;
Call "gt" (((#compareOutput @% "gt")): _);
Call "lt" (((#compareOutput @% "lt")): _);
Call "eq" (((#compareOutput @% "eq")): _);
Retv
}.
End Compare.
Definition CompareF16 := CompareModFN "fpu" 6 6.
Definition CompareF32 := CompareModFN "fpu" 6 22.
Definition CompareF64 := CompareModFN "fpu" 9 51.
Definition CompareRecF16 := CompareModRecFN "fpu" 6 6.
Definition CompareRecF32 := CompareModRecFN "fpu" 6 22.
Definition CompareRecF64 := CompareModRecFN "fpu" 9 51.