aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/gna
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2022-12-22 10:20:16 +0100
committerTristan Gingold <tgingold@free.fr>2022-12-23 08:53:30 +0100
commitb8c022a220ebd67415a4d496f989309bb6189ee2 (patch)
tree9f61029f9576bd529c8103cfc0cdaed8190aa6f5 /testsuite/gna
parent91266a811cd8cd5dcd70345ea6acbb899389453c (diff)
downloadghdl-b8c022a220ebd67415a4d496f989309bb6189ee2.tar.gz
ghdl-b8c022a220ebd67415a4d496f989309bb6189ee2.tar.bz2
ghdl-b8c022a220ebd67415a4d496f989309bb6189ee2.zip
testsuite/gna: add test for #2264
Diffstat (limited to 'testsuite/gna')
-rw-r--r--testsuite/gna/issue2264/repro1.vhdl32
-rw-r--r--testsuite/gna/issue2264/repro2.vhdl39
-rw-r--r--testsuite/gna/issue2264/tb.vhdl97
-rwxr-xr-xtestsuite/gna/issue2264/testsuite.sh12
4 files changed, 180 insertions, 0 deletions
diff --git a/testsuite/gna/issue2264/repro1.vhdl b/testsuite/gna/issue2264/repro1.vhdl
new file mode 100644
index 000000000..29ba21939
--- /dev/null
+++ b/testsuite/gna/issue2264/repro1.vhdl
@@ -0,0 +1,32 @@
+package repro1_gpkg is
+ generic (len : natural);
+
+ subtype my_nat is natural range 0 to len;
+
+ type my_rec is record
+ v : integer;
+ end record;
+
+ constant my_cst : my_rec := (v => len);
+end;
+
+package repro1_pkg4 is new work.repro1_gpkg generic map (len => 4);
+package repro1_pkg10 is new work.repro1_gpkg generic map (len => 10);
+
+
+entity repro1 is
+end;
+
+use work.repro1_pkg10.all;
+
+architecture behav of repro1 is
+begin
+ process
+ variable v : my_rec;
+ begin
+ assert my_cst.v = 10 severity failure;
+ -- Error.
+ v := work.repro1_pkg4.my_cst;
+ wait;
+ end process;
+end behav;
diff --git a/testsuite/gna/issue2264/repro2.vhdl b/testsuite/gna/issue2264/repro2.vhdl
new file mode 100644
index 000000000..c7a8963e5
--- /dev/null
+++ b/testsuite/gna/issue2264/repro2.vhdl
@@ -0,0 +1,39 @@
+package repro2_gpkg is
+ generic (len : natural);
+
+ subtype my_nat is natural range 0 to len;
+
+ type my_rec is record
+ v : integer;
+ end record;
+
+ constant my_cst : my_rec := (v => len);
+end;
+
+package repro2_gpkgpkg is
+ generic (package pkg is new work.repro2_gpkg generic map (<>));
+
+ use pkg.all;
+ constant my2_cst : my_rec := (v => len + 1);
+end;
+
+package repro2_pkg10 is new work.repro2_gpkg generic map (len => 10);
+
+package repro2_pkgpkg10 is new work.repro2_gpkgpkg generic map (pkg => work.repro2_pkg10);
+
+
+entity repro2 is
+end;
+
+use work.repro2_pkg10.all;
+use work.repro2_pkgpkg10.all;
+
+architecture behav of repro2 is
+begin
+ process
+ variable v : my_rec;
+ begin
+ assert my2_cst.v = my_cst.v + 1 severity failure;
+ wait;
+ end process;
+end behav;
diff --git a/testsuite/gna/issue2264/tb.vhdl b/testsuite/gna/issue2264/tb.vhdl
new file mode 100644
index 000000000..59f7579a1
--- /dev/null
+++ b/testsuite/gna/issue2264/tb.vhdl
@@ -0,0 +1,97 @@
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+--! Configuration data types and structures
+package test_pattern_generator_generic_pkg is
+ generic(
+ PIXEL_PER_LINE_MAX : positive := 640
+ );
+
+ --! Redeclared constants so that we don't have to pass them to dependent entities as generics again
+ constant C_PIXEL_PER_LINE_MAX : positive := PIXEL_PER_LINE_MAX;
+
+ --! Constrained types with valid ranges for run time configurable options
+ subtype Pixel_Per_Line_t is integer range 2 to PIXEL_PER_LINE_MAX;
+
+ type Test_Pattern_Options_t is record
+ PixelPerLine : Pixel_Per_Line_t;
+ end record Test_Pattern_Options_t;
+
+ --! Default options for a test pattern generator that are guaranteed to produce valid output
+ constant DEFAULT_OPTIONS : Test_Pattern_Options_t := (
+ PixelPerLine => Pixel_Per_Line_t'low
+ );
+
+end package test_pattern_generator_generic_pkg;
+
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+entity test_pattern_generator is
+ generic(
+ package GENERIC_PKG_INSTANCE is new work.test_pattern_generator_generic_pkg generic map(<>)
+ );
+ port(
+ Clk : in std_logic; -- Clock Signal
+ --! Generated image parameters runtime options
+ Options : in GENERIC_PKG_INSTANCE.Test_Pattern_Options_t
+ );
+
+end test_pattern_generator;
+
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+architecture rtl of test_pattern_generator is
+ use GENERIC_PKG_INSTANCE.all;
+ --! Pixel counter, 0 based up-counter, counts pixels in the current line
+ signal pixel_cnt : natural range 0 to GENERIC_PKG_INSTANCE.C_PIXEL_PER_LINE_MAX - 1;
+
+begin
+end architecture rtl;
+
+
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+entity test_pattern_generator_tb is
+end entity test_pattern_generator_tb;
+
+architecture sim of test_pattern_generator_tb is
+ constant CLK_PERIOD : time := 10 ns;
+
+ -- Test Pattern Generator Generics
+ constant PIXEL_PER_LINE_MAX : integer := 160;
+
+ -- Instance for the type package for the test pattern generator
+ package test_pattern_pkg_inst is new work.test_pattern_generator_generic_pkg generic map(
+ PIXEL_PER_LINE_MAX => PIXEL_PER_LINE_MAX
+ );
+ use test_pattern_pkg_inst.all;
+
+ -- Test Pattern Generator Inputs
+ signal clk : std_logic := '0';
+ signal control_sig : test_pattern_pkg_inst.Test_Pattern_Options_t := test_pattern_pkg_inst.DEFAULT_OPTIONS;
+
+begin
+ test_pattern_generator_inst_tb : entity work.test_pattern_generator
+ generic map(
+ GENERIC_PKG_INSTANCE => test_pattern_pkg_inst
+ )
+ port map(
+ Clk => clk,
+ Options => control_sig
+ );
+
+ clk <= not clk after CLK_PERIOD / 2;
+
+ test_runner : process
+ begin
+ wait for CLK_PERIOD;
+ end process test_runner;
+
+end architecture sim;
diff --git a/testsuite/gna/issue2264/testsuite.sh b/testsuite/gna/issue2264/testsuite.sh
new file mode 100755
index 000000000..ba5697326
--- /dev/null
+++ b/testsuite/gna/issue2264/testsuite.sh
@@ -0,0 +1,12 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+export GHDL_STD_FLAGS=--std=08
+analyze_failure repro1.vhdl
+
+$GHDL -s $GHDL_STD_FLAGS repro2.vhdl
+
+clean
+
+echo "Test successful"