aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-12-29 18:33:35 +0100
committerTristan Gingold <tgingold@free.fr>2020-12-29 18:33:58 +0100
commit708cbe6c1ff75f5bccb09af043577b50982529b9 (patch)
tree0e046329d1a63f8b20ad0696532a29625327dd57
parent61315151bc011a063d6a07937fd36068bdff53b6 (diff)
downloadghdl-708cbe6c1ff75f5bccb09af043577b50982529b9.tar.gz
ghdl-708cbe6c1ff75f5bccb09af043577b50982529b9.tar.bz2
ghdl-708cbe6c1ff75f5bccb09af043577b50982529b9.zip
testsuite/gna: add tests for #1549
-rw-r--r--testsuite/gna/issue1549/ent.vhdl67
-rw-r--r--testsuite/gna/issue1549/ent2.vhdl50
-rw-r--r--testsuite/gna/issue1549/ent3.vhdl56
-rw-r--r--testsuite/gna/issue1549/ent4.vhdl29
-rw-r--r--testsuite/gna/issue1549/ent5.vhdl26
-rw-r--r--testsuite/gna/issue1549/ent6.vhdl28
-rwxr-xr-xtestsuite/gna/issue1549/testsuite.sh26
7 files changed, 282 insertions, 0 deletions
diff --git a/testsuite/gna/issue1549/ent.vhdl b/testsuite/gna/issue1549/ent.vhdl
new file mode 100644
index 000000000..46cab39c3
--- /dev/null
+++ b/testsuite/gna/issue1549/ent.vhdl
@@ -0,0 +1,67 @@
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+entity ent is
+ generic (
+ TUSER_WIDTH : natural := 1); -- Changing TUSER_WIDTH to a local constant inside ent fixes the issue
+end ent;
+
+architecture ent of ent is
+
+ -- constant TUSER_WIDTH : natural := 1;
+
+ type data_t is record
+ tuser : std_logic_vector;
+ end record;
+
+ type data_array_t is array (natural range <>) of data_t;
+ type std_logic_array_t is array (natural range <>) of std_logic_vector;
+ subtype tuser_array_t is std_logic_array_t(open)(TUSER_WIDTH - 1 downto 0);
+
+begin
+
+ process
+ ------------------------------------------------------------------------------------
+ procedure write_data (
+ constant tuser : tuser_array_t -- Fails!
+ -- constant tuser : std_logic_array_t(open)(open) -- Works
+ -- constant tuser : std_logic_array_t -- Works
+ ) is
+ begin
+
+ -- All entries will show as zero when it fails!
+ for i in tuser'range loop
+ report integer'image(i) & " =>" & integer'image(to_integer(unsigned(tuser(i))));
+ end loop;
+
+ assert tuser(1)(0) = '1'; -- <<<<<====== This should not fail
+ end procedure;
+
+ ------------------------------------------------------------------------------------
+ procedure handle_data_array ( constant data : data_array_t) is
+ variable local_tuser : std_logic_array_t(data'range)(TUSER_WIDTH - 1 downto 0);
+ -- variable local_tuser : tuser_array_t(data'range); -- This fails in this procedure!
+ begin
+ -- Convert a list of tuples into two lists
+ for i in data'range loop
+ local_tuser(i) := data(i).tuser;
+ -- This assertion fails when local_tuser type is one of
+ -- tuser_array_t(data'range)
+ -- tuser_array_t(0 to 1)
+ -- It will pass if the local_tuser is of type std_logic_array_t(data'range)(TUSER_WIDTH - 1 downto 0);
+ assert local_tuser(i) = data(i).tuser
+ report "local_tuser and data(i).tuser should not be different here";
+ end loop;
+
+ write_data(tuser => local_tuser);
+ end;
+
+ ------------------------------------------------------------------------------------
+ constant data : data_array_t(0 to 1)(tuser(0 downto 0)) := (0 => (tuser => (0 downto 0 => '0')),
+ 1 => (tuser => (0 downto 0 => '1')));
+ begin
+ handle_data_array(data);
+ wait;
+ end process;
+end ent;
diff --git a/testsuite/gna/issue1549/ent2.vhdl b/testsuite/gna/issue1549/ent2.vhdl
new file mode 100644
index 000000000..818d980db
--- /dev/null
+++ b/testsuite/gna/issue1549/ent2.vhdl
@@ -0,0 +1,50 @@
+library ieee;
+use ieee.std_logic_1164.all;
+
+entity ent2 is
+ generic (
+ TUSER_WIDTH : natural := 1);
+end ent2;
+
+architecture ent of ent2 is
+ type data_t is record
+ tuser : std_logic_vector;
+ end record;
+
+ type data_array_t is array (natural range <>) of data_t;
+ type std_logic_array_t is array (natural range <>) of std_logic_vector;
+ subtype tuser_array_t is std_logic_array_t(open)(TUSER_WIDTH - 1 downto 0);
+
+begin
+
+ process
+ procedure write_data (constant tuser : tuser_array_t) is
+ begin
+ for i in tuser'range loop
+ report integer'image(i) & " =>" & to_bstring(tuser(i));
+ end loop;
+
+ assert tuser(1)(0) = '1'; -- <<<<<====== This should not fail
+ end procedure;
+
+ procedure handle_data_array ( constant data : data_array_t) is
+ variable local_tuser : std_logic_array_t(data'range)(TUSER_WIDTH - 1 downto 0);
+ begin
+ -- Convert a list of tuples into two lists
+ for i in data'range loop
+ local_tuser(i) := data(i).tuser;
+ assert local_tuser(i) = data(i).tuser
+ report "local_tuser and data(i).tuser should not be different here";
+ end loop;
+
+ write_data(tuser => local_tuser);
+ end;
+
+ constant data : data_array_t(0 to 1)(tuser(0 downto 0)) :=
+ (0 => (tuser => (0 downto 0 => '0')),
+ 1 => (tuser => (0 downto 0 => '1')));
+ begin
+ handle_data_array(data);
+ wait;
+ end process;
+end ent;
diff --git a/testsuite/gna/issue1549/ent3.vhdl b/testsuite/gna/issue1549/ent3.vhdl
new file mode 100644
index 000000000..123445d07
--- /dev/null
+++ b/testsuite/gna/issue1549/ent3.vhdl
@@ -0,0 +1,56 @@
+library ieee;
+use ieee.std_logic_1164.all;
+
+entity ent3 is
+ generic (
+ TUSER_WIDTH : natural := 1);
+end ent3;
+
+architecture ent of ent3 is
+ type data_t is record
+ tuser : std_logic_vector;
+ end record;
+
+ type data_array_t is array (natural range <>) of data_t;
+ type std_logic_array_t is array (natural range <>) of std_logic_vector;
+ subtype tuser_array_t is std_logic_array_t(open)(TUSER_WIDTH - 1 downto 0);
+
+ procedure write_data (constant tuser : tuser_array_t) is
+ begin
+ for i in tuser'range loop
+ report integer'image(i) & " =>" & to_bstring(tuser(i));
+ end loop;
+
+ assert tuser(1)(0) = '1'; -- <<<<<====== This should not fail
+ end procedure;
+
+ procedure handle_data_array ( constant data : data_array_t) is
+ variable local_tuser : std_logic_array_t(data'range)(TUSER_WIDTH - 1 downto 0);
+ begin
+ -- Convert a list of tuples into two lists
+ for i in data'range loop
+ local_tuser(i) := data(i).tuser;
+ assert local_tuser(i) = data(i).tuser
+ report "local_tuser and data(i).tuser should not be different here";
+ end loop;
+ report "local(0)=" & to_bstring(local_tuser(0));
+ report "local(1)=" & to_bstring(local_tuser(1));
+
+ write_data(tuser => local_tuser);
+ end;
+
+ constant data : data_array_t(0 to 1)(tuser(0 downto 0)) :=
+ (0 => (tuser => (0 downto 0 => '0')),
+ 1 => (tuser => (0 downto 0 => '1')));
+
+ constant data2 : tuser_array_t(0 to 1) := (0 => "0", 1 => "1");
+begin
+ process
+ begin
+ write_data(data2);
+ report "data(0).tuser=" & to_bstring(data(0).tuser);
+ report "data(1).tuser=" & to_bstring(data(1).tuser);
+ handle_data_array(data);
+ wait;
+ end process;
+end ent;
diff --git a/testsuite/gna/issue1549/ent4.vhdl b/testsuite/gna/issue1549/ent4.vhdl
new file mode 100644
index 000000000..b921879ef
--- /dev/null
+++ b/testsuite/gna/issue1549/ent4.vhdl
@@ -0,0 +1,29 @@
+library ieee;
+use ieee.std_logic_1164.all;
+
+entity ent4 is
+ generic (
+ TUSER_WIDTH : natural := 1);
+end ent4;
+
+architecture ent of ent4 is
+ type std_logic_array_t is array (natural range <>) of std_logic_vector;
+ subtype tuser_array_t is std_logic_array_t(open)(TUSER_WIDTH - 1 downto 0);
+
+ procedure write_data (constant tuser : tuser_array_t) is
+ begin
+ for i in tuser'range loop
+ report integer'image(i) & " =>" & to_bstring(tuser(i));
+ end loop;
+
+ assert tuser(1)(0) = '1'; -- <<<<<====== This should not fail
+ end procedure;
+
+ constant data2 : tuser_array_t(0 to 1) := (0 => "0", 1 => "1");
+begin
+ process
+ begin
+ write_data(data2);
+ wait;
+ end process;
+end ent;
diff --git a/testsuite/gna/issue1549/ent5.vhdl b/testsuite/gna/issue1549/ent5.vhdl
new file mode 100644
index 000000000..58684bcb0
--- /dev/null
+++ b/testsuite/gna/issue1549/ent5.vhdl
@@ -0,0 +1,26 @@
+entity ent5 is
+ generic (
+ WIDTH : natural := 1);
+end ent5;
+
+architecture ent of ent5 is
+ type bv_array_t is array (natural range <>) of bit_vector;
+ subtype bv_array2_t is bv_array_t(open)(WIDTH - 1 downto 0);
+
+ procedure write_data (constant c : bv_array2_t) is
+ begin
+ for i in c'range loop
+ report integer'image(i) & " =>" & to_string(c(i));
+ end loop;
+
+ assert c(1)(0) = '1'; -- <<<<<====== This should not fail
+ end procedure;
+
+ constant data2 : bv_array2_t(0 to 1) := (0 => "0", 1 => "1");
+begin
+ process
+ begin
+ write_data(data2);
+ wait;
+ end process;
+end ent;
diff --git a/testsuite/gna/issue1549/ent6.vhdl b/testsuite/gna/issue1549/ent6.vhdl
new file mode 100644
index 000000000..eed31b5f5
--- /dev/null
+++ b/testsuite/gna/issue1549/ent6.vhdl
@@ -0,0 +1,28 @@
+entity ent6 is
+ generic (
+ WIDTH : natural := 1);
+end ent6;
+
+architecture ent of ent6 is
+ type bv_array_t is array (natural range <>) of bit_vector;
+ subtype bv_array2_t is bv_array_t(open)(WIDTH - 1 downto 0);
+
+ procedure write_data (constant c : bv_array2_t) is
+ begin
+ for i in c'range loop
+ report integer'image(i) & " =>" & to_string(c(i));
+ end loop;
+
+ assert c(1)(0) = '1'; -- <<<<<====== This should not fail
+ end procedure;
+
+begin
+ process
+ variable data2 : bv_array2_t(0 to 1);
+ begin
+ data2(0) := "0";
+ data2(1) := "1";
+ write_data(data2);
+ wait;
+ end process;
+end ent;
diff --git a/testsuite/gna/issue1549/testsuite.sh b/testsuite/gna/issue1549/testsuite.sh
new file mode 100755
index 000000000..28abdf604
--- /dev/null
+++ b/testsuite/gna/issue1549/testsuite.sh
@@ -0,0 +1,26 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+export GHDL_STD_FLAGS=--std=08
+analyze ent.vhdl
+elab_simulate ent
+
+analyze ent2.vhdl
+elab_simulate ent2
+
+analyze ent3.vhdl
+elab_simulate ent3
+
+analyze ent4.vhdl
+elab_simulate ent4
+
+analyze ent5.vhdl
+elab_simulate ent5
+
+analyze ent6.vhdl
+elab_simulate ent6
+
+clean
+
+echo "Test successful"