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

Subversion Repositories ethmac

[/] [ethmac/] [trunk/] [rtl/] [verilog/] [eth_fifo.v] - Blame information for rev 94

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

Line No. Rev Author Line
1 40 mohor
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  eth_fifo.v                                                  ////
4
////                                                              ////
5
////  This file is part of the Ethernet IP core project           ////
6
////  http://www.opencores.org/projects/ethmac/                   ////
7
////                                                              ////
8
////  Author(s):                                                  ////
9
////      - Igor Mohor (igorM@opencores.org)                      ////
10
////                                                              ////
11
////  All additional information is avaliable in the Readme.txt   ////
12
////  file.                                                       ////
13
////                                                              ////
14
//////////////////////////////////////////////////////////////////////
15
////                                                              ////
16
//// Copyright (C) 2001 Authors                                   ////
17
////                                                              ////
18
//// This source file may be used and distributed without         ////
19
//// restriction provided that this copyright statement is not    ////
20
//// removed from the file and that any derivative work contains  ////
21
//// the original copyright notice and the associated disclaimer. ////
22
////                                                              ////
23
//// This source file is free software; you can redistribute it   ////
24
//// and/or modify it under the terms of the GNU Lesser General   ////
25
//// Public License as published by the Free Software Foundation; ////
26
//// either version 2.1 of the License, or (at your option) any   ////
27
//// later version.                                               ////
28
////                                                              ////
29
//// This source is distributed in the hope that it will be       ////
30
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
31
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
32
//// PURPOSE.  See the GNU Lesser General Public License for more ////
33
//// details.                                                     ////
34
////                                                              ////
35
//// You should have received a copy of the GNU Lesser General    ////
36
//// Public License along with this source; if not, download it   ////
37
//// from http://www.opencores.org/lgpl.shtml                     ////
38
////                                                              ////
39
//////////////////////////////////////////////////////////////////////
40
//
41
// CVS Revision History
42
//
43
// $Log: not supported by cvs2svn $
44 94 mohor
// Revision 1.1  2002/02/05 16:44:39  mohor
45
// Both rx and tx part are finished. Tested with wb_clk_i between 10 and 200
46
// MHz. Statuses, overrun, control frame transmission and reception still  need
47
// to be fixed.
48 40 mohor
//
49 94 mohor
//
50 40 mohor
 
51
`include "timescale.v"
52
 
53
module eth_fifo (data_in, data_out, clk, reset, write, read, clear, almost_full, full, almost_empty, empty);
54
 
55
parameter DATA_WIDTH    = 32;
56
parameter DEPTH         = 8;
57
parameter CNT_WIDTH     = 4;
58
 
59
parameter Tp            = 1;
60
 
61
input                     clk;
62
input                     reset;
63
input                     write;
64
input                     read;
65
input                     clear;
66
input   [DATA_WIDTH-1:0]  data_in;
67
 
68
output  [DATA_WIDTH-1:0]  data_out;
69
output                    almost_full;
70
output                    full;
71
output                    almost_empty;
72
output                    empty;
73
 
74
reg     [DATA_WIDTH-1:0]  fifo  [0:DEPTH-1];
75
reg     [CNT_WIDTH-1:0]   cnt;
76
reg     [CNT_WIDTH-2:0]   read_pointer;
77
reg     [CNT_WIDTH-2:0]   write_pointer;
78
 
79
 
80
always @ (posedge clk or posedge reset)
81
begin
82
  if(reset)
83
    cnt <=#Tp 0;
84
  else
85
  if(clear)
86 94 mohor
    cnt <=#Tp { {(CNT_WIDTH-1){1'b0}}, read^write};
87 40 mohor
  else
88
  if(read ^ write)
89
    if(read)
90
      cnt <=#Tp cnt - 1'b1;
91
    else
92
      cnt <=#Tp cnt + 1'b1;
93
end
94
 
95
always @ (posedge clk or posedge reset)
96
begin
97
  if(reset)
98
    read_pointer <=#Tp 0;
99
  else
100
  if(clear)
101 94 mohor
    read_pointer <=#Tp { {(CNT_WIDTH-2){1'b0}}, read};
102 40 mohor
  else
103
  if(read & ~empty)
104
    read_pointer <=#Tp read_pointer + 1'b1;
105
end
106
 
107
always @ (posedge clk or posedge reset)
108
begin
109
  if(reset)
110
    write_pointer <=#Tp 0;
111
  else
112
  if(clear)
113 94 mohor
    write_pointer <=#Tp { {(CNT_WIDTH-2){1'b0}}, write};
114 40 mohor
  else
115
  if(write & ~full)
116
    write_pointer <=#Tp write_pointer + 1'b1;
117
end
118
 
119
assign empty = ~(|cnt);
120
assign almost_empty = cnt == 1;
121
assign full  = cnt == DEPTH;
122
assign almost_full  = &cnt[CNT_WIDTH-2:0];
123
 
124
always @ (posedge clk)
125
begin
126
  if(write & ~full)
127
    fifo[write_pointer] <=#Tp data_in;
128
end
129
 
130
assign data_out = fifo[read_pointer];
131
 
132
 
133
endmodule

powered by: WebSVN 2.1.0

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