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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [rtl/] [verilog/] [ethmac/] [eth_rxcounters.v] - Blame information for rev 803

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 julius
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  eth_rxcounters.v                                            ////
4
////                                                              ////
5
////  This file is part of the Ethernet IP core project           ////
6 570 olof
////  http://www.opencores.org/project,ethmac                     ////
7 6 julius
////                                                              ////
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
`include "timescale.v"
44
 
45
 
46 439 julius
module eth_rxcounters
47
  (
48
   MRxClk, Reset, MRxDV, StateIdle, StateSFD, StateData, StateDrop, StatePreamble,
49
   MRxDEqD, DlyCrcEn, DlyCrcCnt, Transmitting, MaxFL, r_IFG, HugEn, IFGCounterEq24,
50
   ByteCntEq0, ByteCntEq1, ByteCntEq2,ByteCntEq3,ByteCntEq4,ByteCntEq5, ByteCntEq6,
51
   ByteCntEq7, ByteCntGreat2, ByteCntSmall7, ByteCntMaxFrame, ByteCntOut
52
   );
53 6 julius
 
54
input         MRxClk;
55
input         Reset;
56
input         MRxDV;
57
input         StateSFD;
58
input [1:0]   StateData;
59
input         MRxDEqD;
60
input         StateIdle;
61
input         StateDrop;
62
input         DlyCrcEn;
63
input         StatePreamble;
64
input         Transmitting;
65
input         HugEn;
66
input [15:0]  MaxFL;
67
input         r_IFG;
68
 
69
output        IFGCounterEq24;           // IFG counter reaches 9600 ns (960 ns)
70
output [3:0]  DlyCrcCnt;                // Delayed CRC counter
71
output        ByteCntEq0;               // Byte counter = 0
72
output        ByteCntEq1;               // Byte counter = 1
73
output        ByteCntEq2;               // Byte counter = 2  
74
output        ByteCntEq3;               // Byte counter = 3  
75
output        ByteCntEq4;               // Byte counter = 4  
76
output        ByteCntEq5;               // Byte counter = 5  
77
output        ByteCntEq6;               // Byte counter = 6
78
output        ByteCntEq7;               // Byte counter = 7
79
output        ByteCntGreat2;            // Byte counter > 2
80
output        ByteCntSmall7;            // Byte counter < 7
81
output        ByteCntMaxFrame;          // Byte counter = MaxFL
82
output [15:0] ByteCntOut;               // Byte counter
83
 
84
wire          ResetByteCounter;
85
wire          IncrementByteCounter;
86
wire          ResetIFGCounter;
87
wire          IncrementIFGCounter;
88
wire          ByteCntMax;
89
 
90
reg   [15:0]  ByteCnt;
91
reg   [3:0]   DlyCrcCnt;
92
reg   [4:0]   IFGCounter;
93
 
94
wire  [15:0]  ByteCntDelayed;
95
 
96
 
97
 
98
assign ResetByteCounter = MRxDV & (StateSFD & MRxDEqD | StateData[0] & ByteCntMaxFrame);
99
 
100
assign IncrementByteCounter = ~ResetByteCounter & MRxDV &
101
                              (StatePreamble | StateSFD | StateIdle & ~Transmitting |
102
                               StateData[1] & ~ByteCntMax & ~(DlyCrcEn & |DlyCrcCnt)
103
                              );
104
 
105
 
106
always @ (posedge MRxClk or posedge Reset)
107
begin
108
  if(Reset)
109 439 julius
    ByteCnt[15:0] <=  16'd0;
110 6 julius
  else
111
    begin
112
      if(ResetByteCounter)
113 439 julius
        ByteCnt[15:0] <=  16'd0;
114 6 julius
      else
115
      if(IncrementByteCounter)
116 439 julius
        ByteCnt[15:0] <=  ByteCnt[15:0] + 16'd1;
117 6 julius
     end
118
end
119
 
120 439 julius
assign ByteCntDelayed = ByteCnt + 16'd4;
121
assign ByteCntOut = DlyCrcEn ? ByteCntDelayed : ByteCnt;
122 6 julius
 
123 439 julius
assign ByteCntEq0       = ByteCnt == 16'd0;
124
assign ByteCntEq1       = ByteCnt == 16'd1;
125
assign ByteCntEq2       = ByteCnt == 16'd2;
126
assign ByteCntEq3       = ByteCnt == 16'd3;
127
assign ByteCntEq4       = ByteCnt == 16'd4;
128
assign ByteCntEq5       = ByteCnt == 16'd5;
129
assign ByteCntEq6       = ByteCnt == 16'd6;
130
assign ByteCntEq7       = ByteCnt == 16'd7;
131
assign ByteCntGreat2    = ByteCnt >  16'd2;
132
assign ByteCntSmall7    = ByteCnt <  16'd7;
133 6 julius
assign ByteCntMax       = ByteCnt == 16'hffff;
134
assign ByteCntMaxFrame  = ByteCnt == MaxFL[15:0] & ~HugEn;
135
 
136
 
137
assign ResetIFGCounter = StateSFD  &  MRxDV & MRxDEqD | StateDrop;
138
 
139
assign IncrementIFGCounter = ~ResetIFGCounter & (StateDrop | StateIdle | StatePreamble | StateSFD) & ~IFGCounterEq24;
140
 
141
always @ (posedge MRxClk or posedge Reset)
142
begin
143
  if(Reset)
144 403 julius
    IFGCounter[4:0] <=  5'h0;
145 6 julius
  else
146
    begin
147
      if(ResetIFGCounter)
148 403 julius
        IFGCounter[4:0] <=  5'h0;
149 6 julius
      else
150
      if(IncrementIFGCounter)
151 439 julius
        IFGCounter[4:0] <=  IFGCounter[4:0] + 5'd1;
152 6 julius
    end
153
end
154
 
155
 
156
 
157
assign IFGCounterEq24 = (IFGCounter[4:0] == 5'h18) | r_IFG; // 24*400 = 9600 ns or r_IFG is set to 1
158
 
159
 
160
always @ (posedge MRxClk or posedge Reset)
161
begin
162
  if(Reset)
163 403 julius
    DlyCrcCnt[3:0] <=  4'h0;
164 6 julius
  else
165
    begin
166
      if(DlyCrcCnt[3:0] == 4'h9)
167 403 julius
        DlyCrcCnt[3:0] <=  4'h0;
168 6 julius
      else
169
      if(DlyCrcEn & StateSFD)
170 403 julius
        DlyCrcCnt[3:0] <=  4'h1;
171 6 julius
      else
172
      if(DlyCrcEn & (|DlyCrcCnt[3:0]))
173 439 julius
        DlyCrcCnt[3:0] <=  DlyCrcCnt[3:0] + 4'd1;
174 6 julius
    end
175
end
176
 
177
 
178
endmodule

powered by: WebSVN 2.1.0

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