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

Subversion Repositories ethmac

[/] [ethmac/] [tags/] [rel_19/] [rtl/] [verilog/] [eth_rxcounters.v] - Blame information for rev 338

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 37 mohor
////  http://www.opencores.org/projects/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 57 mohor
// Revision 1.4  2002/02/14 20:19:41  billditt
47
// Modified for Address Checking,
48
// addition of eth_addrcheck.v
49
//
50 52 billditt
// Revision 1.3  2002/01/23 10:28:16  mohor
51
// Link in the header changed.
52
//
53 37 mohor
// Revision 1.2  2001/10/19 08:43:51  mohor
54
// eth_timescale.v changed to timescale.v This is done because of the
55
// simulation of the few cores in a one joined project.
56
//
57 22 mohor
// Revision 1.1  2001/08/06 14:44:29  mohor
58
// A define FPGA added to select between Artisan RAM (for ASIC) and Block Ram (For Virtex).
59
// Include files fixed to contain no path.
60
// File names and module names changed ta have a eth_ prologue in the name.
61
// File eth_timescale.v is used to define timescale
62
// All pin names on the top module are changed to contain _I, _O or _OE at the end.
63
// Bidirectional signal MDIO is changed to three signals (Mdc_O, Mdi_I, Mdo_O
64
// and Mdo_OE. The bidirectional signal must be created on the top level. This
65
// is done due to the ASIC tools.
66
//
67 15 mohor
// Revision 1.1  2001/07/30 21:23:42  mohor
68
// Directory structure changed. Files checked and joind together.
69
//
70
// Revision 1.1  2001/06/27 21:26:19  mohor
71
// Initial release of the RxEthMAC module.
72
//
73
//
74
//
75
//
76
//
77
//
78
 
79
 
80 22 mohor
`include "timescale.v"
81 15 mohor
 
82
 
83
module eth_rxcounters (MRxClk, Reset, MRxDV, StateIdle, StateSFD, StateData, StateDrop, StatePreamble,
84
                       MRxDEqD, DlyCrcEn, DlyCrcCnt, Transmitting, MaxFL, r_IFG, HugEn, IFGCounterEq24,
85 57 mohor
                       ByteCntEq0, ByteCntEq1, ByteCntEq2,ByteCntEq3,ByteCntEq4,ByteCntEq5, ByteCntEq6,
86
                       ByteCntEq7, ByteCntGreat2, ByteCntSmall7, ByteCntMaxFrame, ByteCnt
87 15 mohor
                      );
88
 
89
parameter Tp = 1;
90
 
91
input         MRxClk;
92
input         Reset;
93
input         MRxDV;
94
input         StateSFD;
95
input [1:0]   StateData;
96
input         MRxDEqD;
97
input         StateIdle;
98
input         StateDrop;
99
input         DlyCrcEn;
100
input         StatePreamble;
101
input         Transmitting;
102
input         HugEn;
103
input [15:0]  MaxFL;
104
input         r_IFG;
105
 
106
output        IFGCounterEq24;           // IFG counter reaches 9600 ns (960 ns)
107
output [3:0]  DlyCrcCnt;                // Delayed CRC counter
108
output        ByteCntEq0;               // Byte counter = 0
109
output        ByteCntEq1;               // Byte counter = 1
110 52 billditt
output        ByteCntEq2;               // Byte counter = 2  
111
output        ByteCntEq3;               // Byte counter = 3  
112
output        ByteCntEq4;               // Byte counter = 4  
113
output        ByteCntEq5;               // Byte counter = 5  
114 15 mohor
output        ByteCntEq6;               // Byte counter = 6
115 52 billditt
output        ByteCntEq7;               // Byte counter = 7
116 15 mohor
output        ByteCntGreat2;            // Byte counter > 2
117
output        ByteCntSmall7;            // Byte counter < 7
118
output        ByteCntMaxFrame;          // Byte counter = MaxFL
119
output [15:0] ByteCnt;                  // Byte counter
120
 
121
wire          ResetByteCounter;
122
wire          IncrementByteCounter;
123
wire          ResetIFGCounter;
124
wire          IncrementIFGCounter;
125
wire          ByteCntMax;
126
 
127
reg   [15:0]  ByteCnt;
128
reg   [3:0]   DlyCrcCnt;
129
reg   [4:0]   IFGCounter;
130
 
131
 
132
 
133
assign ResetByteCounter = MRxDV & (StateSFD & MRxDEqD | StateData[0] & ByteCntMaxFrame);
134
 
135
assign IncrementByteCounter = ~ResetByteCounter & MRxDV &
136
                              (StatePreamble | StateSFD | StateIdle & ~Transmitting |
137
                               StateData[1] & ~ByteCntMax & ~(DlyCrcEn & |DlyCrcCnt)
138
                              );
139
 
140
 
141
always @ (posedge MRxClk or posedge Reset)
142
begin
143
  if(Reset)
144
    ByteCnt[15:0] <= #Tp 11'h0;
145
  else
146
    begin
147
      if(ResetByteCounter)
148
        ByteCnt[15:0] <= #Tp 11'h0;
149
      else
150
      if(IncrementByteCounter)
151
        ByteCnt[15:0] <= #Tp ByteCnt[15:0] + 1'b1;
152
     end
153
end
154
 
155
assign ByteCntEq0       = ByteCnt == 16'h0;
156
assign ByteCntEq1       = ByteCnt == 16'h1;
157 52 billditt
assign ByteCntEq2       = ByteCnt == 16'h2;
158
assign ByteCntEq3       = ByteCnt == 16'h3;
159
assign ByteCntEq4       = ByteCnt == 16'h4;
160
assign ByteCntEq5       = ByteCnt == 16'h5;
161 15 mohor
assign ByteCntEq6       = ByteCnt == 16'h6;
162 52 billditt
assign ByteCntEq7       = ByteCnt == 16'h7;
163 15 mohor
assign ByteCntGreat2    = ByteCnt >  16'h2;
164
assign ByteCntSmall7    = ByteCnt <  16'h7;
165
assign ByteCntMax       = ByteCnt == 16'hffff;
166
assign ByteCntMaxFrame  = ByteCnt == MaxFL[15:0] & ~HugEn;
167
 
168
 
169
 
170
assign ResetIFGCounter = StateSFD  &  MRxDV & MRxDEqD | StateDrop;
171
 
172
assign IncrementIFGCounter = ~ResetIFGCounter & (StateDrop | StateIdle | StatePreamble | StateSFD) & ~IFGCounterEq24;
173
 
174
always @ (posedge MRxClk or posedge Reset)
175
begin
176
  if(Reset)
177
    IFGCounter[4:0] <= #Tp 5'h0;
178
  else
179
    begin
180
      if(ResetIFGCounter)
181
        IFGCounter[4:0] <= #Tp 5'h0;
182
      else
183
      if(IncrementIFGCounter)
184
        IFGCounter[4:0] <= #Tp IFGCounter[4:0] + 1'b1;
185
    end
186
end
187
 
188
 
189
 
190
assign IFGCounterEq24 = (IFGCounter[4:0] == 5'h18) | r_IFG; // 24*400 = 9600 ns or r_IFG is set to 1
191
 
192
 
193
always @ (posedge MRxClk or posedge Reset)
194
begin
195
  if(Reset)
196
    DlyCrcCnt[3:0] <= #Tp 4'h0;
197
  else
198
    begin
199
      if(DlyCrcCnt[3:0] == 4'h9)
200
        DlyCrcCnt[3:0] <= #Tp 4'h0;
201
      else
202
      if(DlyCrcEn & StateSFD)
203
        DlyCrcCnt[3:0] <= #Tp 4'h1;
204
      else
205
      if(DlyCrcEn & (|DlyCrcCnt[3:0]))
206
        DlyCrcCnt[3:0] <= #Tp DlyCrcCnt[3:0] + 1'b1;
207
    end
208
end
209
 
210
 
211
endmodule

powered by: WebSVN 2.1.0

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