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

Subversion Repositories rtfbitmapcontroller

[/] [rtfbitmapcontroller/] [trunk/] [rtl/] [verilog/] [rtfVideoFifo.v] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 robfinch
`timescale 1ns / 1ps
2
// ============================================================================
3
//      (C) 2008-2013  Robert Finch
4
//      robfinch<remove>@opencores.org
5
//
6
//
7
// This source file is free software: you can redistribute it and/or modify 
8
// it under the terms of the GNU Lesser General Public License as published 
9
// by the Free Software Foundation, either version 3 of the License, or     
10
// (at your option) any later version.                                      
11
//                                                                          
12
// This source file is distributed in the hope that it will be useful,      
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
15
// GNU General Public License for more details.                             
16
//                                                                          
17
// You should have received a copy of the GNU General Public License        
18
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
19
//                                                                          
20
//
21
//      Verilog 1995
22
//
23
// ============================================================================
24
//
25
module rtfVideoFifo(rst, wclk, wr, di, rclk, rd, do, cnt);
26
input rst;
27
input wclk;
28
input wr;
29
input [31:0] di;
30
input rclk;
31
input rd;
32
output [31:0] do;
33
output [8:0] cnt;
34
reg [8:0] cnt;
35
 
36
reg [8:0] wr_ptr;
37
reg [8:0] rd_ptr,rrd_ptr;
38
reg [31:0] mem [0:511];
39
 
40
always @(posedge wclk)
41
        if (rst)
42
                wr_ptr <= 9'd0;
43
        else if (wr) begin
44
                mem[wr_ptr] <= di;
45
                wr_ptr <= wr_ptr + 9'd1;
46
        end
47
 
48
always @(posedge rclk)
49
        if (rst)
50
                rd_ptr <= 9'd0;
51
        else if (rd)
52
                rd_ptr <= rd_ptr + 9'd1;
53
always @(posedge rclk)
54
        rrd_ptr <= rd_ptr;
55
 
56
assign do = mem[rrd_ptr];
57
 
58
always @(wr_ptr or rd_ptr)
59
        if (rd_ptr > wr_ptr)
60
                cnt <= wr_ptr + (10'd512 - rd_ptr);
61
        else
62
                cnt <= wr_ptr - rd_ptr;
63
 
64
endmodule

powered by: WebSVN 2.1.0

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