diff options
author | Tristan Gingold <tgingold@free.fr> | 2022-09-14 21:04:19 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2022-09-15 01:48:29 +0200 |
commit | e5de56d020e0ca03d78d97d278ca03666ff3f28d (patch) | |
tree | f93c1b9ace73b998c8ce0e70bddde2c2f9927d19 /testsuite | |
parent | d70e470c76901f09620745c7921e8280946f19ee (diff) | |
download | ghdl-e5de56d020e0ca03d78d97d278ca03666ff3f28d.tar.gz ghdl-e5de56d020e0ca03d78d97d278ca03666ff3f28d.tar.bz2 ghdl-e5de56d020e0ca03d78d97d278ca03666ff3f28d.zip |
testsuite/gna: add a test for #2189
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/gna/issue2189/bug02.vhdl | 21 | ||||
-rw-r--r-- | testsuite/gna/issue2189/conv.on | 19 | ||||
-rw-r--r-- | testsuite/gna/issue2189/repro01.vhdl | 18 | ||||
-rwxr-xr-x | testsuite/gna/issue2189/testsuite.sh | 11 |
4 files changed, 69 insertions, 0 deletions
diff --git a/testsuite/gna/issue2189/bug02.vhdl b/testsuite/gna/issue2189/bug02.vhdl new file mode 100644 index 000000000..c6dd7841b --- /dev/null +++ b/testsuite/gna/issue2189/bug02.vhdl @@ -0,0 +1,21 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; +use work.all; + +entity bug02 is +end bug02; + +architecture rtl of bug02 is + FUNCTION weird (bw : integer range 2 to 32) + RETURN INTEGER IS + BEGIN + RETURN -(2**(bw - 1)); + END weird; +begin + process + begin + report to_string(weird(10)); + wait; + end process; +end architecture; diff --git a/testsuite/gna/issue2189/conv.on b/testsuite/gna/issue2189/conv.on new file mode 100644 index 000000000..5138e93fd --- /dev/null +++ b/testsuite/gna/issue2189/conv.on @@ -0,0 +1,19 @@ +TYPE __ghdl_i32 IS SIGNED (32); + +TYPE __ghdl_i64 IS SIGNED (64); + +TYPE std__standard__integer__BT IS SIGNED (32); + +EXTERNAL FUNCTION __ghdl_i64_exp ( + left: __ghdl_i64; + right: std__standard__integer__BT) + RETURN __ghdl_i64; + +PUBLIC FUNCTION conv ( + bw: std__standard__integer__BT) + RETURN std__standard__integer__BT +DECLARE +BEGIN + RETURN -std__standard__integer__BT'conv# (__ghdl_i64_exp (__ghdl_i64'conv# ( + std__standard__integer__BT'[2]), (bw -# 1))); +END; diff --git a/testsuite/gna/issue2189/repro01.vhdl b/testsuite/gna/issue2189/repro01.vhdl new file mode 100644 index 000000000..55e3fc455 --- /dev/null +++ b/testsuite/gna/issue2189/repro01.vhdl @@ -0,0 +1,18 @@ +entity bug02 is +end bug02; + +architecture rtl of bug02 is + FUNCTION weird (bw : integer range 2 to 32) + RETURN INTEGER IS + BEGIN + RETURN -(2**(bw - 1)); + END weird; +begin + process + constant c : integer := weird (10); + begin + report natural'image(c); + assert c = -512 severity failure; + wait; + end process; +end architecture; diff --git a/testsuite/gna/issue2189/testsuite.sh b/testsuite/gna/issue2189/testsuite.sh new file mode 100755 index 000000000..ea1bc3ed7 --- /dev/null +++ b/testsuite/gna/issue2189/testsuite.sh @@ -0,0 +1,11 @@ +#! /bin/sh + +. ../../testenv.sh + +GHDL_STD_FLAGS=--std=08 +analyze bug02.vhdl +elab_simulate bug02 + +clean + +echo "Test successful" |