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

Subversion Repositories rtfbitmapcontroller

[/] [rtfbitmapcontroller/] [trunk/] [rtl/] [verilog/] [rfVideoFifo.v] - Blame information for rev 28

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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