From 87a7bc3cdc20d1a4ac04d41fcea795387a02281f Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Thu, 16 Apr 2020 17:49:17 +0200 Subject: testsuite/gna: add a test for #1229 --- testsuite/gna/issue1229/aux.c | 1 + testsuite/gna/issue1229/pkg.vhdl | 20 ++++++++++++++++++++ testsuite/gna/issue1229/tb.vhdl | 17 +++++++++++++++++ testsuite/gna/issue1229/testsuite.sh | 15 +++++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 testsuite/gna/issue1229/aux.c create mode 100644 testsuite/gna/issue1229/pkg.vhdl create mode 100644 testsuite/gna/issue1229/tb.vhdl create mode 100755 testsuite/gna/issue1229/testsuite.sh (limited to 'testsuite/gna') diff --git a/testsuite/gna/issue1229/aux.c b/testsuite/gna/issue1229/aux.c new file mode 100644 index 000000000..f355dea13 --- /dev/null +++ b/testsuite/gna/issue1229/aux.c @@ -0,0 +1 @@ +int getInt(){return 141;} diff --git a/testsuite/gna/issue1229/pkg.vhdl b/testsuite/gna/issue1229/pkg.vhdl new file mode 100644 index 000000000..660b00a58 --- /dev/null +++ b/testsuite/gna/issue1229/pkg.vhdl @@ -0,0 +1,20 @@ +package pkg is + generic (N : integer := 2); + + procedure showPackageN; + + impure function c_int return integer; + attribute foreign of c_int : function is "VHPIDIRECT aux.so getInt"; +end package pkg; + +package body pkg is + procedure showPackageN is + begin + report integer'image(N); + end; + + impure function c_int return integer is + begin + assert false report "c_int VHPI" severity failure; + end c_int; +end package body pkg; diff --git a/testsuite/gna/issue1229/tb.vhdl b/testsuite/gna/issue1229/tb.vhdl new file mode 100644 index 000000000..efe510017 --- /dev/null +++ b/testsuite/gna/issue1229/tb.vhdl @@ -0,0 +1,17 @@ +entity tb is +end entity tb; + +architecture RTL of tb is + package tbpkg is new work.pkg generic map (N => 3); +begin + process + use tbpkg.all; + variable int : integer := c_int; + begin + report tbpkg.c_int'foreign; + + showPackageN; + report "C Int: " & integer'image(int); + wait; + end process; +end architecture RTL; diff --git a/testsuite/gna/issue1229/testsuite.sh b/testsuite/gna/issue1229/testsuite.sh new file mode 100755 index 000000000..67082607b --- /dev/null +++ b/testsuite/gna/issue1229/testsuite.sh @@ -0,0 +1,15 @@ +#! /bin/sh + +. ../../testenv.sh + +gcc -c -fPIC aux.c +gcc -shared -o aux.so aux.o + +export GHDL_STD_FLAGS=--std=08 +analyze pkg.vhdl tb.vhdl +elab_simulate tb + +clean +rm -f aux.o aux.so + +echo "Test successful" -- cgit v1.2.3