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

Subversion Repositories t6507lp

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

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 227 creep
module vga_controller ( reset_n, clk_50, line, vert_counter, SW, VGA_R, VGA_G, VGA_B, LEDR, VGA_VS, VGA_HS);
48 221 creep
 
49 227 creep
input reset_n;
50 223 gabrielosh
input clk_50;
51 224 creep
input [8:0] SW;
52 225 gabrielosh
input [479:0] line;
53
input [4:0] vert_counter;
54 223 gabrielosh
output reg [3:0] VGA_R;
55
output reg [3:0] VGA_G;
56
output reg [3:0] VGA_B;
57
output [9:0] LEDR;
58
output reg VGA_VS;
59
output reg VGA_HS;
60 222 creep
 
61 221 creep
reg clk_25;
62
reg [9:0] hc;
63
reg [9:0] vc;
64
reg vsenable;
65
wire vidon;
66
 
67 225 gabrielosh
assign LEDR[8:0] = SW;
68 227 creep
assign LEDR[9] = reset_n;
69 221 creep
 
70 227 creep
always @ (posedge clk_50 or negedge reset_n)
71 221 creep
begin
72 227 creep
        if (!reset_n) begin
73 221 creep
                clk_25 <= 0;
74
        end
75
        else begin
76
                clk_25 <= !clk_25;
77
        end
78
end
79
 
80 227 creep
always @ (posedge clk_25 or negedge reset_n)
81 221 creep
begin
82 227 creep
        if (!reset_n) begin
83 221 creep
                hc <= 0;
84
                VGA_HS <= 1;
85
                vsenable <= 0;
86
        end
87
        else if (hc < 640) begin
88
                hc <= hc + 1;
89
                vsenable <= 0;
90
                VGA_HS <= 1;
91
        end
92
        else if (hc < 640 + 16) begin
93
                VGA_HS <= 1;
94
                hc <= hc + 1;
95
                vsenable <= 0;
96
        end
97
        else if (hc < 640 + 16 + 96) begin
98
                VGA_HS <= 0;
99
                hc <= hc + 1;
100
                vsenable <= 0;
101
        end
102
        else if (hc < 640 + 16 + 96 + 48) begin
103
                VGA_HS <= 1;
104
                hc <= hc + 1;
105
                vsenable <= 0;
106
        end
107
        else begin
108
                VGA_HS <= 1;
109
                hc <= 0;
110
                vsenable <= 1;
111
        end
112
end
113
 
114 227 creep
always @ (posedge clk_25 or negedge reset_n)
115 221 creep
begin
116 227 creep
        if (!reset_n) begin
117 221 creep
                vc <= 0;
118
                VGA_VS <= 1;
119
        end
120
        else begin
121
                if (vsenable == 1) begin
122
                        vc <= vc + 1;
123
                end
124
                if (vc < 480) begin
125
                        VGA_VS <= 1;
126
                end
127
                else if (vc < 480 + 11) begin
128
                        VGA_VS <= 1;
129
                end
130
                else if (vc < 480 + 11 + 2) begin
131
                        VGA_VS <= 0;
132
                end
133
                else if (vc < 480 + 11 + 2 + 31) begin
134
                        VGA_VS <= 1;
135
                end
136
                else begin
137
                        vc <= 0;
138
                        VGA_VS <= 1;
139
                end
140
        end
141
end
142
 
143
always @ (posedge clk_25)
144
begin
145 227 creep
        VGA_R[0] <= 0;
146
        VGA_G[0] <= 0;
147
        VGA_B[0] <= 0;
148
        VGA_R[1] <= 0;
149
        VGA_G[1] <= 0;
150
        VGA_B[1] <= 0;
151
        VGA_R[2] <= 0;
152
        VGA_G[2] <= 0;
153
        VGA_B[2] <= 0;
154
        VGA_R[3] <= 0;
155
        VGA_G[3] <= 0;
156
        VGA_B[3] <= 0;
157 221 creep
        if (vidon == 1) begin
158 229 creep
                if (hc < 640) begin
159
                        if (vc > vert_counter * 16 && vc < vert_couter*16 + 16)
160
                                if (vert_counter == 1) begin
161
                                        VGA_R[0] <= line[hc*12];
162
                                        VGA_R[1] <= line[hc*12+1];
163
                                        VGA_R[2] <= line[hc*12+2];
164
                                        VGA_R[3] <= line[hc*12+3];
165
                                        VGA_G[0] <= line[hc*12+4];
166
                                        VGA_G[1] <= line[hc*12+5];
167
                                        VGA_G[2] <= line[hc*12+6];
168
                                        VGA_G[3] <= line[hc*12+7];
169
                                        VGA_B[0] <= line[hc*12+8];
170
                                        VGA_B[1] <= line[hc*12+9];
171
                                        VGA_B[2] <= line[hc*12+10];
172
                                        VGA_B[3] <= line[hc*12+11];
173
                                end
174 225 gabrielosh
                        end
175
                end
176 221 creep
        end
177
end
178
 
179
assign vidon = (hc < 640 && vc < 480) ? 1 : 0;
180
 
181
endmodule

powered by: WebSVN 2.1.0

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