-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVGA_LOGIC.v
86 lines (81 loc) · 1.44 KB
/
VGA_LOGIC.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
`timescale 1ns / 1ps
module VGA_LOGIC(
input clk,
input [2:0]rgb_in,
output reg red_out,
output reg green_out,
output reg blue_out,
output reg hsync,
output reg vsync,
output [9:0]hor_count,
output [9:0]ver_count
);
reg [9:0]hcount;
reg [9:0]vcount;
reg [2:0]color;
assign hor_count = hcount;
assign ver_count = vcount;
always @(posedge clk)
begin
if(hcount == 799)
begin
hcount =0;
if(vcount ==524)
begin
vcount =0;
end else begin
vcount = vcount+1;
end
end else begin
hcount = hcount +1;
end
if(vcount >= 490 && vcount <492) begin
vsync =0;
end else begin
vsync =1;
end
if(hcount >=656 && hcount <752) begin
hsync =0;
end else begin
hsync =1;
end
if(hcount < 640 && vcount <480) begin
red_out =color[0];
green_out = color[1];
blue_out=color[2];
end else begin
red_out =1'b0;
green_out = 1'b0;
blue_out=1'b0;
end
if(hcount < 640 && vcount <480)
begin
/*//seting background
if(hcount < 80)
begin
color = 3'b000;
end else if(hcount < 160) begin
color = 3'b001;
end else if(hcount < 240) begin
color = 3'b010;
end else if(hcount < 320) begin
color = 3'b011;
end else if(hcount < 400) begin
color = 3'b100;
end else if(hcount < 480) begin
color = 3'b101;
end else if(hcount < 560) begin
color = 3'b110;
end else begin
color = 3'b111;
end*/
color = rgb_in;
end
end
initial
begin
hcount = 0;
vcount=0;
color = 3'b0;
end
endmodule