This repository has been archived by the owner on Nov 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnexys3.v
117 lines (110 loc) · 1.98 KB
/
nexys3.v
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
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 12:32:35 05/19/2015
// Design Name:
// Module Name: nexys3
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module nexys3(
input clk,
input btnU,
input btnL,
input btnD,
input btnR,
output Hsync,
output Vsync,
output reg [2:0] vgaRed,
output reg [2:0] vgaGreen,
output reg [1:0] vgaBlue
);
clock _clock (
.clk_in(clk),
.clk_out50(clk50),
.clk_outDB(clkdb)
);
// Assign buttons
wire left;
debouncer _dbLeft(
.dbfreq(clkdb),
.btn_in(btnL),
.btn_out(left)
);
wire right;
debouncer _dbRight(
.dbfreq(clkdb),
.btn_in(btnR),
.btn_out(right)
);
wire select;
debouncer _dbSelect(
.dbfreq(clkdb),
.btn_in(btnD),
.btn_out(select)
);
wire reset;
debouncer _dbReset(
.dbfreq(clkdb),
.btn_in(btnU),
.btn_out(reset)
);
// VGA controller
reg clr = 0;
wire Hs;
assign Hsync = ~Hs;
wire Vs;
assign Vsync = ~Vs;
wire [10:0] PixelX;
wire [10:0] PixelY;
wire vidon;
vga_800x600 _vga(
.clk(clk50),
.clr(clr),
.hsync(Hs),
.vsync(Vs),
.PixelX(PixelX),
.PixelY(PixelY),
.vidon(vidon)
);
// Initialize game logic
wire R;
wire G;
wire B;
connect4 _connect4(
.clk(clk50),
.PixelX(PixelX),
.PixelY(PixelY),
.left(left),
.right(right),
.select(select),
.reset(reset),
.R(R),
.G(G),
.B(B)
);
// Output pixel values
always @(clk50) begin
if (vidon) begin
vgaRed[2:0] = R;
vgaGreen[2:0] = G;
vgaBlue[1:0] = B;
end
else begin
vgaRed[2:0] = 3'b000;
vgaGreen[2:0] = 3'b000;
vgaBlue[1:0] = 2'b00;
end
end
endmodule