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

Subversion Repositories t6507lp

[/] [t6507lp/] [trunk/] [rtl/] [verilog/] [controller_test.v] - Blame information for rev 233

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

Line No. Rev Author Line
1 222 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 233 creep
module controller_test(reset_n, clk_50, pixel, write_addr, write_data, write_enable_n, clk_358);
48 222 creep
 
49 227 creep
input reset_n;
50 225 gabrielosh
input clk_50;
51 233 creep
output reg [2:0] pixel;
52
output reg [10:0] write_addr;
53
output reg [2:0] write_data;
54
output reg write_enable_n;
55
output reg clk_358; // 3.58mhz
56 222 creep
 
57
reg [3:0] counter;
58
 
59 233 creep
//reg [3:0] red;
60
//reg [3:0] green;
61
//reg [3:0] blue;
62 222 creep
 
63 233 creep
reg [8:0] vert_counter;
64
reg [7:0] hor_counter;
65
 
66 227 creep
always @ (posedge clk_50 or negedge reset_n) begin
67
        if (reset_n == 1'b0) begin
68 222 creep
                clk_358 <= 1'b0;
69
                counter <= 4'd0;
70 233 creep
                //red <= 4'b1010;
71
                //green <= 4'b0001;
72
                //blue <= 4'b1110;
73 222 creep
        end
74
        else begin
75 233 creep
                //red <= 4'b1010;
76
                //green <= 4'b0001;
77
                //blue <= 4'b1110;
78 230 creep
 
79 222 creep
                if (counter == 4'h6) begin
80
                        clk_358 <= !clk_358;
81
                        counter <= 4'd0;
82
                end
83
                else begin
84 227 creep
                        counter <= counter + 4'd1;
85 222 creep
                end
86 227 creep
        end
87 222 creep
end
88
 
89 227 creep
always @ (posedge clk_358 or negedge reset_n) begin
90
        if (reset_n == 1'b0) begin
91 230 creep
                hor_counter <= 8'd0;
92 231 gabrielosh
                vert_counter <= 9'd0;
93 222 creep
        end
94
        else begin
95 230 creep
                if (hor_counter == 8'd227) begin // last colum
96
                        hor_counter <= 8'd0;
97 222 creep
 
98 230 creep
                        if (vert_counter == 9'd261) begin // last line
99
                                vert_counter <= 9'd0;
100
                        end
101
                        else begin
102
                                vert_counter <= vert_counter + 9'd1;
103
                        end
104 222 creep
                end
105
                else begin
106 230 creep
                        hor_counter <= hor_counter + 8'd1;
107 222 creep
                end
108
        end
109 227 creep
end
110 222 creep
 
111 230 creep
always @(*) begin // comb logic
112 233 creep
        if (hor_counter < 68 || vert_counter < 40 || vert_counter > 232) begin
113
                pixel = 3'd0;
114
                write_enable_n = 1'b1;
115
                write_addr = 0;
116
                write_data = vert_counter[2:0];
117 232 creep
        end
118
        else begin
119 233 creep
                pixel = 3'd4;
120
                write_enable_n = 1'b0;
121
                write_addr = (hor_counter - 68) + (vert_counter - 40)*160;
122
                write_data = 3'd4;
123 232 creep
        end
124 222 creep
end
125
 
126
endmodule

powered by: WebSVN 2.1.0

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