-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab5_pong.vhd.bak
executable file
·106 lines (88 loc) · 3.72 KB
/
lab5_pong.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity lab5_pong is
port(CLOCK_50 : in std_logic;
KEY : in std_logic_vector(3 downto 0);
SW : in std_logic_vector(17 downto 0);
LEDR : out std_logic_vector(17 downto 0); -- for debugging
VGA_R, VGA_G, VGA_B : out std_logic_vector(9 downto 0); -- The outs go to VGA controller
VGA_HS : out std_logic;
VGA_VS : out std_logic;
VGA_BLANK : out std_logic;
VGA_SYNC : out std_logic;
VGA_CLK : out std_logic
);
end lab5_pong;
architecture rtl of lab5_pong is
--Component from the Verilog file: vga_adapter.v
component vga_adapter
generic(RESOLUTION : string);
port (resetn : in std_logic;
clock : in std_logic;
colour : in std_logic_vector(2 downto 0);
x : in std_logic_vector(7 downto 0);
y : in std_logic_vector(6 downto 0);
plot : in std_logic;
VGA_R, VGA_G, VGA_B : out std_logic_vector(9 downto 0);
VGA_HS, VGA_VS, VGA_BLANK, VGA_SYNC, VGA_CLK : out std_logic);
end component;
component fsm is
port( clock: in std_logic;
nextStep: in std_logic;
reset: in std_logic;
done : in std_logic;
x0: out std_logic_vector( 7 downto 0);
y0: out std_logic_vector( 6 downto 0);
mode: out std_logic_vector(1 downto 0) -- 0 = erase, 1 = idle, 2 = drawLine
);
end component;
component DataPath IS
PORT(
clock : IN STD_LOGIC;
-- reset : IN std_logic;
mode : IN std_logic_vector(1 downto 0);
done : out std_logic;
x0 : in std_logic_vector(7 downto 0);
y0 : in std_logic_vector(6 downto 0);
x1 : in std_logic_vector(7 downto 0);
y1 : in std_logic_vector(6 downto 0);
colour : out std_logic_vector(2 downto 0);
colour_sw: in std_logic_vector(2 downto 0);
x : out std_logic_vector(7 downto 0);
y : out std_logic_vector(6 downto 0);
plot : out std_logic
);
END component;
signal x : std_logic_vector(7 downto 0);
signal y : std_logic_vector(6 downto 0);
signal x0 : std_logic_vector(7 downto 0);
signal y0 : std_logic_vector(6 downto 0);
signal mode : std_logic_vector(1 downto 0);
signal colour : std_logic_vector(2 downto 0);
signal plot : std_logic;
signal done : std_logic;
begin
-- includes the vga adapter, which should be in your project
vga_u0 : vga_adapter
generic map(RESOLUTION => "160x120")
port map(resetn => KEY(3),
clock => CLOCK_50,
colour => colour,
x => x,
y => y,
plot => plot,
VGA_R => VGA_R,
VGA_G => VGA_G,
VGA_B => VGA_B,
VGA_HS => VGA_HS,
VGA_VS => VGA_VS,
VGA_BLANK => VGA_BLANK,
VGA_SYNC => VGA_SYNC,
VGA_CLK => VGA_CLK);
U0: fsm
port map( clock => CLOCK_50, nextStep => KEY(0), reset => KEY(3), x0 => x0, y0 => y0, done => done, mode => mode);
U1: dataPath
port map(clock => CLOCK_50, mode => mode, done => done, x0 => x0, y0 => y0, x1 => SW(17 downto 10),
y1 => SW(9 downto 3), colour => colour, colour_sw => SW(2 downto 0), x => x, y => y, plot => plot);
end RTL;