-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocessor_tb.vhd
More file actions
70 lines (61 loc) · 2 KB
/
processor_tb.vhd
File metadata and controls
70 lines (61 loc) · 2 KB
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
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity processor_tb is
end entity;
-- Lucas Yukio Fukuda Matsumoto - Matrícula 2516977
-- Laboratório uProcessador 5
-- Testbench do processador
architecture a_processor_tb of processor_tb is
constant period_time : time := 100 ns; -- Período para o clock
signal clk, rst : std_logic := '0'; -- Sinais de clock e reset
signal finished : std_logic := '0'; -- Sinal de terminou
signal exception : std_logic := '0'; -- Flag de erro
signal number : unsigned(15 downto 0) := (others => '0'); -- Saída do número
begin
processor_inst : entity work.processor -- Instância do processador
port map(
clk => clk, -- Clock
rst => rst, -- Reset
exception => exception, -- Flag de erro
result => number -- Saída do número
);
-- Reset dos registradores para iniciar
reset_global: process
begin
rst <= '1';
wait for period_time * 3; -- Espera 3 clocks, para resetar o estado da máquina de estados
rst <= '0';
wait;
end process;
sim_time_proc: process
begin
-- for i in 0 to 9999 loop
-- wait for 100 ns;
-- if exception = '1' then
-- finished <= '1';
-- wait for period_time * 3;
-- exit;
-- end if;
-- end loop;
wait for 500 us;
finished <= '1';
wait;
end process sim_time_proc;
-- Simula um clock com período period_time até que o tempo da simulação, sim_time_proc, se esgote
clk_proc: process
begin
while (exception /= '1' and finished /= '1') loop
clk <= '0';
wait for period_time / 2;
clk <= '1';
wait for period_time / 2;
end loop;
wait;
end process clk_proc;
-- Casos de teste
process
begin
wait; -- Para terminar a simulação
end process;
end architecture;