aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2017-04-08 04:11:03 +0200
committerTristan Gingold <tgingold@free.fr>2017-04-19 20:48:23 +0200
commit7d17b527ea6bad8ef1e3f5450c0d7899c60febee (patch)
treee457d57cf12281432f353d33cd06c4177be6f1d7 /testsuite
parent761f216517447532ba7aedd9b54300328d0dfa1b (diff)
downloadghdl-7d17b527ea6bad8ef1e3f5450c0d7899c60febee.tar.gz
ghdl-7d17b527ea6bad8ef1e3f5450c0d7899c60febee.tar.bz2
ghdl-7d17b527ea6bad8ef1e3f5450c0d7899c60febee.zip
Add testcase for floating point literal scan.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/gna/bug071/atod.vhdl44
-rwxr-xr-xtestsuite/gna/bug071/testsuite.sh11
2 files changed, 55 insertions, 0 deletions
diff --git a/testsuite/gna/bug071/atod.vhdl b/testsuite/gna/bug071/atod.vhdl
new file mode 100644
index 000000000..e7f84d88d
--- /dev/null
+++ b/testsuite/gna/bug071/atod.vhdl
@@ -0,0 +1,44 @@
+entity atod is
+end atod;
+
+architecture behav of atod is
+ type real_array is array (natural range <>) of real;
+ constant csts : real_array :=
+ (1.0,
+ 0.0,
+ -- Corner cases from
+ -- http://www.exploringbinary.com/
+ -- decimal-to-realing-point-needs-arbitrary-precision/
+
+ 7.8459735791271921e65,
+ -- In binary:
+ -- 1.11011100 11010000 00001000 10011100 00010011 00010100 1110 e218
+ -- 1. d c d 0 0 8 9 c 1 3 1 4 e
+
+ 3.571e266,
+ -- 1.01100010 01100100 01001100 01100001 11010100 00011010 1010 e885
+ -- 1. 6 2 6 4 4 c 6 1 d 4 1 a a
+
+ 3.08984926168550152811E-32,
+ -- 1.01000000 11011110 01001000 01100111 01100110 01010011 1011 e-105
+ -- 1. 4 0 d e 4 8 6 7 6 6 5 3 b
+
+ 7.4505805969238281e-09
+ );
+
+begin
+ process
+ variable v : real;
+ begin
+ for i in csts'range loop
+ report to_string (csts (i), "%a") severity note;
+ end loop;
+
+ v := csts (2);
+ assert to_string (v, "%a") = "0x1.dcd0089c1314ep+218" severity failure;
+
+ v := csts (3);
+ assert to_string (v, "%a") = "0x1.62644c61d41aap+885" severity failure;
+ wait;
+ end process;
+end behav;
diff --git a/testsuite/gna/bug071/testsuite.sh b/testsuite/gna/bug071/testsuite.sh
new file mode 100755
index 000000000..7bf42e9e8
--- /dev/null
+++ b/testsuite/gna/bug071/testsuite.sh
@@ -0,0 +1,11 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+export GHDL_STD_FLAGS=--std=08
+analyze atod.vhdl
+elab_simulate atod
+
+clean
+
+echo "Test successful"