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

Subversion Repositories ethmac

[/] [ethmac/] [trunk/] [rtl/] [verilog/] [eth_rxcounters.v] - Blame information for rev 352

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

Line No. Rev Author Line
1 15 mohor
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  eth_rxcounters.v                                            ////
4
////                                                              ////
5
////  This file is part of the Ethernet IP core project           ////
6 346 olof
////  http://www.opencores.org/project,ethmac                     ////
7 15 mohor
////                                                              ////
8
////  Author(s):                                                  ////
9
////      - Igor Mohor (igorM@opencores.org)                      ////
10
////      - Novan Hartadi (novan@vlsi.itb.ac.id)                  ////
11
////      - Mahmud Galela (mgalela@vlsi.itb.ac.id)                ////
12
////                                                              ////
13
////  All additional information is avaliable in the Readme.txt   ////
14
////  file.                                                       ////
15
////                                                              ////
16
//////////////////////////////////////////////////////////////////////
17
////                                                              ////
18
//// Copyright (C) 2001 Authors                                   ////
19
////                                                              ////
20
//// This source file may be used and distributed without         ////
21
//// restriction provided that this copyright statement is not    ////
22
//// removed from the file and that any derivative work contains  ////
23
//// the original copyright notice and the associated disclaimer. ////
24
////                                                              ////
25
//// This source file is free software; you can redistribute it   ////
26
//// and/or modify it under the terms of the GNU Lesser General   ////
27
//// Public License as published by the Free Software Foundation; ////
28
//// either version 2.1 of the License, or (at your option) any   ////
29
//// later version.                                               ////
30
////                                                              ////
31
//// This source is distributed in the hope that it will be       ////
32
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
33
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
34
//// PURPOSE.  See the GNU Lesser General Public License for more ////
35
//// details.                                                     ////
36
////                                                              ////
37
//// You should have received a copy of the GNU Lesser General    ////
38
//// Public License along with this source; if not, download it   ////
39
//// from http://www.opencores.org/lgpl.shtml                     ////
40
////                                                              ////
41
//////////////////////////////////////////////////////////////////////
42
//
43
// CVS Revision History
44
//
45
// $Log: not supported by cvs2svn $
46 326 igorm
// Revision 1.5  2002/02/15 11:13:29  mohor
47
// Format of the file changed a bit.
48
//
49 57 mohor
// Revision 1.4  2002/02/14 20:19:41  billditt
50
// Modified for Address Checking,
51
// addition of eth_addrcheck.v
52
//
53 52 billditt
// Revision 1.3  2002/01/23 10:28:16  mohor
54
// Link in the header changed.
55
//
56 37 mohor
// Revision 1.2  2001/10/19 08:43:51  mohor
57
// eth_timescale.v changed to timescale.v This is done because of the
58
// simulation of the few cores in a one joined project.
59
//
60 22 mohor
// Revision 1.1  2001/08/06 14:44:29  mohor
61
// A define FPGA added to select between Artisan RAM (for ASIC) and Block Ram (For Virtex).
62
// Include files fixed to contain no path.
63
// File names and module names changed ta have a eth_ prologue in the name.
64
// File eth_timescale.v is used to define timescale
65
// All pin names on the top module are changed to contain _I, _O or _OE at the end.
66
// Bidirectional signal MDIO is changed to three signals (Mdc_O, Mdi_I, Mdo_O
67
// and Mdo_OE. The bidirectional signal must be created on the top level. This
68
// is done due to the ASIC tools.
69
//
70 15 mohor
// Revision 1.1  2001/07/30 21:23:42  mohor
71
// Directory structure changed. Files checked and joind together.
72
//
73
// Revision 1.1  2001/06/27 21:26:19  mohor
74
// Initial release of the RxEthMAC module.
75
//
76
//
77
//
78
//
79
//
80
//
81
 
82
 
83 22 mohor
`include "timescale.v"
84 15 mohor
 
85
 
86
module eth_rxcounters (MRxClk, Reset, MRxDV, StateIdle, StateSFD, StateData, StateDrop, StatePreamble,
87
                       MRxDEqD, DlyCrcEn, DlyCrcCnt, Transmitting, MaxFL, r_IFG, HugEn, IFGCounterEq24,
88 57 mohor
                       ByteCntEq0, ByteCntEq1, ByteCntEq2,ByteCntEq3,ByteCntEq4,ByteCntEq5, ByteCntEq6,
89 326 igorm
                       ByteCntEq7, ByteCntGreat2, ByteCntSmall7, ByteCntMaxFrame, ByteCntOut
90 15 mohor
                      );
91
 
92
input         MRxClk;
93
input         Reset;
94
input         MRxDV;
95
input         StateSFD;
96
input [1:0]   StateData;
97
input         MRxDEqD;
98
input         StateIdle;
99
input         StateDrop;
100
input         DlyCrcEn;
101
input         StatePreamble;
102
input         Transmitting;
103
input         HugEn;
104
input [15:0]  MaxFL;
105
input         r_IFG;
106
 
107
output        IFGCounterEq24;           // IFG counter reaches 9600 ns (960 ns)
108
output [3:0]  DlyCrcCnt;                // Delayed CRC counter
109
output        ByteCntEq0;               // Byte counter = 0
110
output        ByteCntEq1;               // Byte counter = 1
111 52 billditt
output        ByteCntEq2;               // Byte counter = 2  
112
output        ByteCntEq3;               // Byte counter = 3  
113
output        ByteCntEq4;               // Byte counter = 4  
114
output        ByteCntEq5;               // Byte counter = 5  
115 15 mohor
output        ByteCntEq6;               // Byte counter = 6
116 52 billditt
output        ByteCntEq7;               // Byte counter = 7
117 15 mohor
output        ByteCntGreat2;            // Byte counter > 2
118
output        ByteCntSmall7;            // Byte counter < 7
119
output        ByteCntMaxFrame;          // Byte counter = MaxFL
120 326 igorm
output [15:0] ByteCntOut;               // Byte counter
121 15 mohor
 
122
wire          ResetByteCounter;
123
wire          IncrementByteCounter;
124
wire          ResetIFGCounter;
125
wire          IncrementIFGCounter;
126
wire          ByteCntMax;
127
 
128
reg   [15:0]  ByteCnt;
129
reg   [3:0]   DlyCrcCnt;
130
reg   [4:0]   IFGCounter;
131
 
132 326 igorm
wire  [15:0]  ByteCntDelayed;
133 15 mohor
 
134
 
135 326 igorm
 
136 15 mohor
assign ResetByteCounter = MRxDV & (StateSFD & MRxDEqD | StateData[0] & ByteCntMaxFrame);
137
 
138
assign IncrementByteCounter = ~ResetByteCounter & MRxDV &
139
                              (StatePreamble | StateSFD | StateIdle & ~Transmitting |
140
                               StateData[1] & ~ByteCntMax & ~(DlyCrcEn & |DlyCrcCnt)
141
                              );
142
 
143
 
144
always @ (posedge MRxClk or posedge Reset)
145
begin
146
  if(Reset)
147 352 olof
    ByteCnt[15:0] <=  16'h0;
148 15 mohor
  else
149
    begin
150
      if(ResetByteCounter)
151 352 olof
        ByteCnt[15:0] <=  16'h0;
152 15 mohor
      else
153
      if(IncrementByteCounter)
154 352 olof
        ByteCnt[15:0] <=  ByteCnt[15:0] + 1'b1;
155 15 mohor
     end
156
end
157
 
158 326 igorm
assign ByteCntDelayed = ByteCnt + 3'h4;
159
assign ByteCntOut = DlyCrcEn? ByteCntDelayed : ByteCnt;
160
 
161 15 mohor
assign ByteCntEq0       = ByteCnt == 16'h0;
162
assign ByteCntEq1       = ByteCnt == 16'h1;
163 52 billditt
assign ByteCntEq2       = ByteCnt == 16'h2;
164
assign ByteCntEq3       = ByteCnt == 16'h3;
165
assign ByteCntEq4       = ByteCnt == 16'h4;
166
assign ByteCntEq5       = ByteCnt == 16'h5;
167 15 mohor
assign ByteCntEq6       = ByteCnt == 16'h6;
168 52 billditt
assign ByteCntEq7       = ByteCnt == 16'h7;
169 15 mohor
assign ByteCntGreat2    = ByteCnt >  16'h2;
170
assign ByteCntSmall7    = ByteCnt <  16'h7;
171
assign ByteCntMax       = ByteCnt == 16'hffff;
172
assign ByteCntMaxFrame  = ByteCnt == MaxFL[15:0] & ~HugEn;
173
 
174
 
175
assign ResetIFGCounter = StateSFD  &  MRxDV & MRxDEqD | StateDrop;
176
 
177
assign IncrementIFGCounter = ~ResetIFGCounter & (StateDrop | StateIdle | StatePreamble | StateSFD) & ~IFGCounterEq24;
178
 
179
always @ (posedge MRxClk or posedge Reset)
180
begin
181
  if(Reset)
182 352 olof
    IFGCounter[4:0] <=  5'h0;
183 15 mohor
  else
184
    begin
185
      if(ResetIFGCounter)
186 352 olof
        IFGCounter[4:0] <=  5'h0;
187 15 mohor
      else
188
      if(IncrementIFGCounter)
189 352 olof
        IFGCounter[4:0] <=  IFGCounter[4:0] + 1'b1;
190 15 mohor
    end
191
end
192
 
193
 
194
 
195
assign IFGCounterEq24 = (IFGCounter[4:0] == 5'h18) | r_IFG; // 24*400 = 9600 ns or r_IFG is set to 1
196
 
197
 
198
always @ (posedge MRxClk or posedge Reset)
199
begin
200
  if(Reset)
201 352 olof
    DlyCrcCnt[3:0] <=  4'h0;
202 15 mohor
  else
203
    begin
204
      if(DlyCrcCnt[3:0] == 4'h9)
205 352 olof
        DlyCrcCnt[3:0] <=  4'h0;
206 15 mohor
      else
207
      if(DlyCrcEn & StateSFD)
208 352 olof
        DlyCrcCnt[3:0] <=  4'h1;
209 15 mohor
      else
210
      if(DlyCrcEn & (|DlyCrcCnt[3:0]))
211 352 olof
        DlyCrcCnt[3:0] <=  DlyCrcCnt[3:0] + 1'b1;
212 15 mohor
    end
213
end
214
 
215
 
216
endmodule

powered by: WebSVN 2.1.0

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