aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/synth
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2022-06-04 16:37:23 +0200
committerTristan Gingold <tgingold@free.fr>2022-06-04 18:55:57 +0200
commit89afd0cc5a3b36f185c62c9f183066133631910e (patch)
tree1828a8e2d3285a8ed7dfc4b677c7dd0f9692f1de /testsuite/synth
parent467f6d66017b73496cef8b5212385c3b407a722f (diff)
downloadghdl-89afd0cc5a3b36f185c62c9f183066133631910e.tar.gz
ghdl-89afd0cc5a3b36f185c62c9f183066133631910e.tar.bz2
ghdl-89afd0cc5a3b36f185c62c9f183066133631910e.zip
testsuite/synth: add a test for #2072
Diffstat (limited to 'testsuite/synth')
-rw-r--r--testsuite/synth/issue2072/swaptest.vhdl34
-rw-r--r--testsuite/synth/issue2072/tb_swaptest.vhdl37
-rwxr-xr-xtestsuite/synth/issue2072/testsuite.sh9
3 files changed, 80 insertions, 0 deletions
diff --git a/testsuite/synth/issue2072/swaptest.vhdl b/testsuite/synth/issue2072/swaptest.vhdl
new file mode 100644
index 000000000..11ea76368
--- /dev/null
+++ b/testsuite/synth/issue2072/swaptest.vhdl
@@ -0,0 +1,34 @@
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+entity swaptest is
+port (
+ clk : in std_logic;
+ d : in unsigned(7 downto 0);
+ q : out unsigned(7 downto 0)
+);
+end entity;
+
+architecture rtl of swaptest is
+
+FUNCTION bswap(v : unsigned) RETURN unsigned IS
+ VARIABLE u: unsigned(0 TO v'length-1) :=v;
+ VARIABLE x: unsigned(0 TO v'length-1);
+BEGIN
+ FOR i IN 0 TO v'length-1 LOOP
+ x((v'length-1)-i):=u(i);
+ END LOOP;
+ return x;
+END FUNCTION;
+
+begin
+
+ process(clk) begin
+ if rising_edge(clk) then
+ q(7 downto 1) <= bswap(d(7 downto 1));
+ end if;
+ end process;
+
+end architecture;
+
diff --git a/testsuite/synth/issue2072/tb_swaptest.vhdl b/testsuite/synth/issue2072/tb_swaptest.vhdl
new file mode 100644
index 000000000..194f3c9d0
--- /dev/null
+++ b/testsuite/synth/issue2072/tb_swaptest.vhdl
@@ -0,0 +1,37 @@
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+library std;
+use std.textio.all;
+
+entity tb_swaptest is
+end tb_swaptest;
+
+architecture behaviour of tb_swaptest
+is
+ constant clk_period : time := 10 ns;
+ signal clk : std_logic;
+ signal d : unsigned(7 downto 0) := X"c5";
+ signal q : unsigned(7 downto 0);
+begin
+
+ clk_process: process
+ begin
+ for i in 1 to 10 loop
+ clk <= '0';
+ wait for clk_period/2;
+ clk <= '1';
+ wait for clk_period/2;
+ end loop;
+ wait;
+ end process;
+
+ st : entity work.swaptest
+ port map (
+ clk => clk,
+ d => d,
+ q => q
+ );
+
+end architecture;
diff --git a/testsuite/synth/issue2072/testsuite.sh b/testsuite/synth/issue2072/testsuite.sh
new file mode 100755
index 000000000..755f1f4ec
--- /dev/null
+++ b/testsuite/synth/issue2072/testsuite.sh
@@ -0,0 +1,9 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+for t in swaptest; do
+ synth_tb $t
+done
+
+echo "Test successful"