-
Notifications
You must be signed in to change notification settings - Fork 0
/
cordic.vhd
94 lines (76 loc) · 2.19 KB
/
cordic.vhd
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
entity cordic is
generic(
N : natural := 16; --Ancho de la palabra
ITER : natural := 12);--Numero de iteraciones
port(
clk : in std_logic;
rst : in std_logic;
en_i : in std_logic;
x_i : in std_logic_vector(N-1 downto 0);
y_i : in std_logic_vector(N-1 downto 0);
z_i : in std_logic_vector(N-1 downto 0);
dv_o : out std_logic;
x_o : out std_logic_vector(N-1 downto 0);
y_o : out std_logic_vector(N-1 downto 0);
z_o : out std_logic_vector(N-1 downto 0)
);
end entity;
architecture structural of cordic is
component cordic_core is
generic (
SIZE :positive;
ITERATIONS :positive
);
port (
Clock : in std_ulogic;
Reset : in std_ulogic;
Data_valid : in std_ulogic; --# Load new input data
Busy : out std_ulogic; --# Generating new result
Result_valid : out std_ulogic; --# Flag when result is valid
X : in signed(SIZE-1 downto 0);
Y : in signed(SIZE-1 downto 0);
Z : in signed(SIZE-1 downto 0);
X_result : out signed(SIZE-1 downto 0);
Y_result : out signed(SIZE-1 downto 0);
Z_result : out signed(SIZE-1 downto 0)
);
end component;
signal en_ii : std_ulogic := '0';
signal is_busy : std_ulogic;
signal xt_o : signed(N-1 downto 0);
signal yt_o : signed(N-1 downto 0);
signal zt_o : signed(N-1 downto 0);
begin
enable : process(clk, en_i, is_busy) is
begin
if en_i = '1' and is_busy = '0' then
en_ii <= '1';
elsif is_busy = '1' then
en_ii <= '0';
end if;
end process;
CORD : cordic_core
generic map (
SIZE => N,
ITERATIONS => ITER
)
port map (
Clock => clk,
Reset => rst,
Data_valid => en_ii,
Busy => is_busy,
Result_valid => dv_o,
X => signed(x_i),
Y => signed(y_i),
Z => signed(z_i),
X_result => xt_o,
Y_result => yt_o,
Z_result => zt_o
);
x_o <= std_logic_vector(xt_o);
y_o <= std_logic_vector(yt_o);
z_o <= std_logic_vector(zt_o);
end architecture;