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

Subversion Repositories t6507lp

[/] [t6507lp/] [trunk/] [rtl/] [verilog/] [video.v] - Blame information for rev 218

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

Line No. Rev Author Line
1 215 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
//// Video module                                                       ////
10
////                                                                    ////
11
//// TODO:                                                              ////
12
//// - Everything?                                                      ////
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
module video(clk, reset_n, io_lines, enable, mem_rw, address, data);
48
        parameter [3:0] DATA_SIZE = 4'd8;
49
        parameter [3:0] ADDR_SIZE = 4'd10; // this is the *local* addr_size
50
 
51
        localparam [3:0] DATA_SIZE_ = DATA_SIZE - 4'd1;
52
        localparam [3:0] ADDR_SIZE_ = ADDR_SIZE - 4'd1;
53
 
54
        input clk; // master clock signal, 1.19mhz
55
        input reset_n;
56
        input [15:0] io_lines; // inputs from the keyboard controller
57
        input enable; // since the address bus is shared an enable signal is used
58
        input mem_rw; // read == 0, write == 1
59
        input [ADDR_SIZE_:0] address; // system address bus
60
        inout [DATA_SIZE_:0] data; // controler <=> riot data bus
61
 
62
        reg [DATA_SIZE_:0] data_drv; // wrapper for the data bus
63
 
64
        assign data = (mem_rw || !reset_n) ? 8'bZ : data_drv; // if under writing the bus receives the data from cpu, else local data. 
65
 
66
        reg VSYNC; // vertical sync set-clear
67 216 creep
        reg [2:0] VBLANK; // vertical blank set-clear
68 215 creep
        reg WSYNC; //  s t r o b e wait for leading edge of horizontal blank
69
        reg RSYNC; //  s t r o b e reset horizontal sync counter
70 216 creep
        reg [5:0] NUSIZ0; //  number-size player-missile 0
71
        reg [5:0] NUSIZ1; //  number-size player-missile 1
72
        reg [6:0] COLUP0; //  color-lum player 0
73
        reg [6:0] COLUP1; //  color-lum player 1
74
        reg [6:0] COLUPF; //  color-lum playfield
75
        reg [6:0] COLUBK; //  color-lum background
76
        reg [4:0] CTRLPF; //  control playfield ball size & collisions
77
        reg REFP0; //  reflect player 0
78
        reg REFP1; //  reflect player 1
79
        reg [3:0] PF0; //  playfield register byte 0
80
        reg [7:0] PF1; //  playfield register byte 1
81
        reg [7:0] PF2; //  playfield register byte 2
82 215 creep
        reg RESP0; //  s t r o b e reset player 0
83
        reg RESP1; //  s t r o b e reset player 1
84
        reg RESM0; //  s t r o b e reset missile 0
85
        reg RESM1; //  s t r o b e reset missile 1
86
        reg RESBL; //  s t r o b e reset ball
87 216 creep
        reg [3:0] AUDC0; //  audio control 0
88
        reg [4:0] AUDC1; //  audio control 1
89
        reg [4:0] AUDF0; //  audio frequency 0
90
        reg [3:0] AUDF1; //  audio frequency 1
91
        reg [3:0] AUDV0; //  audio volume 0
92
        reg [3:0] AUDV1; //  audio volume 1
93
        reg [7:0] GRP0; //  graphics player 0
94
        reg [7:0] GRP1; //  graphics player 1
95
        reg ENAM0; //  graphics (enable) missile 0
96
        reg ENAM1; //  graphics (enable) missile 1
97
        reg ENABL; //  graphics (enable) ball
98
        reg [3:0] HMP0; //  horizontal motion player 0
99
        reg [3:0] HMP1; //  horizontal motion player 1
100
        reg [3:0] HMM0; //  horizontal motion missile 0
101
        reg [3:0] HMM1; //  horizontal motion missile 1
102
        reg [3:0] HMBL; //  horizontal motion ball
103
        reg VDELP0; //  vertical delay player 0
104
        reg VDEL01; //  vertical delay player 1
105
        reg VDELBL; //  vertical delay ball
106
        reg RESMP0; //  reset missile 0 to player 0
107
        reg RESMP1; //  reset missile 1 to player 1
108 215 creep
        reg HMOVE; //  s t r o b e apply horizontal motion
109
        reg HMCLR; //  s t r o b e clear horizontal motion registers
110 216 creep
        reg CXCLR ; // s t r o b e clear collision latches
111 215 creep
 
112 216 creep
        reg [1:0] CXM0P; // read collision MO P1 M0 P0
113
        reg [1:0] CXM1P; // read collision M1 P0 M1 P1
114
        reg [1:0] CXP0FB; // read collision P0 PF P0 BL
115
        reg [1:0] CXP1FB; // read collision P1 PF P1 BL
116
        reg [1:0] CXM0FB; // read collision M0 PF M0 BL
117
        reg [1:0] CXM1FB; // read collision M1 PF M1 BL
118
        reg CXBLPF; // read collision BL PF unused
119
        reg [1:0] CXPPMM; // read collision P0 P1 M0 M1
120
        reg INPT0; // read pot port
121
        reg INPT1; // read pot port
122
        reg INPT2; // read pot port
123
        reg INPT3; // read pot port
124
        reg INPT4; // read input
125
        reg INPT5; // read input 
126
 
127
        always @(posedge clk  or negedge reset_n) begin
128 215 creep
                if (reset_n == 1'b0) begin
129
                        data_drv <= 8'h00;
130
                end
131
                else begin
132 216 creep
                        if (mem_rw == 1'b0) begin // reading! 
133 215 creep
                                case (address)
134 216 creep
                                        6'h00: data_drv <= {CXM0P, 6'b000000};
135
                                        6'h01: data_drv <= {CXM1P, 6'b000000};
136
                                        6'h02: data_drv <= {CXP0FB, 6'b000000};
137
                                        6'h03: data_drv <= {CXP1FB, 6'b000000};
138
                                        6'h04: data_drv <= {CXM0FB, 6'b000000};
139
                                        6'h05: data_drv <= {CXM1FB, 6'b000000};
140
                                        6'h06: data_drv <= {CXBLPF, 7'b000000};
141
                                        6'h07: data_drv <= {CXPPMM, 6'b000000};
142
                                        6'h08: data_drv <= {INPT0, 7'b000000};
143
                                        6'h09: data_drv <= {INPT1, 7'b000000};
144
                                        6'h0A: data_drv <= {INPT2, 7'b000000};
145
                                        6'h0B: data_drv <= {INPT3, 7'b000000};
146
                                        6'h0C: data_drv <= {INPT4, 7'b000000};
147
                                        6'h0D: data_drv <= {INPT5, 7'b000000};
148
                                        default: ;
149 215 creep
                                endcase
150
                        end
151 216 creep
                        else begin // writing! 
152 215 creep
                                case (address)
153 216 creep
                                        6'h00: begin
154 217 creep
                                                VSYNC <= data[1];
155 215 creep
                                        end
156 216 creep
                                        6'h01: begin
157 217 creep
                                                VBLANK <= {data[7:6], data[1]};
158 215 creep
                                        end
159 216 creep
                                        6'h02: begin
160 217 creep
                                                WSYNC <= 1'b1; // STROBE
161 215 creep
                                        end
162 216 creep
                                        6'h03: begin
163 217 creep
                                                RSYNC <= 1'b1; // STROBE
164 215 creep
                                        end
165 216 creep
                                        6'h04: begin
166 217 creep
                                                NUSIZ0 <= data[5:0];
167 216 creep
                                        end
168
                                        6'h05: begin
169 217 creep
                                                NUSIZ1 <= data[5:0];
170 216 creep
                                        end
171
                                        6'h06: begin
172 217 creep
                                                COLUP0 <= data[7:1];
173 216 creep
                                        end
174
                                        6'h07: begin
175 217 creep
                                                COLUP1 <= data[7:1];
176 216 creep
                                        end
177
                                        6'h08: begin
178 217 creep
                                                COLUPF <= data[7:1];
179 216 creep
                                        end
180
                                        6'h09: begin
181 217 creep
                                                COLUBK <= data[7:1];
182 216 creep
                                        end
183
                                        6'h0a: begin
184 217 creep
                                                CTRLPF <= {data[5:4], data[2:0]};
185 216 creep
                                        end
186
                                        6'h0b: begin
187 217 creep
                                                REFP0 <= data[3];
188 216 creep
                                        end
189
                                        6'h0c: begin
190 217 creep
                                                REFP1 <= data[3];
191 216 creep
                                        end
192 217 creep
                                        6'h0d: begin
193
                                                PF0 <= data[7:4 ];
194
                                        end
195
                                        6'h0e: begin
196
                                                PF1 <= data;
197
                                        end
198
                                        6'h0f: begin
199
                                                PF2 <= data;
200
                                        end
201
                                        6'h10: begin
202
                                                RESP0 <= 1'b1; // STROBE
203
                                        end
204
                                        6'h11: begin
205
                                                RESP1 <= 1'b1; // STROBE
206
                                        end
207
                                        6'h12: begin
208
                                                RESM0 <= 1'b1; // STROBE
209
                                        end
210
                                        6'h13: begin
211
                                                RESM1 <= 1'b1; // STROBE
212
                                        end
213
                                        6'h14: begin
214
                                                RESBL <= 1'b1; // STROBE
215
                                        end
216
                                        6'h15: begin
217
                                                AUDC0 <= data[3:0];
218
                                        end
219
                                        6'h16: begin
220
                                                AUDC1 <= data[4:0];
221
                                        end
222
                                        6'h17: begin
223
                                                AUDF0 <= data[4:0];
224
                                        end
225
                                        6'h18: begin
226
                                                AUDF1 <= data[3:0];
227
                                        end
228
                                        6'h19: begin
229
                                                AUDV0 <= data[3:0];
230
                                        end
231
                                        6'h1A: begin
232
                                                AUDV1 <= data[3:0];
233
                                        end
234
                                        6'h1B: begin
235
                                                GRP0 <= data;
236
                                        end
237
                                        6'h1C: begin
238
                                                GRP1 <= data;
239
                                        end
240
                                        6'h1D: begin
241
                                                ENAM0 <= data[1];
242
                                        end
243
                                        6'h1E: begin
244
                                                ENAM1 <= data[1];
245
                                        end
246
                                        6'h1F: begin
247
                                                ENABL <= data[1];
248
                                        end
249
                                        6'h20: begin
250
                                                HMP0 <= data[7:4];
251
                                        end
252
                                        6'h21: begin
253
                                                HMP1 <= data[7:4];
254
                                        end
255
                                        6'h22: begin
256
                                                HMM0 <= data[7:4];
257
                                        end
258
                                        6'h23: begin
259
                                                HMM1 <= data[7:4];
260
                                        end
261
                                        6'h24: begin
262
                                                HMBL <= data[7:4];
263
                                        end
264
                                        6'h25: begin
265
                                                VDELP0 <= data[0];
266
                                        end
267
                                        6'h26: begin
268
                                                VDEL01 <= data[0];
269
                                        end
270
                                        6'h27: begin
271
                                                VDELBL <= data[0];
272
                                        end
273
                                        6'h28: begin
274
                                                RESMP0 <= data[1];
275
                                        end
276
                                        6'h29: begin
277
                                                RESMP1 <= data[1];
278
                                        end
279
                                        6'h2a: begin
280
                                                HMOVE <= 1'b1; // STROBE
281
                                        end
282
                                        6'h2b: begin
283
                                                HMCLR <= 1'b1; // STROBE
284
                                        end
285
                                        6'h2c: begin
286
                                                CXCLR <= 1'b1; // STROBE
287
                                        end
288 215 creep
                                        default: begin
289
                                        end
290
                                endcase
291
                        end
292
                end
293
        end
294
 
295
endmodule
296
 

powered by: WebSVN 2.1.0

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