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 15

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
// Revision 1.1  2001/07/30 21:23:42  mohor
47
// Directory structure changed. Files checked and joind together.
48
//
49
// Revision 1.1  2001/06/27 21:26:19  mohor
50
// Initial release of the RxEthMAC module.
51
//
52
//
53
//
54
//
55
//
56
//
57
 
58
 
59
`include "eth_timescale.v"
60
 
61
 
62
module eth_rxcounters (MRxClk, Reset, MRxDV, StateIdle, StateSFD, StateData, StateDrop, StatePreamble,
63
                       MRxDEqD, DlyCrcEn, DlyCrcCnt, Transmitting, MaxFL, r_IFG, HugEn, IFGCounterEq24,
64
                       ByteCntEq0, ByteCntEq1, ByteCntEq6, ByteCntGreat2, ByteCntSmall7, ByteCntMaxFrame,
65
                       ByteCnt
66
                      );
67
 
68
parameter Tp = 1;
69
 
70
input         MRxClk;
71
input         Reset;
72
input         MRxDV;
73
input         StateSFD;
74
input [1:0]   StateData;
75
input         MRxDEqD;
76
input         StateIdle;
77
input         StateDrop;
78
input         DlyCrcEn;
79
input         StatePreamble;
80
input         Transmitting;
81
input         HugEn;
82
input [15:0]  MaxFL;
83
input         r_IFG;
84
 
85
output        IFGCounterEq24;           // IFG counter reaches 9600 ns (960 ns)
86
output [3:0]  DlyCrcCnt;                // Delayed CRC counter
87
output        ByteCntEq0;               // Byte counter = 0
88
output        ByteCntEq1;               // Byte counter = 1
89
output        ByteCntEq6;               // Byte counter = 6
90
output        ByteCntGreat2;            // Byte counter > 2
91
output        ByteCntSmall7;            // Byte counter < 7
92
output        ByteCntMaxFrame;          // Byte counter = MaxFL
93
output [15:0] ByteCnt;                  // Byte counter
94
 
95
wire          ResetByteCounter;
96
wire          IncrementByteCounter;
97
wire          ResetIFGCounter;
98
wire          IncrementIFGCounter;
99
wire          ByteCntMax;
100
 
101
reg   [15:0]  ByteCnt;
102
reg   [3:0]   DlyCrcCnt;
103
reg   [4:0]   IFGCounter;
104
 
105
 
106
 
107
assign ResetByteCounter = MRxDV & (StateSFD & MRxDEqD | StateData[0] & ByteCntMaxFrame);
108
 
109
assign IncrementByteCounter = ~ResetByteCounter & MRxDV &
110
                              (StatePreamble | StateSFD | StateIdle & ~Transmitting |
111
                               StateData[1] & ~ByteCntMax & ~(DlyCrcEn & |DlyCrcCnt)
112
                              );
113
 
114
 
115
always @ (posedge MRxClk or posedge Reset)
116
begin
117
  if(Reset)
118
    ByteCnt[15:0] <= #Tp 11'h0;
119
  else
120
    begin
121
      if(ResetByteCounter)
122
        ByteCnt[15:0] <= #Tp 11'h0;
123
      else
124
      if(IncrementByteCounter)
125
        ByteCnt[15:0] <= #Tp ByteCnt[15:0] + 1'b1;
126
     end
127
end
128
 
129
assign ByteCntEq0       = ByteCnt == 16'h0;
130
assign ByteCntEq1       = ByteCnt == 16'h1;
131
assign ByteCntEq6       = ByteCnt == 16'h6;
132
assign ByteCntGreat2    = ByteCnt >  16'h2;
133
assign ByteCntSmall7    = ByteCnt <  16'h7;
134
assign ByteCntMax       = ByteCnt == 16'hffff;
135
assign ByteCntMaxFrame  = ByteCnt == MaxFL[15:0] & ~HugEn;
136
 
137
 
138
 
139
assign ResetIFGCounter = StateSFD  &  MRxDV & MRxDEqD | StateDrop;
140
 
141
assign IncrementIFGCounter = ~ResetIFGCounter & (StateDrop | StateIdle | StatePreamble | StateSFD) & ~IFGCounterEq24;
142
 
143
always @ (posedge MRxClk or posedge Reset)
144
begin
145
  if(Reset)
146
    IFGCounter[4:0] <= #Tp 5'h0;
147
  else
148
    begin
149
      if(ResetIFGCounter)
150
        IFGCounter[4:0] <= #Tp 5'h0;
151
      else
152
      if(IncrementIFGCounter)
153
        IFGCounter[4:0] <= #Tp IFGCounter[4:0] + 1'b1;
154
    end
155
end
156
 
157
 
158
 
159
assign IFGCounterEq24 = (IFGCounter[4:0] == 5'h18) | r_IFG; // 24*400 = 9600 ns or r_IFG is set to 1
160
 
161
 
162
always @ (posedge MRxClk or posedge Reset)
163
begin
164
  if(Reset)
165
    DlyCrcCnt[3:0] <= #Tp 4'h0;
166
  else
167
    begin
168
      if(DlyCrcCnt[3:0] == 4'h9)
169
        DlyCrcCnt[3:0] <= #Tp 4'h0;
170
      else
171
      if(DlyCrcEn & StateSFD)
172
        DlyCrcCnt[3:0] <= #Tp 4'h1;
173
      else
174
      if(DlyCrcEn & (|DlyCrcCnt[3:0]))
175
        DlyCrcCnt[3:0] <= #Tp DlyCrcCnt[3:0] + 1'b1;
176
    end
177
end
178
 
179
 
180
endmodule

powered by: WebSVN 2.1.0

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