-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cordic_tb.vhd
93 lines (80 loc) · 2.91 KB
/
Cordic_tb.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
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
entity Cordic_tb is
end entity;
architecture Behavioral of Cordic_tb is
constant N : natural := 16; --Ancho de la palabra
constant ITER : natural := 16;--Numero de iteraciones
signal clk : std_logic := '1';
signal rst : std_logic := '1';
signal en_i : std_logic := '0';
signal x_i : std_logic_vector(N-1 downto 0) := (others =>'0');
signal y_i : std_logic_vector(N-1 downto 0) := (others =>'0');
signal z_i : std_logic_vector(N-1 downto 0) := (others =>'0');
signal dv_o : std_logic;
signal x_o : std_logic_vector(N-1 downto 0);
signal y_o : std_logic_vector(N-1 downto 0);
signal z_o : std_logic_vector(N-1 downto 0);
constant clk_period : time := 20 ns;
begin
CLK_PROC: process
begin
clk <= '1';
wait for clk_period/2;
clk <= '0';
wait for clk_period/2;
end process;
RESET_PROC: process
begin
rst <= '1';
wait for clk_period * 5 + 1 ps;
rst <= '0';
wait;
end process;
STIM_PROC: process
begin
en_i <= '0';
wait for clk_period * 10 + 1 ps;
en_i <= '1'; -- Primer vector a procesar
x_i <= std_logic_vector(to_unsigned(0, N)); -- Poner el número a calcular.
y_i <= std_logic_vector(to_unsigned(1000, N)); -- Poner el número a calcular.
z_i <= std_logic_vector(to_unsigned(0, N)); -- Poner el número a calcular.
-- wait for clk_period; -- Segundo vector a procesar
-- x_i <= std_logic_vector(to_unsigned(1, N)); -- Poner el número a calcular.
-- y_i <= std_logic_vector(to_unsigned(0, N)); -- Poner el número a calcular.
-- z_i <= std_logic_vector(to_unsigned(30, N)); -- Poner el número a calcular.
-- wait for clk_period; -- Tercer vector a procesar
-- x_i <= std_logic_vector(to_unsigned(1, N)); -- Poner el número a calcular.
-- y_i <= std_logic_vector(to_unsigned(0, N)); -- Poner el número a calcular.
-- z_i <= std_logic_vector(to_unsigned(30, N)); -- Poner el número a calcular.
-- wait for clk_period; -- Cuarto vector a procesar
-- x_i <= std_logic_vector(to_unsigned(1, N)); -- Poner el número a calcular.
-- y_i <= std_logic_vector(to_unsigned(0, N)); -- Poner el número a calcular.
-- z_i <= std_logic_vector(to_unsigned(30, N)); -- Poner el número a calcular.
-- wait for clk_period; -- Quinto vector a procesar
-- x_i <= std_logic_vector(to_unsigned(1, N)); -- Poner el número a calcular.
-- y_i <= std_logic_vector(to_unsigned(0, N)); -- Poner el número a calcular.
-- z_i <= std_logic_vector(to_unsigned(30, N)); -- Poner el número a calcular.
wait;
end process;
UUT: entity work.cordic
generic map(
N => N,
ITER => ITER
)
port map(
clk => clk,
rst => rst,
en_i => en_i,
x_i => x_i,
y_i => y_i,
z_i => z_i,
dv_o => dv_o,
x_o => x_o,
y_o => y_o,
z_o => z_o
);
-- Se pueden agregar asserts para que la simulación termine si el resultado no
-- es el esperado.
end architecture;