OpenCores
URL https://opencores.org/ocsvn/t6507lp/t6507lp/trunk

Subversion Repositories t6507lp

[/] [t6507lp/] [trunk/] [rtl/] [verilog/] [vga_controller.v] - Blame information for rev 224

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 221 creep
////////////////////////////////////////////////////////////////////////////
2
////                                                                    ////
3
//// t2600 IP Core                                                      ////
4
////                                                                    ////
5
//// This file is part of the t2600 project                             ////
6
//// http://www.opencores.org/cores/t2600/                              ////
7
////                                                                    ////
8
//// Description                                                        ////
9
//// VGA controller                                                     ////
10
////                                                                    ////
11
//// TODO:                                                              ////
12
//// - Feed the controller with data                                    ////
13
////                                                                    ////
14
//// Author(s):                                                         ////
15
//// - Gabriel Oshiro Zardo, gabrieloshiro@gmail.com                    ////
16
//// - Samuel Nascimento Pagliarini (creep), snpagliarini@gmail.com     ////
17
////                                                                    ////
18
////////////////////////////////////////////////////////////////////////////
19
////                                                                    ////
20
//// Copyright (C) 2001 Authors and OPENCORES.ORG                       ////
21
////                                                                    ////
22
//// This source file may be used and distributed without               ////
23
//// restriction provided that this copyright statement is not          ////
24
//// removed from the file and that any derivative work contains        ////
25
//// the original copyright notice and the associated disclaimer.       ////
26
////                                                                    ////
27
//// This source file is free software; you can redistribute it         ////
28
//// and/or modify it under the terms of the GNU Lesser General         ////
29
//// Public License as published by the Free Software Foundation;       ////
30
//// either version 2.1 of the License, or (at your option) any         ////
31
//// later version.                                                     ////
32
////                                                                    ////
33
//// This source is distributed in the hope that it will be             ////
34
//// useful, but WITHOUT ANY WARRANTY; without even the implied         ////
35
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR            ////
36
//// PURPOSE. See the GNU Lesser General Public License for more        ////
37
//// details.                                                           ////
38
////                                                                    ////
39
//// You should have received a copy of the GNU Lesser General          ////
40
//// Public License along with this source; if not, download it         ////
41
//// from http://www.opencores.org/lgpl.shtml                           ////
42
////                                                                    ////
43
////////////////////////////////////////////////////////////////////////////
44
 
45
`include "timescale.v"
46
 
47 224 creep
module vga_controller ( reset, clk_50, line, SW, VGA_R, VGA_G, VGA_B, LEDR, VGA_VS, VGA_HS);
48 221 creep
 
49 223 gabrielosh
input reset;
50
input clk_50;
51 224 creep
input [8:0] SW;
52
input [479:0] line;
53 223 gabrielosh
output reg [3:0] VGA_R;
54
output reg [3:0] VGA_G;
55
output reg [3:0] VGA_B;
56
output [9:0] LEDR;
57
output reg VGA_VS;
58
output reg VGA_HS;
59 222 creep
 
60
 
61 221 creep
reg clk_25;
62
reg [9:0] hc;
63
reg [9:0] vc;
64
reg vsenable;
65
wire vidon;
66
 
67
assign LEDR = SW;
68
 
69
always @ (posedge clk_50 or negedge reset)
70
begin
71
        if (!reset) begin
72
                clk_25 <= 0;
73
        end
74
        else begin
75
                clk_25 <= !clk_25;
76
        end
77
end
78
 
79
always @ (posedge clk_25 or negedge reset)
80
begin
81
        if (!reset) begin
82
                hc <= 0;
83
                VGA_HS <= 1;
84
                vsenable <= 0;
85
        end
86
        else if (hc < 640) begin
87
                hc <= hc + 1;
88
                vsenable <= 0;
89
                VGA_HS <= 1;
90
        end
91
        else if (hc < 640 + 16) begin
92
                VGA_HS <= 1;
93
                hc <= hc + 1;
94
                vsenable <= 0;
95
        end
96
        else if (hc < 640 + 16 + 96) begin
97
                VGA_HS <= 0;
98
                hc <= hc + 1;
99
                vsenable <= 0;
100
        end
101
        else if (hc < 640 + 16 + 96 + 48) begin
102
                VGA_HS <= 1;
103
                hc <= hc + 1;
104
                vsenable <= 0;
105
        end
106
        else begin
107
                VGA_HS <= 1;
108
                hc <= 0;
109
                vsenable <= 1;
110
        end
111
end
112
 
113
always @ (posedge clk_25 or negedge reset)
114
begin
115
        if (!reset) begin
116
                vc <= 0;
117
                VGA_VS <= 1;
118
        end
119
        else begin
120
                if (vsenable == 1) begin
121
                        vc <= vc + 1;
122
                end
123
                if (vc < 480) begin
124
                        VGA_VS <= 1;
125
                end
126
                else if (vc < 480 + 11) begin
127
                        VGA_VS <= 1;
128
                end
129
                else if (vc < 480 + 11 + 2) begin
130
                        VGA_VS <= 0;
131
                end
132
                else if (vc < 480 + 11 + 2 + 31) begin
133
                        VGA_VS <= 1;
134
                end
135
                else begin
136
                        vc <= 0;
137
                        VGA_VS <= 1;
138
                end
139
        end
140
end
141
 
142
always @ (posedge clk_25)
143
begin
144
        if (vidon == 1) begin
145
                if (hc < 320) begin
146
                        if (vc < 240) begin
147
                                VGA_R[0] <= 1;
148
                                VGA_G[0] <= 1;
149
                                VGA_B[0] <= 1;
150
                                VGA_R[1] <= 1;
151
                                VGA_G[1] <= 1;
152
                                VGA_B[1] <= 1;
153
                                VGA_R[2] <= 1;
154
                                VGA_G[2] <= 1;
155
                                VGA_B[2] <= 1;
156
                                VGA_R[3] <= 1;
157
                                VGA_G[3] <= 1;
158
                                VGA_B[3] <= 1;
159
                        end
160
                        else begin
161
                                VGA_R[0] <= 0;
162
                                VGA_G[0] <= 0;
163
                                VGA_B[0] <= 1;
164
                                VGA_R[1] <= 0;
165
                                VGA_G[1] <= 0;
166
                                VGA_B[1] <= 1;
167
                                VGA_R[2] <= 0;
168
                                VGA_G[2] <= 0;
169
                                VGA_B[2] <= 1;
170
                                VGA_R[3] <= 0;
171
                                VGA_G[3] <= 0;
172
                                VGA_B[3] <= 1;
173
                        end
174
                end
175
                else begin
176
                        if (vc < 240) begin
177
                                VGA_R[0] <= 1;
178
                                VGA_G[0] <= 0;
179
                                VGA_B[0] <= 0;
180
                                VGA_R[1] <= 1;
181
                                VGA_G[1] <= 0;
182
                                VGA_B[1] <= 0;
183
                                VGA_R[2] <= 1;
184
                                VGA_G[2] <= 0;
185
                                VGA_B[2] <= 0;
186
                                VGA_R[3] <= 1;
187
                                VGA_G[3] <= 0;
188
                                VGA_B[3] <= 0;
189
                        end
190
                        else begin
191
                                VGA_R[0] <= 0;
192
                                VGA_G[0] <= 1;
193
                                VGA_B[0] <= 0;
194
                                VGA_R[1] <= 0;
195
                                VGA_G[1] <= 1;
196
                                VGA_B[1] <= 0;
197
                                VGA_R[2] <= 0;
198
                                VGA_G[2] <= 1;
199
                                VGA_B[2] <= 0;
200
                                VGA_R[3] <= 0;
201
                                VGA_G[3] <= 1;
202
                                VGA_B[3] <= 0;
203
                        end
204
                end
205
        end
206
        else begin
207
                VGA_R[0] <= 0;
208
                VGA_G[0] <= 0;
209
                VGA_B[0] <= 0;
210
                VGA_R[1] <= 0;
211
                VGA_G[1] <= 0;
212
                VGA_B[1] <= 0;
213
                VGA_R[2] <= 0;
214
                VGA_G[2] <= 0;
215
                VGA_B[2] <= 0;
216
                VGA_R[3] <= 0;
217
                VGA_G[3] <= 0;
218
                VGA_B[3] <= 0;
219
        end
220
end
221
 
222
assign vidon = (hc < 640 && vc < 480) ? 1 : 0;
223
 
224
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.