-
Notifications
You must be signed in to change notification settings - Fork 0
/
ModRound.v
39 lines (32 loc) · 1.57 KB
/
ModRound.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
Require Import Kami.AllNotations FpuKami.Definitions FpuKami.Round String.
Require Export Nat.
Section FpuConvert2.
Variable name: string.
Variable expWidthMinus2 sigWidthMinus2: nat.
Variable out_expWidthMinus2 out_sigWidthMinus2: nat.
Local Notation "^ x" := (name ++ "#" ++ x)%string (at level 100).
Open Scope kami_expr.
Definition NF_from_FN :=
MODULE {
Rule ^"NF_from_FN" :=
Call input: FN expWidthMinus2 sigWidthMinus2 <- "input" ();
Call tiny: Bool <- "tiny" ();
Call roundMode: Bit 3 <- "roundMode" ();
LET inputNF <- getNF_from_FN #input;
LET roundInput: RoundInput _ _ <-
STRUCT {
"in" ::= #inputNF;
"afterRounding" ::= #tiny;
"roundingMode" ::= #roundMode
};
LETA roundOutput <- (RoundNF_action out_expWidthMinus2 out_sigWidthMinus2
(2 ^ (out_expWidthMinus2 + 1) - 2)%nat
(2 ^ (out_expWidthMinus2 + 1) + (out_sigWidthMinus2 + 1) - 2)%nat
(2 ^ (out_expWidthMinus2 + 1) - 1)%nat
#roundInput);
Call "exceptionFlags" (#roundOutput @% "exceptionFlags": _) ;
Call "outputFN" (((#roundOutput @% "out")): _);
Retv
}.
Close Scope kami_expr.
End FpuConvert2.