diff options
author | Tristan Gingold <tgingold@free.fr> | 2022-02-05 17:05:38 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2022-02-05 17:06:04 +0100 |
commit | 29289cbb4fb0bf5c8424519bf97220205f892151 (patch) | |
tree | 9f713a09d8e03cd2decf10c7241038e9b151d891 /testsuite/synth | |
parent | 265881a175f2e9a9f222b0d06780811c6ab6cd93 (diff) | |
download | ghdl-29289cbb4fb0bf5c8424519bf97220205f892151.tar.gz ghdl-29289cbb4fb0bf5c8424519bf97220205f892151.tar.bz2 ghdl-29289cbb4fb0bf5c8424519bf97220205f892151.zip |
testsuite/synth: add a test for #1962
Diffstat (limited to 'testsuite/synth')
-rw-r--r-- | testsuite/synth/issue1962/bug.vhdl | 48 | ||||
-rw-r--r-- | testsuite/synth/issue1962/bug2.vhdl | 44 | ||||
-rwxr-xr-x | testsuite/synth/issue1962/testsuite.sh | 9 |
3 files changed, 101 insertions, 0 deletions
diff --git a/testsuite/synth/issue1962/bug.vhdl b/testsuite/synth/issue1962/bug.vhdl new file mode 100644 index 000000000..739d9c0ee --- /dev/null +++ b/testsuite/synth/issue1962/bug.vhdl @@ -0,0 +1,48 @@ +library IEEE; +use IEEE.std_logic_1164.all; +use IEEE.numeric_std.all; + +entity bug is + port ( + clk : in std_ulogic + ); +end bug; + +architecture struct of bug is + + type data_t is record + value : natural; + end record; + + type offset_array_t is array(natural range<>) of natural; + type data_array_t is array(natural range<>) of data_t; + + type collection_t is record + offset : offset_array_t; + data : data_array_t; + end record; + + -- This results in an error + function append(prefix : collection_t; data : data_array_t) return collection_t is + begin + return (offset => prefix.offset & prefix.data'length, + data => prefix.data & data); + end function; + + -- This works as a workaround + function append2(prefix : collection_t; data : data_array_t) return collection_t is + variable ret : collection_t(offset(0 to prefix.offset'length), data(0 to prefix.data'length+data'length-1)); + begin + ret := (offset => prefix.offset & prefix.data'length, + data => prefix.data & data); + return ret; + end function; + + --intentional null ranges for the initial value + constant initial_collection : collection_t(offset(0 to -1), data(0 to -1)) := (offset => (others => 0), data => (others => (value => 0))); + constant new_data : data_array_t(0 to 2) := (others => (value => 0)); + + constant final_collection : collection_t := append(initial_collection, new_data); +begin + +end architecture; diff --git a/testsuite/synth/issue1962/bug2.vhdl b/testsuite/synth/issue1962/bug2.vhdl new file mode 100644 index 000000000..b597fb89b --- /dev/null +++ b/testsuite/synth/issue1962/bug2.vhdl @@ -0,0 +1,44 @@ +entity bug is + port ( + clk : in bit + ); +end bug; + +architecture struct of bug is + + type data_t is record + value : natural; + end record; + + type offset_array_t is array(natural range<>) of natural; + type data_array_t is array(natural range<>) of data_t; + + type collection_t is record + offset : offset_array_t; + data : data_array_t; + end record; + + -- This results in an error + function append(prefix : collection_t; data : data_array_t) return collection_t is + begin + return (offset => prefix.offset & prefix.data'length, + data => prefix.data & data); + end function; + + -- This works as a workaround + function append2(prefix : collection_t; data : data_array_t) return collection_t is + variable ret : collection_t(offset(0 to prefix.offset'length), data(0 to prefix.data'length+data'length-1)); + begin + ret := (offset => prefix.offset & prefix.data'length, + data => prefix.data & data); + return ret; + end function; + + --intentional null ranges for the initial value + constant initial_collection : collection_t(offset(0 to -1), data(0 to -1)) := (offset => (others => 0), data => (others => (value => 0))); + constant new_data : data_array_t(0 to 2) := (others => (value => 0)); + + constant final_collection : collection_t := append(initial_collection, new_data); +begin + +end architecture; diff --git a/testsuite/synth/issue1962/testsuite.sh b/testsuite/synth/issue1962/testsuite.sh new file mode 100755 index 000000000..a27251178 --- /dev/null +++ b/testsuite/synth/issue1962/testsuite.sh @@ -0,0 +1,9 @@ +#! /bin/sh + +. ../../testenv.sh + +GHDL_STD_FLAGS=--std=08 +synth_only bug +synth_only bug2 + +echo "Test successful" |