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

Subversion Repositories ethmac

[/] [ethmac/] [tags/] [rel_7/] [rtl/] [verilog/] [eth_rxcounters.v] - Blame information for rev 52

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

powered by: WebSVN 2.1.0

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