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 22

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

powered by: WebSVN 2.1.0

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