diff options
author | Tristan Gingold <tgingold@free.fr> | 2023-02-19 12:30:58 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2023-02-19 12:30:58 +0100 |
commit | effe346b0f7d17b377255af1528303335ce7b2b6 (patch) | |
tree | f31c660466d5d7a22bbfdcd48e1f618833f5cb38 | |
parent | 3987fc5bb73352e696adf00dcadbb16b890b6199 (diff) | |
download | ghdl-effe346b0f7d17b377255af1528303335ce7b2b6.tar.gz ghdl-effe346b0f7d17b377255af1528303335ce7b2b6.tar.bz2 ghdl-effe346b0f7d17b377255af1528303335ce7b2b6.zip |
testsuite/gna: add a test for #2353
-rw-r--r-- | testsuite/gna/issue2353/atest_tb.vhdl | 27 | ||||
-rw-r--r-- | testsuite/gna/issue2353/pkg_a.vhdl | 15 | ||||
-rw-r--r-- | testsuite/gna/issue2353/pkg_b.vhdl | 68 | ||||
-rw-r--r-- | testsuite/gna/issue2353/repro1.vhdl | 32 | ||||
-rw-r--r-- | testsuite/gna/issue2353/repro2.vhdl | 42 | ||||
-rwxr-xr-x | testsuite/gna/issue2353/testsuite.sh | 39 |
6 files changed, 223 insertions, 0 deletions
diff --git a/testsuite/gna/issue2353/atest_tb.vhdl b/testsuite/gna/issue2353/atest_tb.vhdl new file mode 100644 index 000000000..39c41011d --- /dev/null +++ b/testsuite/gna/issue2353/atest_tb.vhdl @@ -0,0 +1,27 @@ +library ieee; +use ieee.std_logic_1164.all; + +library osvvm; +library work; + +entity atest_tb is + generic ( + G_TB : integer := 1 + ); +end entity; + +architecture behv of atest_tb is + + package b_inst is new work.b generic map (G_TB); + + signal s_scoreboard : b_inst.scoreboard.ScoreboardIDType; + +begin + + p1 : process is + begin + s_scoreboard <= b_inst.scoreboard.NewID("FIFO"); + wait; + end process p1; + +end architecture;
\ No newline at end of file diff --git a/testsuite/gna/issue2353/pkg_a.vhdl b/testsuite/gna/issue2353/pkg_a.vhdl new file mode 100644 index 000000000..1fac9b223 --- /dev/null +++ b/testsuite/gna/issue2353/pkg_a.vhdl @@ -0,0 +1,15 @@ +library ieee; +use ieee.std_logic_1164.all; + +package a is + generic ( + G_a: integer + ); + + type slv8_array_t is array (natural range <>) of std_logic_vector(7 downto 0); + + type my_type_t is record + a : slv8_array_t(0 to G_a - 1); + end record my_type_t; + +end package a; diff --git a/testsuite/gna/issue2353/pkg_b.vhdl b/testsuite/gna/issue2353/pkg_b.vhdl new file mode 100644 index 000000000..a5971a5f5 --- /dev/null +++ b/testsuite/gna/issue2353/pkg_b.vhdl @@ -0,0 +1,68 @@ + +library ieee; +use ieee.std_logic_1164.all; + +library osvvm; +library work; + +package b is + generic ( + G_b: integer + ); + + package a_inst is new work.a generic map (G_b); + use a_inst.all; + + -- OSVVM string helper function + function ToString( + i_my_type : a_inst.my_type_t + ) return string; + + -- OSVVM compare helper function + function Compare( + i_my_type_a : a_inst.my_type_t; + i_my_type_b : a_inst.my_type_t + ) return boolean; + + -- scoreboard specificiation + package scoreboard is new osvvm.ScoreBoardGenericPkg + generic map ( + ExpectedType => a_inst.my_type_t, + ActualType => a_inst.my_type_t, + match => Compare, + expected_to_string => ToString, + actual_to_string => ToString + ); + + +end package b; + +package body b is + + function ToString( + i_my_type : a_inst.my_type_t + ) return string is + constant c_str : string := "Num el: " & integer'image(i_my_type.a'length); + begin + return c_str; + end function ToString; + + -- OSVVM compare helper function + function Compare( + i_my_type_a : a_inst.my_type_t; + i_my_type_b : a_inst.my_type_t + ) return boolean is + variable v_rtn : boolean; + begin + v_rtn := true; + + for idx in i_my_type_a.a'range loop + if i_my_type_a.a(idx) /= i_my_type_b.a(idx) then + v_rtn := false; + end if; + end loop; + + return v_rtn; + end function Compare; + +end package body b;
\ No newline at end of file diff --git a/testsuite/gna/issue2353/repro1.vhdl b/testsuite/gna/issue2353/repro1.vhdl new file mode 100644 index 000000000..073f10251 --- /dev/null +++ b/testsuite/gna/issue2353/repro1.vhdl @@ -0,0 +1,32 @@ +package repro1_gpkg is + generic (type t); + + function get return natural; +end; + + +package body repro1_gpkg is + function get1 return natural is + begin + report "get1 called"; + return 123; + end get1; + + constant c : natural := get1; + + function get return natural is + begin + report "get called, return: " & natural'image (c); + return c; + end get; +end; + +entity repro1 is +end; + +architecture behav of repro1 is + package inst is new work.repro1_gpkg generic map (t => bit); +begin + assert inst.get > 120 and inst.get < 130 severity failure; +end; + diff --git a/testsuite/gna/issue2353/repro2.vhdl b/testsuite/gna/issue2353/repro2.vhdl new file mode 100644 index 000000000..fb4ff7c99 --- /dev/null +++ b/testsuite/gna/issue2353/repro2.vhdl @@ -0,0 +1,42 @@ +package repro2_pkg is + function get return natural; +end; + +package body repro2_pkg is + function get1 return natural is + begin + report "get1 called"; + return 123; + end get1; + + constant c : natural := get1; + + function get return natural is + begin + report "get called, return: " & natural'image (c); + return c; + end get; +end repro2_pkg; + +package repro2_gpkg is + generic (type t); + + function get return natural; +end; + +package body repro2_gpkg is + function get return natural is + begin + return work.repro2_pkg.get; + end get; +end; + +entity repro2 is +end; + +architecture behav of repro2 is + package inst is new work.repro2_gpkg generic map (t => bit); +begin + assert inst.get > 120 and inst.get < 130 severity failure; +end; + diff --git a/testsuite/gna/issue2353/testsuite.sh b/testsuite/gna/issue2353/testsuite.sh new file mode 100755 index 000000000..557d63b1e --- /dev/null +++ b/testsuite/gna/issue2353/testsuite.sh @@ -0,0 +1,39 @@ +#! /bin/sh + +. ../../testenv.sh + +export GHDL_STD_FLAGS="--std=08" + +analyze repro1.vhdl +elab_simulate repro1 + +analyze repro2.vhdl +elab_simulate repro2 + +clean + +if false; then + export GHDL_STD_FLAGS="--std=08 --work=osvvm" + + analyze OSVVM/NamePkg.vhd + analyze OSVVM/TextUtilPkg.vhd + analyze OSVVM/OsvvmGlobalPkg.vhd + analyze OSVVM/OsvvmScriptSettingsPkg.vhd + analyze OSVVM/TranscriptPkg.vhd + analyze OSVVM/AlertLogPkg.vhd + analyze OSVVM/ResolutionPkg.vhd + analyze OSVVM/NameStorePkg.vhd + analyze OSVVM/ScoreboardGenericPkg.vhd + + export GHDL_STD_FLAGS="--std=08" + + analyze pkg_a.vhdl + analyze pkg_b.vhdl + analyze atest_tb.vhdl + elab_simulate atest_tb + + clean + clean osvvm +fi + +echo "Test successful" |