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

Subversion Repositories or1k

[/] [or1k/] [tags/] [first/] [mp3/] [rtl/] [verilog/] [ssvga/] [ssvga_top.v] - Blame information for rev 266

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

Line No. Rev Author Line
1 266 lampret
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Simple Small VGA IP Core                                    ////
4
////                                                              ////
5
////  This file is part of the Simple Small VGA project           ////
6
////                                                              ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Top level of SSVGA.                                         ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////   Nothing                                                    ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Damjan Lampret, lampret@opencores.org                 ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE.  See the GNU Lesser General Public License for more ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
//
44
// CVS Revision History
45
//
46
// $Log: not supported by cvs2svn $
47
// Revision 1.1.1.1  2001/10/06 10:19:09  igorm
48
// no message
49
//
50
//
51
 
52
// synopsys translate_off
53
`include "timescale.v"
54
// synopsys translate_on
55
 
56
module ssvga_top(
57
        // Clock and reset
58
        wb_clk_i, wb_rst_i,
59
 
60
        // WISHBONE Master I/F
61
        wbm_cyc_o, wbm_stb_o, wbm_sel_o, wbm_we_o,
62
        wbm_adr_o, wbm_dat_o, wbm_cab_o,
63
        wbm_dat_i, wbm_ack_i, wbm_err_i, wbm_rty_i,
64
 
65
        // WISHBONE Slave I/F
66
        wbs_cyc_i, wbs_stb_i, wbs_sel_i, wbs_we_i,
67
        wbs_adr_i, wbs_dat_i, wbs_cab_i,
68
        wbs_dat_o, wbs_ack_o, wbs_err_o, wbs_rty_o,
69
 
70
        // Signals to VGA display
71
        pad_hsync_o, pad_vsync_o, pad_rgb_o, led_o,
72
 
73
        // clock x2 output for crtc iob connection
74
        pix_clk, misc
75
);
76
 
77
//
78
// I/O ports
79
//
80
 
81
//
82
// Clock and reset
83
//
84
input                   wb_clk_i;       // Pixel Clock
85
input                   wb_rst_i;       // Reset
86
 
87
//
88
// WISHBONE Master I/F
89
//
90
output                  wbm_cyc_o;
91
output                  wbm_stb_o;
92
output  [3:0]            wbm_sel_o;
93
output                  wbm_we_o;
94
output  [31:0]           wbm_adr_o;
95
output  [31:0]           wbm_dat_o;
96
output                  wbm_cab_o;
97
input   [31:0]           wbm_dat_i;
98
input                   wbm_ack_i;
99
input                   wbm_err_i;
100
input                   wbm_rty_i;
101
 
102
//
103
// WISHBONE Slave I/F
104
//
105
input                   wbs_cyc_i;
106
input                   wbs_stb_i;
107
input   [3:0]            wbs_sel_i;
108
input                   wbs_we_i;
109
input   [31:0]           wbs_adr_i;
110
input   [31:0]           wbs_dat_i;
111
input                   wbs_cab_i;
112
output  [31:0]           wbs_dat_o;
113
output                  wbs_ack_o;
114
output                  wbs_err_o;
115
output                  wbs_rty_o;
116
 
117
//
118
// VGA display
119
//
120
output                  pad_hsync_o;    // H sync
121
output                  pad_vsync_o;    // V sync
122
output  [15:0]           pad_rgb_o;      // Digital RGB data
123
output                  led_o;
124
output          pix_clk ;       // pixel clock output
125
 
126
input   [15:0]   misc;
127
 
128
//
129
// Internal wires and regs
130
//
131
wire                    ssvga_en;       // Global enable
132
wire                    fifo_full;      // FIFO full flag
133
wire                    fifo_empty;     // FIFO empty flag
134
wire            wbm_restart ; // indicator on when WISHBONE master should restart whole screen because of pixel buffer underrun
135
wire                    crtc_hblank;    // H blank
136
wire                    crtc_vblank;    // V blank
137
wire                    fifo_wr_en;     // FIFO write enable
138
wire                    fifo_rd_en;     // FIFO read enable
139
wire    [31:0]           fifo_in;        // FIFO input data
140
wire    [7:0]            fifo_out;       // FIFO output data
141
//wire  [7:0]           pal_indx;       // Palette index
142
wire                    pal_wr_en;      // Palette write enable
143
wire                    pal_rd_en;      // Palette read enable
144
wire    [15:0]  pal_pix_dat ; // pixel output from pallete RAM
145
 
146
// clockx2 - buffered
147
wire    clk_2x_buf;
148
assign  pix_clk = clk_2x_buf ;
149
reg go ;
150
 
151
// rgb output assignment - when blank output transmits black pixels, otherwise it transmits pallete data
152
reg drive_blank_reg ;
153
//always@(posedge wb_clk_i or posedge wb_rst_i)
154
always@(posedge clk_2x_buf or posedge wb_rst_i)
155
begin
156
    if ( wb_rst_i )
157
        drive_blank_reg <= #1 1'b0 ;
158
    else
159
        drive_blank_reg <= #1 ( crtc_hblank || crtc_vblank || ~go ) ;
160
end
161
 
162
assign pad_rgb_o =  drive_blank_reg ? 16'h0000 : pal_pix_dat ;
163
//assign pad_rgb_o =  drive_blank_reg ? 16'h0000 : wbs_dat_i[15:0]; // for test
164
 
165
assign led_o = ssvga_en ;
166
 
167
//
168
// Read FIFO when blanks are not asserted and fifo has been filled once
169
//
170
always@(posedge wb_clk_i or posedge wb_rst_i)
171
begin
172
    if ( wb_rst_i )
173
        go <= #1 1'b0 ;
174
    else
175
    if ( ~ssvga_en )
176
        go <= #1 1'b0 ;
177
    else
178
        go <= #1 ( fifo_full & crtc_hblank & crtc_vblank ) || ( go && ~fifo_empty ) ;
179
end
180
 
181
assign fifo_rd_en = !crtc_hblank & !crtc_vblank & go ;
182
 
183
assign wbm_restart = go & fifo_empty ;
184
 
185
//
186
// Palette index is either color index from FIFO or
187
// address from WISHBONE slave when writing into palette
188
//
189
//assign pal_indx = (pal_wr_en || pal_rd_en) ? wbs_adr_i[9:2] : fifo_out;
190
 
191
//
192
// Instantiation of WISHBONE Master block
193
//
194
wire [31:2] pix_start_addr ;
195
ssvga_wbm_if ssvga_wbm_if(
196
 
197
        // Clock and reset
198
        .wb_clk_i(wb_clk_i),
199
        .wb_rst_i(wb_rst_i),
200
 
201
        // WISHBONE Master I/F
202
        .wbm_cyc_o(wbm_cyc_o),
203
        .wbm_stb_o(wbm_stb_o),
204
        .wbm_sel_o(wbm_sel_o),
205
        .wbm_we_o(wbm_we_o),
206
        .wbm_adr_o(wbm_adr_o),
207
        .wbm_dat_o(wbm_dat_o),
208
        .wbm_cab_o(wbm_cab_o),
209
        .wbm_dat_i(wbm_dat_i),
210
        .wbm_ack_i(wbm_ack_i),
211
        .wbm_err_i(wbm_err_i),
212
        .wbm_rty_i(wbm_rty_i),
213
 
214
        // FIFO control and other signals
215
        .ssvga_en(ssvga_en),
216
        .fifo_full(fifo_full),
217
        .fifo_wr_en(fifo_wr_en),
218
        .fifo_dat(fifo_in),
219
    .pix_start_addr(pix_start_addr),
220
    .resync(wbm_restart)
221
);
222
 
223
//
224
// Instantiation of WISHBONE Slave block
225
//
226
wire [15:0] wbs_pal_data ;
227
ssvga_wbs_if ssvga_wbs_if(
228
 
229
        // Clock and reset
230
        .wb_clk_i(wb_clk_i),
231
        .wb_rst_i(wb_rst_i),
232
 
233
        // WISHBONE Slave I/F
234
        .wbs_cyc_i(wbs_cyc_i),
235
        .wbs_stb_i(wbs_stb_i),
236
        .wbs_sel_i(wbs_sel_i),
237
        .wbs_we_i(wbs_we_i),
238
        .wbs_adr_i(wbs_adr_i),
239
        .wbs_dat_i(wbs_dat_i),
240
        .wbs_cab_i(wbs_cab_i),
241
        .wbs_dat_o(wbs_dat_o),
242
        .wbs_ack_o(wbs_ack_o),
243
        .wbs_err_o(wbs_err_o),
244
        .wbs_rty_o(wbs_rty_o),
245
 
246
        // Control for other SSVGA blocks
247
        .ssvga_en(ssvga_en),
248
        .pal_wr_en(pal_wr_en),
249
    .pal_rd_en(pal_rd_en),
250
        .pal_dat(wbs_pal_data),
251
    .pix_start_addr(pix_start_addr),
252
        .misc(misc)
253
);
254
 
255
//
256
// Instantiation of line FIFO block
257
//
258
ssvga_fifo ssvga_fifo(
259
        .wclk(wb_clk_i),
260
        .rclk(clk_2x_buf),
261
        .rst(wb_rst_i),
262
        .wr_en(fifo_wr_en),
263
        .rd_en(fifo_rd_en),
264
        .dat_i(fifo_in),
265
        .dat_o(fifo_out),
266
        .full(fifo_full),
267
        .empty(fifo_empty),
268
    .ssvga_en(ssvga_en)
269
);
270
 
271
//
272
// Instantiation of 256x16 Palette block
273
//
274
RAMB4_S16_S16 ssvga_pallete
275
(
276
    .ADDRA(wbs_adr_i[9:2]),
277
    .DIA(wbs_dat_i[15:0]),
278
    .ENA(1'b1),
279
    .RSTA(wb_rst_i),
280
    .CLKA(wb_clk_i),
281
    .WEA(pal_wr_en),
282
    .DOA(wbs_pal_data),
283
    .ADDRB(fifo_out),
284
    .DIB(16'h0000),
285
    .ENB(1'b1),
286
    .RSTB(wb_rst_i),
287
    .CLKB(clk_2x_buf),
288
    .WEB(1'b0),
289
    .DOB(pal_pix_dat)
290
) ;
291
 
292
/*generic_spram_256x16 ssvga_palette(
293
        // Generic synchronous single-port RAM interface
294
        .clk(wb_clk_i),
295
        .rst(wb_rst_i),
296
        .ce(1'b1),
297
        .we(pal_wr_en),
298
        .oe(1'b1),
299
        .addr(pal_indx),
300
        .di(wbs_dat_i[15:0]),
301
        .do(pad_rgb_o)
302
);
303
*/
304
//
305
// Instantiation of CRT controller block
306
//
307
wire    clk_buf;
308
wire    clk_2x;
309
assign clk_buf = wb_clk_i;
310
`ifdef TARGET_VIRTEX
311
BUFG BUFG_crt2(.O(clk_2x_buf), .I(clk_2x));
312
`else
313
assign clk_2x_buf = clk_2x;
314
`endif
315
 
316
`ifdef TARGET_VIRTEX
317
CLKDLL CLKDLL(
318
        .CLK0(),
319
        .CLK90(),
320
        .CLK180(),
321
        .CLK270(),
322
        .CLK2X(clk_2x),
323
        .CLKDV(),
324
        .LOCKED(),
325
        .CLKIN(clk_buf),
326
        .CLKFB(clk_2x_buf),
327
        .RST(1'b0)
328
);
329
`else
330
assign clk_2x = clk_buf;
331
`endif
332
 
333
ssvga_crtc ssvga_crtc(
334
        .clk(clk_2x_buf),
335
        .rst(wb_rst_i),
336
        .hsync(pad_hsync_o),
337
        .vsync(pad_vsync_o),
338
        .hblank(crtc_hblank),
339
        .vblank(crtc_vblank)
340
);
341
 
342
endmodule

powered by: WebSVN 2.1.0

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