-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab5_datapath.vhd
executable file
·188 lines (155 loc) · 6.46 KB
/
lab5_datapath.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity lab5_datapath is
PORT(
clock : IN STD_LOGIC;
reset : IN std_logic;
p1_goalie_sw : in std_logic;
p1_forward_sw: in std_logic;
p2_goalie_sw : in std_logic;
p2_forward_sw: in std_logic;
colour : out 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;
score_p1: out std_logic;
score_p2: out std_logic;
reset_connect: in std_logic;
idle_connect: in std_logic
);
END lab5_datapath;
ARCHITECTURE Behavioural of lab5_datapath is
component changeSpeed is
port( clk : in std_logic;
reset_connect : in std_logic;
idle_connect :in std_logic;
slowclock : out std_logic
);
end component;
component player_move is
port(
clk : in std_logic; -- A 50MHz clock
slowclock : in std_logic;
player_sw : in std_logic;
player_y : out std_logic_vector(6 downto 0);
player_boundary : in std_logic_vector(1 downto 0);
reset_connect: in std_logic;
idle_connect: in std_logic
);
end component;
component puck_move is
port(
clk : in std_logic; -- A 50MHz clock
slowclock : in std_logic;
puck_x_coord : out std_logic_vector(7 downto 0);
puck_y_coord : out std_logic_vector(6 downto 0);
puck_x_direction : out unsigned(0 downto 0);
puck_boundary : in std_logic;
puck_player : in std_logic;
reset_connect: in std_logic;
idle_connect: in std_logic
);
end component;
component collision_detect is
port(
clk : in std_logic; -- A 50MHz clock
p1_goalie_y : in std_logic_vector(6 downto 0);
p1_forward_y : in std_logic_vector(6 downto 0);
p2_goalie_y : in std_logic_vector(6 downto 0);
p2_forward_y : in std_logic_vector(6 downto 0);
puck_x_coord : in std_logic_vector(7 downto 0);
puck_y_coord : in std_logic_vector(6 downto 0);
p1_goalie_sw : in std_logic;
p1_forward_sw: in std_logic;
p2_goalie_sw : in std_logic;
p2_forward_sw: in std_logic;
p1_goalie_boundary : out std_logic_vector(1 downto 0); -- "00" for no bound, "10" for upper, "01" for lower
p1_forward_boundary : out std_logic_vector(1 downto 0);
p2_goalie_boundary : out std_logic_vector(1 downto 0);
p2_forward_boundary : out std_logic_vector(1 downto 0);
puck_boundary: out std_logic;
puck_player: out std_logic;
puck_x_direction: in unsigned(0 downto 0);
score_p1: out std_logic;
score_p2: out std_logic
);
end component;
component DrawScreen is
port( clk : in std_logic;
p1_goalie_y : in std_logic_vector(6 downto 0);
p1_forward_y : in std_logic_vector(6 downto 0);
p2_goalie_y : in std_logic_vector(6 downto 0);
p2_forward_y : in std_logic_vector(6 downto 0);
puck_y_coord : in std_logic_vector(6 downto 0);
puck_x_coord : in std_logic_vector(7 downto 0);
x : out std_logic_vector(7 downto 0);
y : out std_logic_vector(6 downto 0);
colour : out std_logic_vector(2 downto 0);
plot : out std_logic
);
end component;
signal slowclock : std_logic;
signal p1_goalie_y : std_logic_vector(6 downto 0);
signal p1_forward_y : std_logic_vector(6 downto 0);
signal p2_goalie_y : std_logic_vector(6 downto 0);
signal p2_forward_y : std_logic_vector(6 downto 0);
signal puck_x_coord : std_logic_vector(7 downto 0);
signal puck_y_coord : std_logic_vector(6 downto 0);
signal puck_boundary : std_logic;
signal puck_player : std_logic;
signal p1_goalie_boundary : std_logic_vector(1 downto 0);
signal p1_forward_boundary : std_logic_vector(1 downto 0);
signal p2_goalie_boundary : std_logic_vector(1 downto 0);
signal p2_forward_boundary : std_logic_vector(1 downto 0);
signal pixelColour : std_logic_vector(2 downto 0);
signal x_connect : std_logic_vector(7 downto 0);
signal y_connect : std_logic_vector(6 downto 0);
signal puck_x_direction: unsigned(0 downto 0);
begin
DiffClock: changeSpeed
port map (clk => clock, slowclock => slowclock, reset_connect => reset_connect, idle_connect => idle_connect);
Pl_goalie: player_move
port map(clk => clock, slowclock => slowclock, player_sw => p1_goalie_sw,
player_y => p1_goalie_y, player_boundary => p1_goalie_boundary,
reset_connect => reset_connect, idle_connect => idle_connect
);
P1_forward: player_move
port map(clk => clock, slowclock => slowclock, player_sw => p1_forward_sw,
player_y => p1_forward_y, player_boundary => p1_forward_boundary,
reset_connect => reset_connect, idle_connect => idle_connect
);
P2_goalie: player_move
port map(clk => clock, slowclock => slowclock, player_sw => p2_goalie_sw,
player_y => p2_goalie_y, player_boundary => p2_goalie_boundary,
reset_connect => reset_connect, idle_connect => idle_connect
);
P2_forward: player_move
port map(clk => clock, slowclock => slowclock, player_sw => p2_forward_sw,
player_y => p2_forward_y, player_boundary => p2_forward_boundary,
reset_connect => reset_connect, idle_connect => idle_connect
);
Puck_Movement: puck_move
port map(clk => clock, slowclock => slowclock, puck_x_coord => puck_x_coord,
puck_y_coord => puck_y_coord, puck_boundary => puck_boundary, puck_player => puck_player,
reset_connect => reset_connect, idle_connect => idle_connect, puck_x_direction => puck_x_direction
);
Collision: collision_detect
port map(clk => clock,
p1_goalie_y => p1_goalie_y, p1_goalie_boundary => p1_goalie_boundary,
p1_forward_y => p1_forward_y, p1_forward_boundary => p1_forward_boundary,
p2_goalie_y => p2_goalie_y, p2_goalie_boundary => p2_goalie_boundary,
p2_forward_y => p2_forward_y, p2_forward_boundary => p2_forward_boundary,
puck_x_coord => puck_x_coord, puck_y_coord => puck_y_coord, puck_boundary => puck_boundary,
puck_player => puck_player, score_p1 => score_p1, score_p2 => score_p2,
p1_goalie_sw => p1_goalie_sw, p1_forward_sw => p1_forward_sw,
p2_goalie_sw => p2_goalie_sw, p2_forward_sw => p2_forward_sw,
puck_x_direction => puck_x_direction
);
screen: DrawScreen
port map( clk => clock, x => x, y => y, Colour=> Colour, plot => plot,
p1_goalie_y => p1_goalie_y, p1_forward_y => p1_forward_y,
p2_goalie_y => p2_goalie_y, p2_forward_y => p2_forward_y,
puck_x_coord => puck_x_coord, puck_y_coord => puck_y_coord
);
end Behavioural;