From 85f04269f83e6ecfbd0301bdbdb574f388cac6e2 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Tue, 25 Aug 2020 20:21:25 +0200 Subject: testsuite/gna: add a test for #1440 --- testsuite/gna/issue1440/tb2.vhdl | 39 ++++++++++++++++++++++++++++++++++++ testsuite/gna/issue1440/testsuite.sh | 11 ++++++++++ 2 files changed, 50 insertions(+) create mode 100644 testsuite/gna/issue1440/tb2.vhdl diff --git a/testsuite/gna/issue1440/tb2.vhdl b/testsuite/gna/issue1440/tb2.vhdl new file mode 100644 index 000000000..9d656bfa9 --- /dev/null +++ b/testsuite/gna/issue1440/tb2.vhdl @@ -0,0 +1,39 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity tb2 is +end; + +architecture tb of tb2 is + signal cnt, prev : std_logic_vector(3 downto 0) := (others=>'0'); + + function tostr (v : std_logic_vector) return string + is + alias av : std_logic_vector (1 to v'length) is v; + variable res : string (1 to v'length); + begin + for i in av'range loop + case av (i) is + when '0' => res (i) := '0'; + when '1' => res (i) := '1'; + when others => res (i) := '?'; + end case; + end loop; + return res; + end tostr; +begin + process + begin + for i in 0 to 20 loop + wait for 1 ns; + cnt <= std_logic_vector(unsigned(cnt) + 1); + prev <= cnt; + assert false + report "value=" & tostr(cnt) & " last_value=" & tostr(cnt'last_value) + severity note; + assert prev = cnt'last_value severity failure; + end loop; + wait; + end process; +end; diff --git a/testsuite/gna/issue1440/testsuite.sh b/testsuite/gna/issue1440/testsuite.sh index fdbd32d58..1c1885460 100755 --- a/testsuite/gna/issue1440/testsuite.sh +++ b/testsuite/gna/issue1440/testsuite.sh @@ -6,6 +6,17 @@ export GHDL_STD_FLAGS=--std=08 analyze tb_last_value_bug.vhdl elab_simulate tb_last_value_bug --stop-time=50ns +analyze tb2.vhdl +elab_simulate tb2 + +clean + +export GHDL_STD_FLAGS=--std=87 + +analyze tb2.vhdl +elab_simulate_failure tb2 + clean + echo "Test successful" -- cgit v1.2.3