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

Subversion Repositories rtfbitmapcontroller

[/] [rtfbitmapcontroller/] [trunk/] [rtl/] [verilog/] [rtfVideoFifo3.v] - Blame information for rev 16

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

Line No. Rev Author Line
1 16 robfinch
`timescale 1ns / 1ps
2
// ============================================================================
3
//        __
4
//   \\__/ o\    (C) 2008-2015  Robert Finch, Stratford
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 rtfVideoFifo3(wrst, wclk, wr, di, rrst, rclk, rd, dout, cnt);
29
input wrst;
30
input wclk;
31
input wr;
32
input [127:0] di;
33
input rrst;
34
input rclk;
35
input rd;
36
output [127:0] dout;
37
output [7:0] cnt;
38
reg [7:0] cnt;
39
 
40
reg [7:0] wr_ptr;
41
reg [7:0] rd_ptr,rrd_ptr;
42
reg [127:0] mem [0:255];
43
 
44
wire [7:0] wr_ptr_p1 = wr_ptr + 8'd1;
45
wire [7:0] rd_ptr_p1 = rd_ptr + 8'd1;
46
reg [7:0] rd_ptrs;
47
 
48
always @(posedge wclk)
49
        if (wrst)
50
                wr_ptr <= 8'd0;
51
        else if (wr) begin
52
                mem[wr_ptr] <= di;
53
                wr_ptr <= wr_ptr_p1;
54
        end
55
always @(posedge wclk)          // synchronize read pointer to wclk domain
56
        rd_ptrs <= rd_ptr;
57
 
58
always @(posedge rclk)
59
        if (rrst)
60
                rd_ptr <= 8'd0;
61
        else if (rd)
62
                rd_ptr <= rd_ptr_p1;
63
always @(posedge rclk)
64
        rrd_ptr <= rd_ptr;
65
 
66
assign dout = mem[rrd_ptr[7:0]];
67
 
68
always @(wr_ptr or rd_ptrs)
69
        if (rd_ptrs > wr_ptr)
70
                cnt <= wr_ptr + (9'd256 - rd_ptrs);
71
        else
72
                cnt <= wr_ptr - rd_ptrs;
73
 
74
endmodule

powered by: WebSVN 2.1.0

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