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

Subversion Repositories rtfbitmapcontroller

[/] [rtfbitmapcontroller/] [trunk/] [rtl/] [verilog/] [rtfVideoFifo2.v] - Blame information for rev 15

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 15 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 rtfVideoFifo2(rst, wclk, wr, di, rclk, rd, do, cnt);
29
input rst;
30
input wclk;
31
input wr;
32
input [127:0] di;
33
input rclk;
34
input rd;
35
output [31:0] do;
36
reg [31:0] do;
37
output [8:0] cnt;
38
reg [8:0] cnt;
39
 
40
reg [6:0] wr_ptr;
41
reg [8:0] rd_ptr,rrd_ptr;
42
reg [127:0] mem [0:127];
43
 
44
wire [6:0] wr_ptr_p1 = wr_ptr + 7'd1;
45
wire [8:0] rd_ptr_p1 = rd_ptr + 9'd1;
46
reg [8:0] rd_ptrs;
47
 
48
always @(posedge wclk)
49
        if (rst)
50
                wr_ptr <= 7'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 (rst)
60
                rd_ptr <= 9'd0;
61
        else if (rd)
62
                rd_ptr <= rd_ptr_p1;
63
always @(posedge rclk)
64
        rrd_ptr <= rd_ptr;
65
 
66
always @(rrd_ptr)
67
case(rrd_ptr[1:0])
68
2'd0:   do <= mem[rrd_ptr[8:2]][31:0];
69
2'd1:   do <= mem[rrd_ptr[8:2]][63:32];
70
2'd2:   do <= mem[rrd_ptr[8:2]][95:64];
71
2'd3:   do <= mem[rrd_ptr[8:2]][127:96];
72
endcase
73
 
74
always @(wr_ptr or rd_ptrs)
75
        if (rd_ptrs > {wr_ptr,2'b00})
76
                cnt <= {wr_ptr,2'b00} + (10'd512 - rd_ptrs);
77
        else
78
                cnt <= {wr_ptr,2'b00} - rd_ptrs;
79
 
80
endmodule

powered by: WebSVN 2.1.0

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