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

Subversion Repositories pci

[/] [pci/] [tags/] [rel_8/] [apps/] [crt/] [rtl/] [verilog/] [ssvga_top.v] - Blame information for rev 154

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 mihad
//////////////////////////////////////////////////////////////////////
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 21 mihad
// Revision 1.1.1.1  2001/10/02 15:33:33  mihad
48
// New project directory structure
49 2 mihad
//
50 21 mihad
//
51 2 mihad
 
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 21 mihad
 
60 2 mihad
        // 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
 
74
//
75
// I/O ports
76
//
77
 
78
//
79
// Clock and reset
80
//
81
input                   wb_clk_i;       // Write Clock
82
input                   wb_rst_i;       // Reset
83
 
84
//
85
// WISHBONE Master I/F
86
//
87
output                  wbm_cyc_o;
88
output                  wbm_stb_o;
89
output  [3:0]            wbm_sel_o;
90
output                  wbm_we_o;
91
output  [31:0]           wbm_adr_o;
92
output  [31:0]           wbm_dat_o;
93
output                  wbm_cab_o;
94
input   [31:0]           wbm_dat_i;
95
input                   wbm_ack_i;
96
input                   wbm_err_i;
97
input                   wbm_rty_i;
98
 
99
//
100
// WISHBONE Slave I/F
101
//
102
input                   wbs_cyc_i;
103
input                   wbs_stb_i;
104
input   [3:0]            wbs_sel_i;
105
input                   wbs_we_i;
106
input   [31:0]           wbs_adr_i;
107
input   [31:0]           wbs_dat_i;
108
input                   wbs_cab_i;
109
output  [31:0]           wbs_dat_o;
110
output                  wbs_ack_o;
111
output                  wbs_err_o;
112
output                  wbs_rty_o;
113
 
114
//
115
// VGA display
116
//
117
output                  pad_hsync_o;    // H sync
118
output                  pad_vsync_o;    // V sync
119
output  [15:0]           pad_rgb_o;      // Digital RGB data
120
output                  led_o;
121
 
122
//
123
// Internal wires and regs
124
//
125
wire                    ssvga_en;       // Global enable
126
wire                    fifo_full;      // FIFO full flag
127
wire                    fifo_empty;     // FIFO empty flag
128
wire            wbm_restart ; // indicator on when WISHBONE master should restart whole screen because of pixel buffer underrun
129
wire                    crtc_hblank;    // H blank
130
wire                    crtc_vblank;    // V blank
131
wire                    fifo_wr_en;     // FIFO write enable
132
wire                    fifo_rd_en;     // FIFO read enable
133
wire    [31:0]           fifo_in;        // FIFO input data
134
wire    [7:0]            fifo_out;       // FIFO output data
135
//wire  [7:0]           pal_indx;       // Palette index
136
wire                    pal_wr_en;      // Palette write enable
137
wire                    pal_rd_en;      // Palette read enable
138
wire    [15:0]  pal_pix_dat ; // pixel output from pallete RAM
139
 
140
reg go ;
141
 
142
// rgb output assignment - when blank output transmits black pixels, otherwise it transmits pallete data
143
reg drive_blank_reg ;
144
always@(posedge wb_clk_i or posedge wb_rst_i)
145
begin
146
    if ( wb_rst_i )
147
        drive_blank_reg <= #1 1'b0 ;
148
    else
149
        drive_blank_reg <= #1 ( crtc_hblank || crtc_vblank || ~go ) ;
150
end
151
 
152
assign pad_rgb_o =  drive_blank_reg ? 16'h0000 : pal_pix_dat ;
153
 
154
assign led_o = ssvga_en ;
155
 
156
//
157
// Read FIFO when blanks are not asserted and fifo has been filled once
158
//
159
always@(posedge wb_clk_i or posedge wb_rst_i)
160
begin
161
    if ( wb_rst_i )
162
        go <= #1 1'b0 ;
163
    else
164
    if ( ~ssvga_en )
165
        go <= #1 1'b0 ;
166
    else
167
        go <= #1 ( fifo_full & crtc_hblank & crtc_vblank ) || ( go && ~fifo_empty ) ;
168
end
169
 
170
assign fifo_rd_en = !crtc_hblank & !crtc_vblank & go ;
171
 
172
assign wbm_restart = go & fifo_empty ;
173
 
174
//
175
// Palette index is either color index from FIFO or
176
// address from WISHBONE slave when writing into palette
177
//
178
//assign pal_indx = (pal_wr_en || pal_rd_en) ? wbs_adr_i[9:2] : fifo_out;
179
 
180
//
181
// Instantiation of WISHBONE Master block
182
//
183
wire [31:2] pix_start_addr ;
184
ssvga_wbm_if ssvga_wbm_if(
185
 
186
        // Clock and reset
187
        .wb_clk_i(wb_clk_i),
188
        .wb_rst_i(wb_rst_i),
189
 
190
        // WISHBONE Master I/F
191
        .wbm_cyc_o(wbm_cyc_o),
192
        .wbm_stb_o(wbm_stb_o),
193
        .wbm_sel_o(wbm_sel_o),
194
        .wbm_we_o(wbm_we_o),
195
        .wbm_adr_o(wbm_adr_o),
196
        .wbm_dat_o(wbm_dat_o),
197
        .wbm_cab_o(wbm_cab_o),
198
        .wbm_dat_i(wbm_dat_i),
199
        .wbm_ack_i(wbm_ack_i),
200
        .wbm_err_i(wbm_err_i),
201
        .wbm_rty_i(wbm_rty_i),
202
 
203
        // FIFO control and other signals
204
        .ssvga_en(ssvga_en),
205
        .fifo_full(fifo_full),
206
        .fifo_wr_en(fifo_wr_en),
207
        .fifo_dat(fifo_in),
208
    .pix_start_addr(pix_start_addr),
209
    .resync(wbm_restart)
210
);
211
 
212
//
213
// Instantiation of WISHBONE Slave block
214
//
215
wire [15:0] wbs_pal_data ;
216
ssvga_wbs_if ssvga_wbs_if(
217
 
218
        // Clock and reset
219
        .wb_clk_i(wb_clk_i),
220
        .wb_rst_i(wb_rst_i),
221
 
222
        // WISHBONE Slave I/F
223
        .wbs_cyc_i(wbs_cyc_i),
224
        .wbs_stb_i(wbs_stb_i),
225
        .wbs_sel_i(wbs_sel_i),
226
        .wbs_we_i(wbs_we_i),
227
        .wbs_adr_i(wbs_adr_i),
228
        .wbs_dat_i(wbs_dat_i),
229
        .wbs_cab_i(wbs_cab_i),
230
        .wbs_dat_o(wbs_dat_o),
231
        .wbs_ack_o(wbs_ack_o),
232
        .wbs_err_o(wbs_err_o),
233
        .wbs_rty_o(wbs_rty_o),
234
 
235
        // Control for other SSVGA blocks
236
        .ssvga_en(ssvga_en),
237
        .pal_wr_en(pal_wr_en),
238
    .pal_rd_en(pal_rd_en),
239
        .pal_dat(wbs_pal_data),
240
    .pix_start_addr(pix_start_addr)
241
);
242
 
243
//
244
// Instantiation of line FIFO block
245
//
246
ssvga_fifo ssvga_fifo(
247
        .clk(wb_clk_i),
248
        .rst(wb_rst_i),
249
        .wr_en(fifo_wr_en),
250
        .rd_en(fifo_rd_en),
251
        .dat_i(fifo_in),
252
        .dat_o(fifo_out),
253
        .full(fifo_full),
254
        .empty(fifo_empty),
255
    .ssvga_en(ssvga_en)
256
);
257
 
258
//
259
// Instantiation of 256x16 Palette block
260
//
261
RAMB4_S16_S16 ssvga_pallete
262
(
263 21 mihad
    .ADDRA(wbs_adr_i[9:2]),
264
    .DIA(wbs_dat_i[15:0]),
265
    .ENA(1'b1),
266 2 mihad
    .RSTA(wb_rst_i),
267 21 mihad
    .CLKA(wb_clk_i),
268
    .WEA(pal_wr_en),
269 2 mihad
    .DOA(wbs_pal_data),
270 21 mihad
    .ADDRB(fifo_out),
271
    .DIB(16'h0000),
272
    .ENB(1'b1),
273 2 mihad
    .RSTB(wb_rst_i),
274 21 mihad
    .CLKB(wb_clk_i),
275
    .WEB(1'b0),
276 2 mihad
    .DOB(pal_pix_dat)
277
) ;
278
 
279
/*generic_spram_256x16 ssvga_palette(
280
        // Generic synchronous single-port RAM interface
281
        .clk(wb_clk_i),
282
        .rst(wb_rst_i),
283
        .ce(1'b1),
284
        .we(pal_wr_en),
285
        .oe(1'b1),
286
        .addr(pal_indx),
287
        .di(wbs_dat_i[15:0]),
288
        .do(pad_rgb_o)
289
);
290
*/
291
//
292
// Instantiation of CRT controller block
293
//
294
ssvga_crtc ssvga_crtc(
295 21 mihad
        .crt_clk(wb_clk_i),
296 2 mihad
        .rst(wb_rst_i),
297
        .hsync(pad_hsync_o),
298
        .vsync(pad_vsync_o),
299
        .hblank(crtc_hblank),
300
        .vblank(crtc_vblank)
301
);
302
 
303
endmodule

powered by: WebSVN 2.1.0

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