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

Subversion Repositories uart6551

[/] [uart6551/] [trunk/] [trunk/] [rtl/] [uart6551Fifo.sv] - Blame information for rev 4

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

Line No. Rev Author Line
1 2 robfinch
// ============================================================================
2
//        __
3 4 robfinch
//   \\__/ o\    (C) 2003-2021  Robert Finch, Waterloo
4 2 robfinch
//    \  __ /    All rights reserved.
5
//     \/_//     robfinch@finitron.ca
6
//       ||
7
//
8
//
9
// This source file is free software: you can redistribute it and/or modify
10
// it under the terms of the GNU Lesser General Public License as published
11
// by the Free Software Foundation, either version 3 of the License, or
12
// (at your option) any later version.
13
//
14
// This source file is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
// GNU General Public License for more details.
18
//
19
// You should have received a copy of the GNU General Public License
20
// along with this program.  If not, see .
21
//
22
// ============================================================================
23
//
24
module uart6551Fifo(clk, rst, wr, rd, din, dout, ctr, full, empty);
25
parameter WID=8;
26
parameter DEP=16;
27 4 robfinch
localparam pCtrBits = $clog2(DEP-1);
28 2 robfinch
input clk;
29
input rst;
30
input wr;
31
input rd;
32
input [WID-1:0] din;
33
output [WID-1:0] dout;
34 4 robfinch
output [pCtrBits-1:0] ctr;
35
reg [pCtrBits-1:0] ctr;
36 2 robfinch
output full;
37
output empty;
38
 
39
assign full = ctr=={pCtrBits{1'b1}}-1;
40
assign empty = ctr=={pCtrBits{1'b1}};
41
wire rdok = rd & ~empty;
42
wire wrok = wr & ~full;
43
 
44
vtdl #(WID,DEP) u1 (.clk(clk), .ce(1'b1), .a(ctr), .d(din), .q(dout));
45
 
46
always @(posedge clk)
47
if (rst)
48
        ctr <= {pCtrBits{1'b1}};
49
else
50
        ctr <= ctr + {rdok&~wrok,rdok&~wrok,rdok&~wrok,rdok^wrok};
51
 
52
endmodule

powered by: WebSVN 2.1.0

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