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

Subversion Repositories or1k

[/] [or1k/] [tags/] [first/] [orp/] [orp_soc/] [rtl/] [verilog/] [ssvga/] [ssvga_top.v] - Blame information for rev 746

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

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

powered by: WebSVN 2.1.0

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