aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2017-02-24 05:03:39 +0100
committerTristan Gingold <tgingold@free.fr>2017-02-24 05:03:39 +0100
commit8f65c11d87a7dc8993d817f2db0beac9395af0a6 (patch)
tree71479c87b9c760efb363ad10bef089e002ac35b0 /src
parent394c9b5f341cd4393a87acad72b933a6d4a56e2b (diff)
downloadghdl-8f65c11d87a7dc8993d817f2db0beac9395af0a6.tar.gz
ghdl-8f65c11d87a7dc8993d817f2db0beac9395af0a6.tar.bz2
ghdl-8f65c11d87a7dc8993d817f2db0beac9395af0a6.zip
evaluation: add comment for fp exponentiation
Diffstat (limited to 'src')
-rw-r--r--src/vhdl/evaluation.adb10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/vhdl/evaluation.adb b/src/vhdl/evaluation.adb
index d996cace4..1f865a84d 100644
--- a/src/vhdl/evaluation.adb
+++ b/src/vhdl/evaluation.adb
@@ -1355,6 +1355,13 @@ package body Evaluation is
begin
Res := 1.0;
Val := Get_Fp_Value (Left);
+ -- LRM08 9.2.8 Misellaneous operators
+ -- Exponentiation with an integer exponent is equivalent to
+ -- repeated multiplication of the left operand by itself for
+ -- a number of times indicated by the absolute value of the
+ -- exponent and from left to right; [...]
+ -- GHDL: use the standard power-of-2 approach. This is not
+ -- strictly equivalent however.
Exp := abs Get_Value (Right);
while Exp /= 0 loop
if Exp mod 2 = 1 then
@@ -1363,6 +1370,9 @@ package body Evaluation is
Exp := Exp / 2;
Val := Val * Val;
end loop;
+ -- LRM08 9.2.8 Misellaneous operators
+ -- [...] if the exponent is negative then the result is the
+ -- reciprocal of that [...]
if Get_Value (Right) < 0 then
Res := 1.0 / Res;
end if;