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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [mp3/] [rtl/] [verilog/] [ssvga/] [ssvga_fifo.v] - Blame information for rev 1765

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
////  512 entry FIFO for storing line video data. It uses one     ////
10
////  clock for reading and writing.                              ////
11
////                                                              ////
12
////  To Do:                                                      ////
13
////   Nothing                                                    ////
14
////                                                              ////
15
////  Author(s):                                                  ////
16
////      - Damjan Lampret, lampret@opencores.org                 ////
17
////                                                              ////
18
//////////////////////////////////////////////////////////////////////
19
////                                                              ////
20
//// Copyright (C) 2000 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
// CVS Revision History
46
//
47
// $Log: not supported by cvs2svn $
48
// Revision 1.1.1.1  2001/10/06 10:19:09  igorm
49
// no message
50
//
51
//
52
 
53
// synopsys translate_off
54
`include "timescale.v"
55
// synopsys translate_on
56
 
57
module ssvga_fifo(
58
        wclk, rclk, rst, dat_i, wr_en, rd_en,
59
        dat_o, full, empty, ssvga_en
60
);
61
 
62
//
63
// I/O ports
64
//
65
input                   wclk;           // write clock
66
input                   rclk;           // read clock
67
input                   rst;            // Reset
68
input   [31:0]           dat_i;          // Input data
69
input                   wr_en;          // Write enable
70
input                   rd_en;          // Read enable
71
output  [7:0]            dat_o;          // Output data
72
output                  full;           // Full flag
73
output                  empty;          // Empty flag
74
input           ssvga_en ;  // vga enable
75
 
76
//
77
// Internal wires and regs
78
//
79
reg     [7:0]            wr_ptr;            // Write pointer
80
reg     [7:0]            wr_ptr_plus1;  // Write pointer
81
reg     [9:0]            rd_ptr;             // Read pointer
82
reg     [9:0]            rd_ptr_plus1;   // Read pointer plus1
83
wire                    rd_en_int;      // FIFO internal read enable
84
 
85
//
86
// Write pointer + 1
87
//
88
 
89
always @(posedge wclk or posedge rst)
90
    if (rst)
91
                wr_ptr_plus1 <= #1 8'b0000_0001 ;
92
    else if (~ssvga_en)
93
        wr_ptr_plus1 <= #1 8'b0000_0001 ;
94
        else if (wr_en)
95
                wr_ptr_plus1 <= #1 wr_ptr_plus1 + 1;
96
 
97
//
98
// Write pointer
99
//
100
always @(posedge wclk or posedge rst)
101
        if (rst)
102
                wr_ptr <= #1 8'b0000_0000;
103
    else if (~ssvga_en)
104
        wr_ptr <= #1 8'b0000_0000;
105
        else if (wr_en)
106
                wr_ptr <= #1 wr_ptr_plus1 ;
107
 
108
//
109
// Read pointer
110
//
111
always @(posedge rclk or posedge rst)
112
        if (rst)
113
                rd_ptr <= #1 10'b00_0000_0000;
114
    else if (~ssvga_en)
115
        rd_ptr <= #1 10'b00_0000_0000;
116
        else if (rd_en_int)
117
                rd_ptr <= #1 rd_ptr_plus1 ;
118
 
119
always @(posedge rclk or posedge rst)
120
        if (rst)
121
                rd_ptr_plus1 <= #1 10'b00_0000_0001;
122
    else if (~ssvga_en)
123
        rd_ptr_plus1 <= #1 10'b00_0000_0001;
124
        else if (rd_en_int)
125
                rd_ptr_plus1 <= #1 rd_ptr_plus1 + 1 ;
126
 
127
//
128
// Empty is asserted when both pointers match
129
//
130
assign empty = (rd_ptr == {wr_ptr, 2'b00}) ;
131
 
132
//
133
// Full is asserted when both pointers match
134
// and wr_ptr did increment in previous clock cycle
135
//
136
 
137
assign full = ( wr_ptr_plus1 == rd_ptr[9:2] ) ;
138
 
139
wire valid_pix = 1'b1 ;
140
 
141
//
142
// Read enable for FIFO
143
//
144
assign rd_en_int = rd_en & !empty & valid_pix;
145
 
146
wire [8:0] ram_pix_address = rd_en_int ? {rd_ptr_plus1[9:2], rd_ptr_plus1[0]} : {rd_ptr[9:2], rd_ptr[0]} ;
147
 
148
wire [7:0] dat_o_low ;
149
wire [7:0] dat_o_high ;
150
 
151
assign dat_o = rd_ptr[1] ? dat_o_high : dat_o_low ;
152
 
153
RAMB4_S8_S16 ramb4_s8_0(
154
        .CLKA(rclk),
155
        .RSTA(rst),
156
        .ADDRA(ram_pix_address),
157
        .DIA(8'h00),
158
        .ENA(1'b1),
159
        .WEA(1'b0),
160
        .DOA(dat_o_low),
161
 
162
        .CLKB(wclk),
163
        .RSTB(rst),
164
        .ADDRB(wr_ptr),
165
        .DIB(dat_i[15:0]),
166
        .ENB(1'b1),
167
        .WEB(wr_en),
168
        .DOB()
169
);
170
 
171
RAMB4_S8_S16 ramb4_s8_1(
172
        .CLKA(rclk),
173
        .RSTA(rst),
174
        .ADDRA(ram_pix_address),
175
        .DIA(8'h00),
176
        .ENA(1'b1),
177
        .WEA(1'b0),
178
        .DOA(dat_o_high),
179
 
180
        .CLKB(wclk),
181
        .RSTB(rst),
182
        .ADDRB(wr_ptr),
183
        .DIB(dat_i[31:16]),
184
        .ENB(1'b1),
185
        .WEB(wr_en),
186
        .DOB()
187
);
188
 
189
endmodule

powered by: WebSVN 2.1.0

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