aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/synth/issue2072/swaptest.vhdl
blob: 11ea763682997d0dc78943c04684e0bba40006c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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;