From 63c97602af5a19a6e3e48c6c1cafb98f0bb9359d Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Sun, 7 Aug 2022 07:11:51 +0200 Subject: testsuite/gna: add a reproducer for #2163 --- testsuite/gna/issue2163/memory_pkg.vhdl | 12 ++++++++++++ testsuite/gna/issue2163/pkg1.vhdl | 30 ++++++++++++++++++++++++++++++ testsuite/gna/issue2163/pkg2.vhdl | 27 +++++++++++++++++++++++++++ testsuite/gna/issue2163/pkg3.vhdl | 31 +++++++++++++++++++++++++++++++ testsuite/gna/issue2163/testsuite.sh | 16 ++++++++++++++++ 5 files changed, 116 insertions(+) create mode 100644 testsuite/gna/issue2163/memory_pkg.vhdl create mode 100644 testsuite/gna/issue2163/pkg1.vhdl create mode 100644 testsuite/gna/issue2163/pkg2.vhdl create mode 100644 testsuite/gna/issue2163/pkg3.vhdl create mode 100755 testsuite/gna/issue2163/testsuite.sh (limited to 'testsuite') diff --git a/testsuite/gna/issue2163/memory_pkg.vhdl b/testsuite/gna/issue2163/memory_pkg.vhdl new file mode 100644 index 000000000..952999770 --- /dev/null +++ b/testsuite/gna/issue2163/memory_pkg.vhdl @@ -0,0 +1,12 @@ +library ieee; +use ieee.std_logic_1164.all; + +package MemoryGenericPkg is + generic ( + type MemoryBaseType ; + function ToMemoryBaseType(A : std_logic_vector) return MemoryBaseType is <> ; + function FromMemoryBaseType(A : MemoryBaseType ; Size : integer) return std_logic_vector is <> ; + function InitMemoryBaseType(Size : integer) return MemoryBaseType is <> + ) ; +-- Stuff +end package MemoryGenericPkg ; diff --git a/testsuite/gna/issue2163/pkg1.vhdl b/testsuite/gna/issue2163/pkg1.vhdl new file mode 100644 index 000000000..b6737a7d4 --- /dev/null +++ b/testsuite/gna/issue2163/pkg1.vhdl @@ -0,0 +1,30 @@ +package pkg1 is + generic ( + type atyp; + function plus (a: atyp) return natural is <>); + function wrap (a : atyp) return natural; +end pkg1; + +package body pkg1 is + function wrap (a : atyp) return natural is + begin + return plus (a); + end wrap; +end pkg1; + + +entity tb_pkg1 is +end; + +architecture behav of tb_pkg1 is + function plus (a: bit_vector) return natural is + begin + return a'length; + end plus; + + package my_pkg1 is new work.pkg1 generic map (atyp => bit_vector); + + constant c : natural := my_pkg1.wrap("0101"); +begin + assert c = 4 severity failure; +end behav; diff --git a/testsuite/gna/issue2163/pkg2.vhdl b/testsuite/gna/issue2163/pkg2.vhdl new file mode 100644 index 000000000..232419e06 --- /dev/null +++ b/testsuite/gna/issue2163/pkg2.vhdl @@ -0,0 +1,27 @@ +package pkg2 is + generic ( + type atyp; + function plus (a: atyp) return natural is <>); + function wrap (a : atyp) return natural; +end pkg2; + +package body pkg2 is + function wrap (a : atyp) return natural is + begin + return plus (a); + end wrap; +end pkg2; + + +entity tb_pkg2 is +end; + +architecture behav of tb_pkg2 is + constant plus : natural := 5; + package my_pkg2 is new work.pkg2 + generic map (atyp => bit_vector, plus => plus); + + constant c : natural := my_pkg2.wrap("0101"); +begin + assert c = 4 severity failure; +end behav; diff --git a/testsuite/gna/issue2163/pkg3.vhdl b/testsuite/gna/issue2163/pkg3.vhdl new file mode 100644 index 000000000..724488def --- /dev/null +++ b/testsuite/gna/issue2163/pkg3.vhdl @@ -0,0 +1,31 @@ +package pkg3 is + generic ( + type atyp; + function plus (a: atyp) return natural is <>); + function wrap (a : atyp) return natural; +end pkg3; + +package body pkg3 is + function wrap (a : atyp) return natural is + begin + return plus (a); + end wrap; +end pkg3; + + +entity tb_pkg3 is +end; + +architecture behav of tb_pkg3 is + function plus (a: bit_vector) return natural is + begin + return a'length; + end plus; + + package my_pkg3 is new work.pkg3 generic map (atyp => bit_vector, + plus => open); + + constant c : natural := my_pkg3.wrap("0101"); +begin + assert c = 4 severity failure; +end behav; diff --git a/testsuite/gna/issue2163/testsuite.sh b/testsuite/gna/issue2163/testsuite.sh new file mode 100755 index 000000000..34140d8c2 --- /dev/null +++ b/testsuite/gna/issue2163/testsuite.sh @@ -0,0 +1,16 @@ +#! /bin/sh + +. ../../testenv.sh + +export GHDL_STD_FLAGS=--std=08 +analyze_failure pkg2.vhdl + +analyze pkg1.vhdl +elab_simulate tb_pkg1 + +analyze pkg3.vhdl +elab_simulate tb_pkg3 + +clean + +echo "Test successful" -- cgit v1.2.3