diff options
author | Tristan Gingold <tgingold@free.fr> | 2017-12-12 05:25:17 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2017-12-12 05:25:17 +0100 |
commit | 874fd35e9c185f7892dd5553bfa71e32a57d143f (patch) | |
tree | 62e4d65ea1d89a968fda10283811a54284d8eb46 /testsuite/gna/issue476 | |
parent | 650e68b382f5a3c9404b74c7f39a4b769a46350a (diff) | |
download | ghdl-874fd35e9c185f7892dd5553bfa71e32a57d143f.tar.gz ghdl-874fd35e9c185f7892dd5553bfa71e32a57d143f.tar.bz2 ghdl-874fd35e9c185f7892dd5553bfa71e32a57d143f.zip |
Add reproducer for #476
Diffstat (limited to 'testsuite/gna/issue476')
-rw-r--r-- | testsuite/gna/issue476/pixel_column_pkg.vhd | 69 | ||||
-rw-r--r-- | testsuite/gna/issue476/pixel_matrix_pkg.vhd | 75 | ||||
-rw-r--r-- | testsuite/gna/issue476/pixel_pkg.vhd | 69 | ||||
-rw-r--r-- | testsuite/gna/issue476/repro/pixel_column_pkg.vhd | 38 | ||||
-rw-r--r-- | testsuite/gna/issue476/repro/pixel_matrix_pkg.vhd | 37 | ||||
-rw-r--r-- | testsuite/gna/issue476/repro/pixel_pkg.vhd | 32 | ||||
-rw-r--r-- | testsuite/gna/issue476/repro/test_op.vhd | 48 | ||||
-rw-r--r-- | testsuite/gna/issue476/repro/test_op1.vhd | 39 | ||||
-rwxr-xr-x | testsuite/gna/issue476/repro/testsuite.sh | 11 | ||||
-rw-r--r-- | testsuite/gna/issue476/repro2/pixel_column_pkg.vhd | 34 | ||||
-rw-r--r-- | testsuite/gna/issue476/repro2/pixel_matrix_pkg.vhd | 37 | ||||
-rw-r--r-- | testsuite/gna/issue476/repro2/pixel_pkg.vhd | 28 | ||||
-rw-r--r-- | testsuite/gna/issue476/repro2/test_op.vhd | 48 | ||||
-rw-r--r-- | testsuite/gna/issue476/repro2/test_op1.vhd | 35 | ||||
-rwxr-xr-x | testsuite/gna/issue476/repro2/testsuite.sh | 11 | ||||
-rw-r--r-- | testsuite/gna/issue476/test_op.vhd | 71 | ||||
-rwxr-xr-x | testsuite/gna/issue476/testsuite.sh | 11 |
17 files changed, 693 insertions, 0 deletions
diff --git a/testsuite/gna/issue476/pixel_column_pkg.vhd b/testsuite/gna/issue476/pixel_column_pkg.vhd new file mode 100644 index 000000000..ce14bb5f3 --- /dev/null +++ b/testsuite/gna/issue476/pixel_column_pkg.vhd @@ -0,0 +1,69 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +use work.pixel_pkg; + +package pixel_column_pkg is + generic( + NBITS_IN : natural; + NBR_OF_CHROMA_IN : natural; + NBR_OF_ROW_IN : natural; + NBITS_OUT : natural; + NBR_OF_CHROMA_OUT : natural; + NBR_OF_ROW_OUT : natural; + package local_pixel_pkg is new pixel_pkg + generic map (<>) + ); + + use local_pixel_pkg.all; + + type TYPE_PIXEL_COLUMN_IN is array (NBR_OF_ROW_IN-1 downto 0) of TYPE_PIXEL_IN; + type TYPE_PIXEL_COLUMN_OUT is array (NBR_OF_ROW_OUT-1 downto 0) of TYPE_PIXEL_OUT; + + function std_logic_vector_to_pixel_column_in( in_vector : in std_logic_vector(NBR_OF_ROW_IN*NBR_OF_CHROMA_IN*NBITS_IN-1 downto 0)) + return TYPE_PIXEL_COLUMN_IN; + + function pixel_column_out_to_std_logic_vector( out_pixel_column : in TYPE_PIXEL_COLUMN_OUT) + return std_logic_vector; + + function "not" ( pixel_column_in : in TYPE_PIXEL_COLUMN_IN) + return TYPE_PIXEL_COLUMN_OUT; + + +end package pixel_column_pkg; + +package body pixel_column_pkg is + + function std_logic_vector_to_pixel_column_in( in_vector : in std_logic_vector(NBR_OF_ROW_IN*NBR_OF_CHROMA_IN*NBITS_IN-1 downto 0)) + return TYPE_PIXEL_COLUMN_IN is + variable pixel_column_in : TYPE_PIXEL_COLUMN_IN; + begin + for row in 0 to NBR_OF_ROW_IN -1 loop + pixel_column_in(row) := std_logic_vector_to_pixel_in(in_vector((row+1)*NBR_OF_CHROMA_IN*NBITS_IN-1 downto row*NBR_OF_CHROMA_IN*NBITS_IN)); + end loop; + return pixel_column_in; + end function std_logic_vector_to_pixel_column_in; + + function pixel_column_out_to_std_logic_vector( out_pixel_column : in TYPE_PIXEL_COLUMN_OUT) + return std_logic_vector is + variable out_vector : std_logic_vector(NBR_OF_ROW_OUT*NBR_OF_CHROMA_OUT*NBITS_OUT-1 downto 0); + begin + for row in 0 to NBR_OF_ROW_OUT loop + out_vector((row+1)*NBR_OF_CHROMA_IN*NBITS_IN-1 downto row*NBR_OF_CHROMA_IN*NBITS_IN) := pixel_out_to_std_logic_vector(out_pixel_column(row)); + end loop; + return out_vector; + end function pixel_column_out_to_std_logic_vector; + + function "not" ( pixel_column_in : in TYPE_PIXEL_COLUMN_IN) + return TYPE_PIXEL_COLUMN_OUT is + variable pixel_column_out : TYPE_PIXEL_COLUMN_OUT; + begin + for index in pixel_column_in'range loop + pixel_column_out(index) := not pixel_column_in(index); + end loop; + return pixel_column_out; + end function "not"; + +end package body pixel_column_pkg; + diff --git a/testsuite/gna/issue476/pixel_matrix_pkg.vhd b/testsuite/gna/issue476/pixel_matrix_pkg.vhd new file mode 100644 index 000000000..137f62844 --- /dev/null +++ b/testsuite/gna/issue476/pixel_matrix_pkg.vhd @@ -0,0 +1,75 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +use work.pixel_column_pkg; + +package pixel_matrix_pkg is + generic( + NBITS_IN : natural; + NBR_OF_CHROMA_IN : natural; + NBR_OF_ROW_IN : natural; + NBR_OF_COL_IN : natural; + NBITS_OUT : natural; + NBR_OF_CHROMA_OUT : natural; + NBR_OF_ROW_OUT : natural; + NBR_OF_COL_OUT : natural; + package local_pixel_column_pkg is new pixel_column_pkg generic map (<>) + ); + use local_pixel_column_pkg.all; + + type TYPE_PIXEL_MATRIX_IN is array (NBR_OF_COL_IN-1 downto 0) of TYPE_PIXEL_COLUMN_IN; + type TYPE_PIXEL_MATRIX_OUT is array (NBR_OF_COL_OUT-1 downto 0) of TYPE_PIXEL_COLUMN_OUT; + + -- Note: this pkgs is used to propagate the functions that where defined for a (N x 1) array of pixel + -- to a (N x M) array of pixel + + function std_logic_vector_to_pixel_matrix_in( in_vector : in std_logic_vector(NBR_OF_COL_IN*NBR_OF_ROW_IN*NBR_OF_CHROMA_IN*NBITS_IN-1 downto 0)) + return TYPE_PIXEL_MATRIX_IN; + + function pixel_matrix_out_to_std_logic_vector( out_pixel_matrix : in TYPE_PIXEL_MATRIX_OUT) + return std_logic_vector; + + + function "not" ( pixel_matrix_in : in TYPE_PIXEL_MATRIX_IN) + return TYPE_PIXEL_MATRIX_OUT; + + + +end package pixel_matrix_pkg; + +package body pixel_matrix_pkg is + + function std_logic_vector_to_pixel_matrix_in( in_vector : in std_logic_vector(NBR_OF_COL_IN*NBR_OF_ROW_IN*NBR_OF_CHROMA_IN*NBITS_IN-1 downto 0)) + return TYPE_PIXEL_MATRIX_IN is + variable pixel_matrix_in : TYPE_PIXEL_MATRIX_IN; + begin + for col in 0 to NBR_OF_COL_IN-1 loop + pixel_matrix_in(col) := std_logic_vector_to_pixel_column_in(in_vector((col+1)*NBR_OF_ROW_IN*NBR_OF_CHROMA_IN*NBITS_IN-1 downto col*NBR_OF_ROW_OUT*NBR_OF_CHROMA_IN*NBITS_IN)); + end loop; + return pixel_matrix_in; + end function std_logic_vector_to_pixel_matrix_in; + + function pixel_matrix_out_to_std_logic_vector( out_pixel_matrix : in TYPE_PIXEL_MATRIX_OUT) + return std_logic_vector is + variable out_vector : std_logic_vector(NBR_OF_COL_OUT*NBR_OF_ROW_OUT*NBR_OF_CHROMA_OUT*NBITS_OUT-1 downto 0); + begin + for col in 0 to NBR_OF_COL_OUT-1 loop + out_vector(((col+1)*NBR_OF_ROW_IN*NBR_OF_CHROMA_IN)*NBITS_IN-1 downto col*NBR_OF_ROW_OUT*NBR_OF_CHROMA_IN*NBITS_IN) := pixel_column_out_to_std_logic_vector(out_pixel_matrix(col)); + end loop; + return out_vector; + end function pixel_matrix_out_to_std_logic_vector; + + function "not" ( pixel_matrix_in : in TYPE_PIXEL_MATRIX_IN) + return TYPE_PIXEL_MATRIX_OUT is + variable pixel_matrix_out : TYPE_PIXEL_MATRIX_OUT; + begin + for index in 0 to NBR_OF_COL_IN-1 loop + pixel_matrix_out(index) := not pixel_matrix_in(index); + end loop; + return pixel_matrix_out; + end function "not"; + + +end package body pixel_matrix_pkg; + diff --git a/testsuite/gna/issue476/pixel_pkg.vhd b/testsuite/gna/issue476/pixel_pkg.vhd new file mode 100644 index 000000000..6ae4259f5 --- /dev/null +++ b/testsuite/gna/issue476/pixel_pkg.vhd @@ -0,0 +1,69 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +package pixel_pkg is + generic( + NBITS_IN : natural; + NBR_OF_CHROMA_IN : natural; + NBITS_OUT : natural; + NBR_OF_CHROMA_OUT : natural + ); + + subtype CHROMA_IN is unsigned(NBITS_IN-1 downto 0); + type TYPE_PIXEL_IN is array (NBR_OF_CHROMA_IN-1 downto 0) of CHROMA_IN; + + subtype CHROMA_OUT is unsigned(NBITS_OUT-1 downto 0); + type TYPE_PIXEL_OUT is array (NBR_OF_CHROMA_OUT-1 downto 0) of CHROMA_OUT; + + -- Note: every function is using unsigned vectors for now + + function std_logic_vector_to_pixel_in( in_vector : in std_logic_vector(NBR_OF_CHROMA_IN*NBITS_IN-1 downto 0)) + return TYPE_PIXEL_IN; + + function pixel_out_to_std_logic_vector( out_pixel : in TYPE_PIXEL_OUT) + return std_logic_vector; + + function "not" ( pixel_in : in TYPE_PIXEL_IN) + return TYPE_PIXEL_OUT; + + + + + +end package pixel_pkg; + +package body pixel_pkg is + + function std_logic_vector_to_pixel_in( in_vector : in std_logic_vector(NBR_OF_CHROMA_IN*NBITS_IN-1 downto 0)) + return TYPE_PIXEL_IN is + variable pixel_in : TYPE_PIXEL_IN; + begin + for chroma in 0 to NBR_OF_CHROMA_IN -1 loop + pixel_in(chroma) := unsigned(in_vector((chroma+1)*NBITS_IN-1 downto chroma*NBITS_IN)); + end loop; + return pixel_in; + end function std_logic_vector_to_pixel_in; + + function pixel_out_to_std_logic_vector( out_pixel : in TYPE_PIXEL_OUT) + return std_logic_vector is + variable out_vector : std_logic_vector(NBR_OF_CHROMA_OUT*NBITS_OUT-1 downto 0); + begin + for chroma in 0 to NBR_OF_CHROMA_OUT loop + out_vector((chroma+1)*NBITS_OUT-1 downto chroma*NBITS_OUT) := std_logic_vector(out_pixel(chroma)); + end loop; + return out_vector; + end function pixel_out_to_std_logic_vector; + + function "not" ( pixel_in : in TYPE_PIXEL_IN) + return TYPE_PIXEL_OUT is + variable pixel_out : TYPE_PIXEL_OUT; + begin + for index in pixel_in'range loop + pixel_out(index) := not pixel_in(index); + end loop; + return pixel_out; + end function "not"; + +end package body pixel_pkg; + diff --git a/testsuite/gna/issue476/repro/pixel_column_pkg.vhd b/testsuite/gna/issue476/repro/pixel_column_pkg.vhd new file mode 100644 index 000000000..c9a1d712a --- /dev/null +++ b/testsuite/gna/issue476/repro/pixel_column_pkg.vhd @@ -0,0 +1,38 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +use work.pixel_pkg; + +package pixel_column_pkg is + generic( + NBITS : natural; + NBR_OF_CHROMA : natural; + NBR_OF_ROW : natural; + package local_pixel_pkg is new pixel_pkg + generic map (<>) + ); + + use local_pixel_pkg.all; + + type TYPE_PIXEL_COLUMN is array (NBR_OF_ROW-1 downto 0) of TYPE_PIXEL; + + function std_logic_vector_to_pixel_column + (in_vector : in std_logic_vector(NBR_OF_ROW*NBR_OF_CHROMA*NBITS-1 downto 0)) + return TYPE_PIXEL_COLUMN; + +end package pixel_column_pkg; + +package body pixel_column_pkg is + + function std_logic_vector_to_pixel_column( in_vector : in std_logic_vector(NBR_OF_ROW*NBR_OF_CHROMA*NBITS-1 downto 0)) + return TYPE_PIXEL_COLUMN is + variable pixel_column : TYPE_PIXEL_COLUMN; + begin + for row in 0 to NBR_OF_ROW - 1 loop + pixel_column(row) := std_logic_vector_to_pixel(in_vector((row+1)*NBR_OF_CHROMA*NBITS-1 downto row*NBR_OF_CHROMA*NBITS)); + end loop; + return pixel_column; + end function std_logic_vector_to_pixel_column; +end package body pixel_column_pkg; + diff --git a/testsuite/gna/issue476/repro/pixel_matrix_pkg.vhd b/testsuite/gna/issue476/repro/pixel_matrix_pkg.vhd new file mode 100644 index 000000000..69478a68f --- /dev/null +++ b/testsuite/gna/issue476/repro/pixel_matrix_pkg.vhd @@ -0,0 +1,37 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +use work.pixel_column_pkg; + +package pixel_matrix_pkg is + generic( + NBITS : natural; + NBR_OF_CHROMA : natural; + NBR_OF_ROW : natural; + NBR_OF_COL : natural; + package local_pixel_column_pkg is new pixel_column_pkg generic map (<>) + ); + use local_pixel_column_pkg.all; + + type TYPE_PIXEL_MATRIX is array (NBR_OF_COL-1 downto 0) of TYPE_PIXEL_COLUMN; + -- Note: this pkgs is used to propagate the functions that where defined for a (N x 1) array of pixel + -- to a (N x M) array of pixel + + function std_logic_vector_to_pixel_matrix( in_vector : in std_logic_vector(NBR_OF_COL*NBR_OF_ROW*NBR_OF_CHROMA*NBITS-1 downto 0)) + return TYPE_PIXEL_MATRIX; +end package pixel_matrix_pkg; + +package body pixel_matrix_pkg is + + function std_logic_vector_to_pixel_matrix( in_vector : in std_logic_vector(NBR_OF_COL*NBR_OF_ROW*NBR_OF_CHROMA*NBITS-1 downto 0)) + return TYPE_PIXEL_MATRIX is + variable pixel_matrix : TYPE_PIXEL_MATRIX; + begin + for col in 0 to NBR_OF_COL-1 loop + pixel_matrix(col) := std_logic_vector_to_pixel_column(in_vector((col+1)*NBR_OF_ROW*NBR_OF_CHROMA*NBITS-1 downto col*NBR_OF_ROW*NBR_OF_CHROMA*NBITS)); + end loop; + return pixel_matrix; + end function std_logic_vector_to_pixel_matrix; +end package body pixel_matrix_pkg; + diff --git a/testsuite/gna/issue476/repro/pixel_pkg.vhd b/testsuite/gna/issue476/repro/pixel_pkg.vhd new file mode 100644 index 000000000..b6e988ad2 --- /dev/null +++ b/testsuite/gna/issue476/repro/pixel_pkg.vhd @@ -0,0 +1,32 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +package pixel_pkg is + generic( + NBITS : natural; + NBR_OF_CHROMA : natural + ); + + subtype CHROMA is unsigned(NBITS-1 downto 0); + type TYPE_PIXEL is array (NBR_OF_CHROMA-1 downto 0) of CHROMA; + + function std_logic_vector_to_pixel + (in_vector : in std_logic_vector(NBR_OF_CHROMA*NBITS-1 downto 0)) + return TYPE_PIXEL; +end package pixel_pkg; + +package body pixel_pkg is + + function std_logic_vector_to_pixel + ( in_vector : in std_logic_vector(NBR_OF_CHROMA*NBITS-1 downto 0)) + return TYPE_PIXEL is + variable pixel : TYPE_PIXEL; + begin + for chroma in 0 to NBR_OF_CHROMA -1 loop + pixel(chroma) := unsigned(in_vector((chroma+1)*NBITS-1 downto chroma*NBITS)); + end loop; + return pixel; + end function std_logic_vector_to_pixel; +end package body pixel_pkg; + diff --git a/testsuite/gna/issue476/repro/test_op.vhd b/testsuite/gna/issue476/repro/test_op.vhd new file mode 100644 index 000000000..ae1def6b7 --- /dev/null +++ b/testsuite/gna/issue476/repro/test_op.vhd @@ -0,0 +1,48 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity test_op is + generic ( + NBITS : natural := 1; + NBR_OF_CHROMA : natural := 1; + NBR_OF_ROW : natural := 1; + NBR_OF_COL : natural := 1; + NBR_OF_MATRIX : natural := 1); + port ( + signal clock, rst : in std_logic; + signal in_data : in std_logic_vector(NBR_OF_MATRIX*NBR_OF_COL*NBR_OF_ROW*NBR_OF_CHROMA*NBITS-1 downto 0)); +end entity test_op; + +architecture rtl of test_op is + + package local_pixel_pkg is new work.pixel_pkg + generic map ( + NBITS => NBITS, + NBR_OF_CHROMA => NBR_OF_CHROMA + ); + + package local_pixel_column_pkg is new work.pixel_column_pkg + generic map ( + NBITS => NBITS, + NBR_OF_CHROMA => NBR_OF_CHROMA, + NBR_OF_ROW => NBR_OF_ROW, + local_pixel_pkg => local_pixel_pkg + ); + + package local_pixel_matrix_pkg is new work.pixel_matrix_pkg + generic map ( + NBITS => NBITS, + NBR_OF_CHROMA => NBR_OF_CHROMA, + NBR_OF_ROW => NBR_OF_ROW, + NBR_OF_COL => NBR_OF_COL, + local_pixel_column_pkg => local_pixel_column_pkg + ); + + use local_pixel_matrix_pkg.all; + signal input_pixel_matrix : TYPE_PIXEL_MATRIX; +begin + + -- As soon as a function from the local_pixel_matrix_pkg is used it breaks + input_pixel_matrix <= std_logic_vector_to_pixel_matrix(in_data(NBR_OF_COL*NBR_OF_ROW*NBR_OF_CHROMA*NBITS-1 downto 0)); +end architecture rtl; diff --git a/testsuite/gna/issue476/repro/test_op1.vhd b/testsuite/gna/issue476/repro/test_op1.vhd new file mode 100644 index 000000000..b5416f704 --- /dev/null +++ b/testsuite/gna/issue476/repro/test_op1.vhd @@ -0,0 +1,39 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity test_op1 is + generic ( + NBITS : natural := 1; + NBR_OF_CHROMA : natural := 1; + NBR_OF_ROW : natural := 1; + NBR_OF_COL : natural := 1; + NBR_OF_MATRIX : natural := 1); + port ( + signal clock, rst : in std_logic; + signal in_data : in std_logic_vector(NBR_OF_MATRIX*NBR_OF_COL*NBR_OF_ROW*NBR_OF_CHROMA*NBITS-1 downto 0)); +end entity test_op1; + +architecture rtl of test_op1 is + + package local_pixel_pkg is new work.pixel_pkg + generic map ( + NBITS => NBITS, + NBR_OF_CHROMA => NBR_OF_CHROMA + ); + + package local_pixel_column_pkg is new work.pixel_column_pkg + generic map ( + NBITS => NBITS, + NBR_OF_CHROMA => NBR_OF_CHROMA, + NBR_OF_ROW => NBR_OF_ROW, + local_pixel_pkg => local_pixel_pkg + ); + + use local_pixel_column_pkg.all; + signal input_pixel_column : TYPE_PIXEL_COLUMN; +begin + + -- As soon as a function from the local_pixel_matrix_pkg is used it breaks + input_pixel_column <= std_logic_vector_to_pixel_column(in_data(NBR_OF_ROW*NBR_OF_CHROMA*NBITS-1 downto 0)); +end architecture rtl; diff --git a/testsuite/gna/issue476/repro/testsuite.sh b/testsuite/gna/issue476/repro/testsuite.sh new file mode 100755 index 000000000..69c5cbd16 --- /dev/null +++ b/testsuite/gna/issue476/repro/testsuite.sh @@ -0,0 +1,11 @@ +#! /bin/sh + +. ../../../testenv.sh + +export GHDL_STD_FLAGS=--std=08 +analyze pixel_pkg.vhd pixel_column_pkg.vhd pixel_matrix_pkg.vhd test_op1.vhd +elab_simulate test_op1 + +clean + +echo "Test successful" diff --git a/testsuite/gna/issue476/repro2/pixel_column_pkg.vhd b/testsuite/gna/issue476/repro2/pixel_column_pkg.vhd new file mode 100644 index 000000000..6583b6239 --- /dev/null +++ b/testsuite/gna/issue476/repro2/pixel_column_pkg.vhd @@ -0,0 +1,34 @@ +use work.pixel_pkg; + +package pixel_column_pkg is + generic( + NBITS : natural; + NBR_OF_CHROMA : natural; + NBR_OF_ROW : natural; + package local_pixel_pkg is new pixel_pkg + generic map (<>) + ); + + use local_pixel_pkg.all; + + type TYPE_PIXEL_COLUMN is array (NBR_OF_ROW-1 downto 0) of TYPE_PIXEL; + + function bit_vector_to_pixel_column + (in_vector : in bit_vector(NBR_OF_ROW*NBR_OF_CHROMA*NBITS-1 downto 0)) + return TYPE_PIXEL_COLUMN; + +end package pixel_column_pkg; + +package body pixel_column_pkg is + + function bit_vector_to_pixel_column( in_vector : in bit_vector(NBR_OF_ROW*NBR_OF_CHROMA*NBITS-1 downto 0)) + return TYPE_PIXEL_COLUMN is + variable pixel_column : TYPE_PIXEL_COLUMN; + begin + for row in 0 to NBR_OF_ROW-1 loop + pixel_column(row) := bit_vector_to_pixel(in_vector((row+1)*NBR_OF_CHROMA*NBITS-1 downto row*NBR_OF_CHROMA*NBITS)); + end loop; + return pixel_column; + end function bit_vector_to_pixel_column; +end package body pixel_column_pkg; + diff --git a/testsuite/gna/issue476/repro2/pixel_matrix_pkg.vhd b/testsuite/gna/issue476/repro2/pixel_matrix_pkg.vhd new file mode 100644 index 000000000..69478a68f --- /dev/null +++ b/testsuite/gna/issue476/repro2/pixel_matrix_pkg.vhd @@ -0,0 +1,37 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +use work.pixel_column_pkg; + +package pixel_matrix_pkg is + generic( + NBITS : natural; + NBR_OF_CHROMA : natural; + NBR_OF_ROW : natural; + NBR_OF_COL : natural; + package local_pixel_column_pkg is new pixel_column_pkg generic map (<>) + ); + use local_pixel_column_pkg.all; + + type TYPE_PIXEL_MATRIX is array (NBR_OF_COL-1 downto 0) of TYPE_PIXEL_COLUMN; + -- Note: this pkgs is used to propagate the functions that where defined for a (N x 1) array of pixel + -- to a (N x M) array of pixel + + function std_logic_vector_to_pixel_matrix( in_vector : in std_logic_vector(NBR_OF_COL*NBR_OF_ROW*NBR_OF_CHROMA*NBITS-1 downto 0)) + return TYPE_PIXEL_MATRIX; +end package pixel_matrix_pkg; + +package body pixel_matrix_pkg is + + function std_logic_vector_to_pixel_matrix( in_vector : in std_logic_vector(NBR_OF_COL*NBR_OF_ROW*NBR_OF_CHROMA*NBITS-1 downto 0)) + return TYPE_PIXEL_MATRIX is + variable pixel_matrix : TYPE_PIXEL_MATRIX; + begin + for col in 0 to NBR_OF_COL-1 loop + pixel_matrix(col) := std_logic_vector_to_pixel_column(in_vector((col+1)*NBR_OF_ROW*NBR_OF_CHROMA*NBITS-1 downto col*NBR_OF_ROW*NBR_OF_CHROMA*NBITS)); + end loop; + return pixel_matrix; + end function std_logic_vector_to_pixel_matrix; +end package body pixel_matrix_pkg; + diff --git a/testsuite/gna/issue476/repro2/pixel_pkg.vhd b/testsuite/gna/issue476/repro2/pixel_pkg.vhd new file mode 100644 index 000000000..a00f6f519 --- /dev/null +++ b/testsuite/gna/issue476/repro2/pixel_pkg.vhd @@ -0,0 +1,28 @@ +package pixel_pkg is + generic( + NBITS : natural; + NBR_OF_CHROMA : natural + ); + + subtype CHROMA is bit_vector(NBITS-1 downto 0); + type TYPE_PIXEL is array (NBR_OF_CHROMA-1 downto 0) of CHROMA; + + function bit_vector_to_pixel + (in_vector : in bit_vector(NBR_OF_CHROMA*NBITS-1 downto 0)) + return TYPE_PIXEL; +end package pixel_pkg; + +package body pixel_pkg is + + function bit_vector_to_pixel + ( in_vector : in bit_vector(NBR_OF_CHROMA*NBITS-1 downto 0)) + return TYPE_PIXEL is + variable pixel : TYPE_PIXEL; + begin + for chroma in 0 to NBR_OF_CHROMA -1 loop + pixel(chroma) := in_vector((chroma+1)*NBITS-1 downto chroma*NBITS); + end loop; + return pixel; + end function bit_vector_to_pixel; +end package body pixel_pkg; + diff --git a/testsuite/gna/issue476/repro2/test_op.vhd b/testsuite/gna/issue476/repro2/test_op.vhd new file mode 100644 index 000000000..ae1def6b7 --- /dev/null +++ b/testsuite/gna/issue476/repro2/test_op.vhd @@ -0,0 +1,48 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity test_op is + generic ( + NBITS : natural := 1; + NBR_OF_CHROMA : natural := 1; + NBR_OF_ROW : natural := 1; + NBR_OF_COL : natural := 1; + NBR_OF_MATRIX : natural := 1); + port ( + signal clock, rst : in std_logic; + signal in_data : in std_logic_vector(NBR_OF_MATRIX*NBR_OF_COL*NBR_OF_ROW*NBR_OF_CHROMA*NBITS-1 downto 0)); +end entity test_op; + +architecture rtl of test_op is + + package local_pixel_pkg is new work.pixel_pkg + generic map ( + NBITS => NBITS, + NBR_OF_CHROMA => NBR_OF_CHROMA + ); + + package local_pixel_column_pkg is new work.pixel_column_pkg + generic map ( + NBITS => NBITS, + NBR_OF_CHROMA => NBR_OF_CHROMA, + NBR_OF_ROW => NBR_OF_ROW, + local_pixel_pkg => local_pixel_pkg + ); + + package local_pixel_matrix_pkg is new work.pixel_matrix_pkg + generic map ( + NBITS => NBITS, + NBR_OF_CHROMA => NBR_OF_CHROMA, + NBR_OF_ROW => NBR_OF_ROW, + NBR_OF_COL => NBR_OF_COL, + local_pixel_column_pkg => local_pixel_column_pkg + ); + + use local_pixel_matrix_pkg.all; + signal input_pixel_matrix : TYPE_PIXEL_MATRIX; +begin + + -- As soon as a function from the local_pixel_matrix_pkg is used it breaks + input_pixel_matrix <= std_logic_vector_to_pixel_matrix(in_data(NBR_OF_COL*NBR_OF_ROW*NBR_OF_CHROMA*NBITS-1 downto 0)); +end architecture rtl; diff --git a/testsuite/gna/issue476/repro2/test_op1.vhd b/testsuite/gna/issue476/repro2/test_op1.vhd new file mode 100644 index 000000000..def987f76 --- /dev/null +++ b/testsuite/gna/issue476/repro2/test_op1.vhd @@ -0,0 +1,35 @@ +entity test_op1 is + generic ( + NBITS : natural := 1; + NBR_OF_CHROMA : natural := 1; + NBR_OF_ROW : natural := 1; + NBR_OF_COL : natural := 1; + NBR_OF_MATRIX : natural := 1); + port ( + signal clock, rst : in bit; + signal in_data : in bit_vector(NBR_OF_MATRIX*NBR_OF_COL*NBR_OF_ROW*NBR_OF_CHROMA*NBITS-1 downto 0)); +end entity test_op1; + +architecture rtl of test_op1 is + + package inst_pixel_pkg is new work.pixel_pkg + generic map ( + NBITS => NBITS, + NBR_OF_CHROMA => NBR_OF_CHROMA + ); + + package inst_pixel_column_pkg is new work.pixel_column_pkg + generic map ( + NBITS => NBITS, + NBR_OF_CHROMA => NBR_OF_CHROMA, + NBR_OF_ROW => NBR_OF_ROW, + local_pixel_pkg => inst_pixel_pkg + ); + + use inst_pixel_column_pkg.all; + signal input_pixel_column : TYPE_PIXEL_COLUMN; +begin + + -- As soon as a function from the local_pixel_matrix_pkg is used it breaks + input_pixel_column <= bit_vector_to_pixel_column(in_data(NBR_OF_ROW*NBR_OF_CHROMA*NBITS-1 downto 0)); +end architecture rtl; diff --git a/testsuite/gna/issue476/repro2/testsuite.sh b/testsuite/gna/issue476/repro2/testsuite.sh new file mode 100755 index 000000000..cb988307e --- /dev/null +++ b/testsuite/gna/issue476/repro2/testsuite.sh @@ -0,0 +1,11 @@ +#! /bin/sh + +. ../../../testenv.sh + +export GHDL_STD_FLAGS=--std=08 +analyze pixel_pkg.vhd pixel_column_pkg.vhd test_op1.vhd +elab_simulate test_op1 + +clean + +echo "Test successful" diff --git a/testsuite/gna/issue476/test_op.vhd b/testsuite/gna/issue476/test_op.vhd new file mode 100644 index 000000000..06cd15d11 --- /dev/null +++ b/testsuite/gna/issue476/test_op.vhd @@ -0,0 +1,71 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity test_op is + generic ( + NBITS_IN : natural := 1; + NBR_OF_CHROMA_IN : natural := 1; + NBR_OF_ROW_IN : natural := 1; + NBR_OF_COL_IN : natural := 1; + NBITS_OUT : natural := 2; + NBR_OF_CHROMA_OUT : natural := 1; + NBR_OF_ROW_OUT : natural := 1; + NBR_OF_COL_OUT : natural := 1; + NBR_OF_MATRIX_IN : natural := 1; + NBR_OF_MATRIX_OUT : natural := 1); + port ( + signal clock, rst : in std_logic; + signal in_data : in std_logic_vector(NBR_OF_MATRIX_IN*NBR_OF_COL_IN*NBR_OF_ROW_IN*NBR_OF_CHROMA_IN*NBITS_IN-1 downto 0); + signal out_data : out std_logic_vector(NBR_OF_MATRIX_OUT*NBR_OF_COL_OUT*NBR_OF_ROW_OUT*NBR_OF_CHROMA_OUT*NBITS_OUT-1 downto 0)); +end entity test_op; + +architecture rtl of test_op is + + package local_pixel_pkg is new work.pixel_pkg + generic map ( + NBITS_IN => NBITS_IN, + NBR_OF_CHROMA_IN => NBR_OF_CHROMA_IN, + NBITS_OUT => NBITS_OUT, + NBR_OF_CHROMA_OUT => NBR_OF_CHROMA_OUT + ); + + package local_pixel_column_pkg is new work.pixel_column_pkg + generic map ( + NBITS_IN => NBITS_IN, + NBR_OF_CHROMA_IN => NBR_OF_CHROMA_IN, + NBR_OF_ROW_IN => NBR_OF_ROW_IN, + NBITS_OUT => NBITS_OUT, + NBR_OF_CHROMA_OUT => NBR_OF_CHROMA_OUT, + NBR_OF_ROW_OUT => NBR_OF_ROW_OUT, + local_pixel_pkg => local_pixel_pkg + ); + + package local_pixel_matrix_pkg is new work.pixel_matrix_pkg + generic map ( + NBITS_IN => NBITS_IN, + NBR_OF_CHROMA_IN => NBR_OF_CHROMA_IN, + NBR_OF_ROW_IN => NBR_OF_ROW_IN, + NBR_OF_COL_IN => NBR_OF_COL_IN, + NBITS_OUT => NBITS_OUT, + NBR_OF_CHROMA_OUT => NBR_OF_CHROMA_OUT, + NBR_OF_ROW_OUT => NBR_OF_ROW_OUT, + NBR_OF_COL_OUT => NBR_OF_COL_OUT, + local_pixel_column_pkg => local_pixel_column_pkg + ); + + use local_pixel_matrix_pkg.all; + signal input_pixel_matrix : TYPE_PIXEL_MATRIX_IN; + signal output_pixel_matrix : TYPE_PIXEL_MATRIX_OUT; +begin + + -- As soon as a function from the local_pixel_matrix_pkg is used it breaks + input_pixel_matrix <= std_logic_vector_to_pixel_matrix_in(in_data(NBR_OF_COL_IN*NBR_OF_ROW_IN*NBR_OF_CHROMA_IN*NBITS_IN-1 downto 0)); + + -- Note: Commented out more complex operation to show that the error is generated regardless + -- Uncomment to have more "complete" code + --output_pixel_matrix <= not input_pixel_matrix; + out_data <= (others => '0'); --pixel_matrix_out_to_std_logic_vector(output_pixel_matrix); + --out_data <= in_data(NBR_OF_MATRIX_OUT*NBR_OF_COL_OUT*NBR_OF_ROW_OUT*NBR_OF_CHROMA_OUT*NBITS_OUT-1 downto 0); + +end architecture rtl; diff --git a/testsuite/gna/issue476/testsuite.sh b/testsuite/gna/issue476/testsuite.sh new file mode 100755 index 000000000..5c372de19 --- /dev/null +++ b/testsuite/gna/issue476/testsuite.sh @@ -0,0 +1,11 @@ +#! /bin/sh + +. ../../testenv.sh + +export GHDL_STD_FLAGS=--std=08 +analyze pixel_pkg.vhd pixel_column_pkg.vhd pixel_matrix_pkg.vhd test_op.vhd +elab_simulate test_op + +clean + +echo "Test successful" |