aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/gna/issue1820/etapa.vhdl
blob: 82b0baaecb51e50f459887d600bd8369c2d57921 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;

entity etapa is
	generic (
		SIZE: natural := 16;
		STEP: natural := 1
	);
	port (
		vec: in std_logic;
		x_i: in std_logic_vector(SIZE-1 downto 0);
		y_i: in std_logic_vector(SIZE-1 downto 0);
		z_i: in std_logic_vector(SIZE-1 downto 0);
		atan_i: in std_logic_vector(SIZE-1 downto 0);
		x_o: out std_logic_vector(SIZE-1 downto 0);
		y_o: out std_logic_vector(SIZE-1 downto 0);
		z_o: out std_logic_vector(SIZE-1 downto 0)
	) ;
end entity ; -- etapa

architecture etapa_arq of etapa is

	signal d_i: std_logic;
	signal d_i_slv: std_logic_vector(SIZE-1 downto 0);
	signal d_i_n_slv: std_logic_vector(SIZE-1 downto 0);

	signal x_shifted: std_logic_vector(SIZE-1 downto 0);
	signal y_shifted: std_logic_vector(SIZE-1 downto 0);
	signal c_x_shifted: std_logic_vector(SIZE-1 downto 0);
	signal c_y_shifted: std_logic_vector(SIZE-1 downto 0);
	signal c_z_i: std_logic_vector(SIZE-1 downto 0);

begin

	d_i <= y_i(SIZE-1) when vec = '1' else z_i(SIZE-1);
	d_i_slv <= (SIZE-2 downto 0 => '0') & d_i;
	d_i_n_slv <= (SIZE-2 downto 0 => '0') & not(d_i);

	x_shifted <= std_logic_vector(shift_right(signed(x_i), STEP));
	y_shifted <= std_logic_vector(shift_right(signed(y_i), STEP));

	c_x_shifted <= x_shifted xor (0 to SIZE-1 => d_i);
	c_y_shifted <= y_shifted xor (0 to SIZE-1 => not(d_i));
	c_z_i <= atan_i xor (0 to SIZE-1 => not(d_i));

	x_o <= std_logic_vector(signed(x_i) + signed(c_y_shifted) + signed(d_i_n_slv));
	y_o <= std_logic_vector(signed(y_i) + signed(c_x_shifted) + signed(d_i_slv));
	z_o <= std_logic_vector(signed(z_i) + signed(c_z_i) + signed(d_i_n_slv));

end architecture ; -- etapa_arq