-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcontroller.vhd.bak
76 lines (64 loc) · 1.66 KB
/
controller.vhd.bak
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
library ieee;
use ieee.numeric_std.all;
use ieee.std_logic_1164.all;
use work.tetris_package.all;
entity controller is
port
(
CLOCK : in std_logic;
RESET_N : in std_logic;
TIME_10MS : in std_logic;
CHANGE_SQUARE_BUTTON : in std_logic;
CHANGE_COLOR_BUTTON : in std_logic;
CONFIRM_GUESS_BUTTON : in std_logic;
-- Connections with Datapath
CLEAR : out std_logic;
CHANGE_SQUARE : out std_logic;
CHANGE_COLOR : out std_logic;
CONFIRM_GUESS : out std_logic;
-- Connections with View
REDRAW : out std_logic
);
end entity;
architecture RTL of controller is
signal button_time : std_logic;
begin
CLEAR <= '0';
button_time : process(CLOCK, RESET_N)
begin
if (RESET_N = '0') then
button_time <= '0';
elsif rising_edge(CLOCK) then
button_time <= '0';
if (TIME_10MS = '1') then
button_time <= '1'
end if;
end if;
end process;
controller_RTL : process (CLOCK, RESET_N)
begin
if (RESET_N = '0') then
CHANGE_SQUARE <= '0';
CHANGE_COLOR <= '0';
CONFIRM_GUESS <= '0';
REDRAW <= '0';
elsif rising_edge(CLOCK) then
CHANGE_SQUARE <= '0';
CHANGE_COLOR <= '0';
CONFIRM_GUESS <= '0';
REDRAW <= '0';
if (button_time = '1') then
if (CHANGE_SQUARE_BUTTON = '1') then
CHANGE_SQUARE <= '1';
REDRAW <= '1';
elsif (CHANGE_COLOR_BUTTON = '1') then
CHANGE_COLOR <= '1';
REDRAW <= '1';
elsif (CONFIRM_GUESS_BUTTON = '1') then
CONFIRM_GUESS <= '1';
REDRAW <= '1';
end if;
end if;
end if;
end process;
end architecture;