aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-10-06 17:44:25 +0200
committerTristan Gingold <tgingold@free.fr>2019-10-06 17:53:24 +0200
commitbe9cdfbbe25b64ee587ba3316898fcc988830c0a (patch)
tree8d0dbb580abb0dda2d9ec260bcf3bdf5b715785b /testsuite
parent74348ad90435e6a28a86c4050d17a989f5434e9d (diff)
downloadghdl-be9cdfbbe25b64ee587ba3316898fcc988830c0a.tar.gz
ghdl-be9cdfbbe25b64ee587ba3316898fcc988830c0a.tar.bz2
ghdl-be9cdfbbe25b64ee587ba3316898fcc988830c0a.zip
testsuite/synth: add a test for previous commit.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/synth/comp02/cmask.vhdl14
-rw-r--r--testsuite/synth/comp02/mixer.vhdl17
-rw-r--r--testsuite/synth/comp02/pkg.vhdl11
-rw-r--r--testsuite/synth/comp02/tb_mixer.vhdl32
-rwxr-xr-xtestsuite/synth/comp02/testsuite.sh15
5 files changed, 89 insertions, 0 deletions
diff --git a/testsuite/synth/comp02/cmask.vhdl b/testsuite/synth/comp02/cmask.vhdl
new file mode 100644
index 000000000..9b1f2438c
--- /dev/null
+++ b/testsuite/synth/comp02/cmask.vhdl
@@ -0,0 +1,14 @@
+library ieee;
+use ieee.std_logic_1164.all;
+
+entity cmask is
+ generic
+ (mask : std_logic_vector (0 to 7));
+ port (d : std_logic_vector (7 downto 0);
+ o : out std_logic_vector (7 downto 0));
+end cmask;
+
+architecture behav of cmask is
+begin
+ o <= d and mask;
+end behav;
diff --git a/testsuite/synth/comp02/mixer.vhdl b/testsuite/synth/comp02/mixer.vhdl
new file mode 100644
index 000000000..589f19980
--- /dev/null
+++ b/testsuite/synth/comp02/mixer.vhdl
@@ -0,0 +1,17 @@
+library ieee;
+use ieee.std_logic_1164.all;
+
+entity mixer is
+ port (h, l : std_logic_vector(7 downto 0);
+ o : out std_logic_vector (7 downto 0));
+end mixer;
+
+use work.pkg.all;
+architecture behav of mixer is
+ signal t1 : std_logic_vector (7 downto 0);
+begin
+ a1: cmask
+ generic map (mask => x"0f")
+ port map (l, t1);
+ o <= t1 or h;
+end behav;
diff --git a/testsuite/synth/comp02/pkg.vhdl b/testsuite/synth/comp02/pkg.vhdl
new file mode 100644
index 000000000..8d834a280
--- /dev/null
+++ b/testsuite/synth/comp02/pkg.vhdl
@@ -0,0 +1,11 @@
+library ieee;
+use ieee.std_logic_1164.all;
+
+package pkg is
+ component cmask is
+ generic
+ (mask : std_logic_vector (0 to 7));
+ port (d : std_logic_vector (7 downto 0);
+ o : out std_logic_vector (7 downto 0));
+ end component;
+end pkg;
diff --git a/testsuite/synth/comp02/tb_mixer.vhdl b/testsuite/synth/comp02/tb_mixer.vhdl
new file mode 100644
index 000000000..4085ba9a9
--- /dev/null
+++ b/testsuite/synth/comp02/tb_mixer.vhdl
@@ -0,0 +1,32 @@
+library ieee;
+use ieee.std_logic_1164.all;
+
+entity tb_mixer is
+end tb_mixer;
+
+architecture behav of tb_mixer is
+ signal h, l, o : std_logic_vector (7 downto 0);
+begin
+ dut : entity work.mixer
+ port map (h => h, l => l, o => o);
+
+ process
+ begin
+ h <= x"00";
+ l <= x"ab";
+ wait for 1 ns;
+ assert o = x"0b" severity failure;
+
+ h <= x"50";
+ l <= x"a6";
+ wait for 1 ns;
+ assert o = x"56" severity failure;
+
+ h <= x"a3";
+ l <= x"5c";
+ wait for 1 ns;
+ assert o = x"af" severity failure;
+
+ wait;
+ end process;
+end behav;
diff --git a/testsuite/synth/comp02/testsuite.sh b/testsuite/synth/comp02/testsuite.sh
new file mode 100755
index 000000000..73ee22454
--- /dev/null
+++ b/testsuite/synth/comp02/testsuite.sh
@@ -0,0 +1,15 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+# Direct instance
+analyze pkg.vhdl cmask.vhdl mixer.vhdl tb_mixer.vhdl
+elab_simulate tb_mixer
+clean
+
+synth pkg.vhdl cmask.vhdl mixer.vhdl -e mixer > syn_mixer.vhdl
+analyze syn_mixer.vhdl tb_mixer.vhdl
+elab_simulate tb_mixer
+clean
+
+echo "Test successful"