-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtop.v
173 lines (141 loc) · 3.52 KB
/
top.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
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
`timescale 1ns / 1ps
module top(
input fire_mode1,
input gamelevel_top,
input ShootingModeSw,
input ates_tusu,
input clk_50MHz, // from DE1-SoC
input reset, // system reset
input ciguli,
input but1_top,
input but2_top,
output reg clk25,
output hsync, // VGA port on DE1-SoC
output vsync, // VGA port on DE1-SoC
output [7:0] red, // red to VGA port on DE1-SoC
output [7:0] green, // green to VGA port on DE1-SoC
output [7:0] blue, // blue to VGA port on DE1-SoC
output blank,
output sync,
output [3:0] ledverisi,
output [6:0]hex0_top,
output [6:0]hex1_top,
output [6:0]hex2_top,
output [6:0]hex3_top
);
wire w_video_on, w_p_tick;
wire [9:0] w_x, w_y;
reg [7:0] red_reg, green_reg, blue_reg;
wire [7:0] red_next, green_next, blue_next;
always @(posedge clk_50MHz) begin
clk25 <= ~clk25;
end
vga_controller vc(
.clk_50MHz(clk_50MHz),
.reset(reset),
.video_on(w_video_on),
.hsync(hsync),
.vsync(vsync),
.p_tick(w_p_tick),
.x(w_x),
.y(w_y)
);
wire w1;
wire w2;
wire w3;
wire w4;
wire [3:0] w5;
wire [3:0] w6;
assign ledverisi=w6;
wire w11;
wire w12;
wire w13;
wire w14;
wire fail_case_int;
wire [8:0] score_led;
lfsr lfsr_top(
.fire_mode_lfsr1(fire_mode1),
.swcontrolalt(w4),
.swcontrolsag(w2),
.swcontrolust(w3),
.swcontrolsol(w1),
.swcontrolsolust(w11),
.swcontrolsagust(w12),
.swcontrolsolalt(w13),
.swcontrolsagalt(w14),
.countcase(w5),
.tetik_tusu(ates_tusu),
.random_number(w6),
.clk(clk1hz),
.reset(reset),
.total_score(score_led),
.fail_case_input(fail_case_int)
);
wire clk1hz;
clock_divider cd(
.clk_in(clk_50MHz),
.reset(reset),
.clk_out(clk1hz),
);
pixel_generation_from_left pg(
.gamelevel(gamelevel_top),
.swsol(w1),
.swsag(w2),
.swust(w3),
.swalt(w4),
.ShootingModeIndicator(ShootingModeSw),
.score_counter(score_led),
.solust(w11),
.swsagalt(w14),
.swsagust(w12),
.swsolalt(w13),
.count(w5),
.clk(clk_50MHz),
.ciguli(ciguli),
.video_on(w_video_on),
.x(w_x),
.y(w_y),
.red(red_next),
.green(green_next),
.blue(blue_next),
.but1(but1_top),
.but2(but2_top),
.fail_case_out(fail_case_int)
);
seven_segment display (.number(score_led),
.hex0(hex0_top),
.hex1(hex1_top),
.hex2(hex2_top),
.hex3(hex3_top));
always @(posedge clk_50MHz)
if(w_p_tick) begin
red_reg <= red_next;
green_reg <= green_next;
blue_reg <= blue_next;
end
assign red = red_reg;
assign green = green_reg;
assign blue = blue_reg;
reg [9:0] a = 0; // horizontal counter
reg [9:0] b = 0; // vertical counter
always @(posedge clk25) begin
if (a < 799)
a <= a + 1;
else
a <= 0;
end
always @(posedge clk25) begin
if (a == 799) begin
if (b < 524)
b <= b + 1;
else
b <= 0;
end
end
wire k;
wire m;
assign k = (a >= 640 && a < 799) ? 1 : 0;
assign m = (b >= 480 && b < 525) ? 1 : 0;
assign blank = ~(k | m);
assign sync = 1'b0;
endmodule