diff options
-rw-r--r-- | testsuite/synth/issue2072/swaptest.vhdl | 34 | ||||
-rw-r--r-- | testsuite/synth/issue2072/tb_swaptest.vhdl | 37 | ||||
-rwxr-xr-x | testsuite/synth/issue2072/testsuite.sh | 9 |
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" |