aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/synth
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2022-01-16 19:12:07 +0100
committerTristan Gingold <tgingold@free.fr>2022-01-16 19:12:07 +0100
commitaee3585afb2d5797d3cca5f13ae4a2c1a64b1267 (patch)
treeddb837d1ceadb11e93840c2d0cdba63e5f8ded38 /testsuite/synth
parent8503d1a87282fdd57e7cd85007799ad752ebf048 (diff)
downloadghdl-aee3585afb2d5797d3cca5f13ae4a2c1a64b1267.tar.gz
ghdl-aee3585afb2d5797d3cca5f13ae4a2c1a64b1267.tar.bz2
ghdl-aee3585afb2d5797d3cca5f13ae4a2c1a64b1267.zip
testsuite/synth: add more tests for generic packages
Diffstat (limited to 'testsuite/synth')
-rw-r--r--testsuite/synth/gen01/pkg01.vhdl24
-rw-r--r--testsuite/synth/gen01/pkg02.vhdl25
-rw-r--r--testsuite/synth/gen01/pkg03.vhdl27
-rw-r--r--testsuite/synth/gen01/pkg04.vhdl27
-rwxr-xr-xtestsuite/synth/gen01/testsuite.sh4
5 files changed, 107 insertions, 0 deletions
diff --git a/testsuite/synth/gen01/pkg01.vhdl b/testsuite/synth/gen01/pkg01.vhdl
new file mode 100644
index 000000000..e0faedb16
--- /dev/null
+++ b/testsuite/synth/gen01/pkg01.vhdl
@@ -0,0 +1,24 @@
+package gen is
+ generic (val : integer);
+
+ function get_val (x : integer) return integer;
+end;
+
+package body gen is
+ function get_val (x : integer) return integer is
+ begin
+ return val + x;
+ end get_val;
+end;
+
+entity pkg01 is
+ port (i : in integer;
+ o : out integer);
+end pkg01;
+
+architecture behav of pkg01 is
+ package inst1 is new work.gen generic map (val => 2);
+ use inst1.all;
+begin
+ o <= get_val (i);
+end behav;
diff --git a/testsuite/synth/gen01/pkg02.vhdl b/testsuite/synth/gen01/pkg02.vhdl
new file mode 100644
index 000000000..326246d8f
--- /dev/null
+++ b/testsuite/synth/gen01/pkg02.vhdl
@@ -0,0 +1,25 @@
+package gen is
+ generic (val : integer);
+
+ function get_val (x : integer) return integer;
+end;
+
+package body gen is
+ function get_val (x : integer) return integer is
+ begin
+ return val + x;
+ end get_val;
+end;
+
+package inst1 is new work.gen generic map (val => 3);
+
+entity pkg02 is
+ port (i : in integer;
+ o : out integer);
+end pkg02;
+
+architecture behav of pkg02 is
+ use work.inst1.all;
+begin
+ o <= get_val (i);
+end behav;
diff --git a/testsuite/synth/gen01/pkg03.vhdl b/testsuite/synth/gen01/pkg03.vhdl
new file mode 100644
index 000000000..04e038bac
--- /dev/null
+++ b/testsuite/synth/gen01/pkg03.vhdl
@@ -0,0 +1,27 @@
+package gen is
+ generic (max : natural);
+
+ subtype my_int is integer range 0 to max;
+
+ function get_val (x : my_int) return my_int;
+end;
+
+package body gen is
+ function get_val (x : my_int) return my_int is
+ begin
+ return x + 1;
+ end get_val;
+end;
+
+package inst1 is new work.gen generic map (max => 3);
+
+entity pkg03 is
+ port (i : in integer;
+ o : out integer);
+end pkg03;
+
+architecture behav of pkg03 is
+ use work.inst1.all;
+begin
+ o <= get_val (i);
+end behav;
diff --git a/testsuite/synth/gen01/pkg04.vhdl b/testsuite/synth/gen01/pkg04.vhdl
new file mode 100644
index 000000000..ccca9056e
--- /dev/null
+++ b/testsuite/synth/gen01/pkg04.vhdl
@@ -0,0 +1,27 @@
+package gen is
+ generic (val : integer);
+
+ constant c : integer := val;
+
+ function get_val (x : integer := c) return integer;
+end;
+
+package body gen is
+ function get_val (x : integer := c) return integer is
+ begin
+ return x + val;
+ end get_val;
+end;
+
+package inst1 is new work.gen generic map (val => 5);
+
+entity pkg04 is
+ port (i : in integer;
+ o : out integer);
+end pkg04;
+
+architecture behav of pkg04 is
+ use work.inst1.all;
+begin
+ o <= i + get_val;
+end behav;
diff --git a/testsuite/synth/gen01/testsuite.sh b/testsuite/synth/gen01/testsuite.sh
index 16e9f52c9..3004f203e 100755
--- a/testsuite/synth/gen01/testsuite.sh
+++ b/testsuite/synth/gen01/testsuite.sh
@@ -6,5 +6,9 @@ GHDL_STD_FLAGS=--std=08
synth_only dly1
synth_only dly2
synth_only dly3
+synth_only pkg01
+synth_only pkg02
+synth_only pkg03
+synth_only pkg04
echo "Test successful"