-
Notifications
You must be signed in to change notification settings - Fork 2
/
vgaram.v
99 lines (72 loc) · 1.84 KB
/
vgaram.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
module vgaram(
input clk50_in,
output reg hs_out,
output reg vs_out,
output wire [2:0] red_out,
output wire [1:0] green_out,
output wire [2:0] blue_out
);
reg clk25;
reg [9:0] horizontal_counter;
reg [9:0] vertical_counter;
reg [9:0] X;
reg [9:0] Y;
wire [7:0] red;
wire [7:0] green;
wire [7:0] blue;
assign red_out[2:0] = ((horizontal_counter >= 144)
&& (horizontal_counter < 784)
&& (vertical_counter >=39)
&& (vertical_counter < 519)) ? red[7:5] : 3'b000;
assign green_out[1:0] = ((horizontal_counter >= 144)
&& (horizontal_counter < 784)
&& (vertical_counter >=39)
&& (vertical_counter < 519)) ? green[7:6] : 2'b00;
assign blue_out[2:0] = ((horizontal_counter >= 144)
&& (horizontal_counter < 784)
&& (vertical_counter >=39)
&& (vertical_counter < 519)) ? blue[7:5] : 3'b000;
assign red = ((horizontal_counter >= 144)&&(horizontal_counter < 344) ) ? 8'b11100000 : 8'b00000000;
assign green = ((horizontal_counter >= 344)&&(horizontal_counter < 544) ) ? 8'b11000000 : 8'b00000000;
assign blue = ((horizontal_counter >= 544)&&(horizontal_counter < 784) ) ? 8'b11100000 : 8'b00000000;
always @(posedge clk50_in)
begin
if (clk25 == 0)
begin
clk25 <= 1;
end
else
begin
clk25 <= 0;
end
end
always @(posedge clk25)
begin
if ((horizontal_counter > 0) && (horizontal_counter < 97))// -- 96+1
begin
hs_out <= 0;
end
else
begin
hs_out <= 1;
end
if ((vertical_counter > 0 ) && (vertical_counter < 3 )) //-- 2+1
begin
vs_out <= 0;
end
else
begin
vs_out <= 1;
end
horizontal_counter <= horizontal_counter+1;
if (horizontal_counter == 800)
begin
vertical_counter <= vertical_counter+1;
horizontal_counter <= 0;
end
if (vertical_counter == 521)
begin
vertical_counter <= 0;
end
end
endmodule