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

Subversion Repositories ethmac

[/] [ethmac/] [tags/] [rel_17/] [rtl/] [verilog/] [eth_rxcounters.v] - Blame information for rev 37

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

powered by: WebSVN 2.1.0

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