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

Subversion Repositories openrisc

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

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

Line No. Rev Author Line
1 6 julius
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  eth_txcounters.v                                            ////
4
////                                                              ////
5
////  This file is part of the Ethernet IP core project           ////
6 409 julius
////  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
// CVS Revision History
44
//
45 403 julius
// $Log: not supported by cvs2svn $
46 6 julius
// Revision 1.5  2002/04/22 14:54:14  mohor
47
// FCS should not be included in NibbleMinFl.
48
//
49
// Revision 1.4  2002/01/23 10:28:16  mohor
50
// Link in the header changed.
51
//
52
// Revision 1.3  2001/10/19 08:43:51  mohor
53
// eth_timescale.v changed to timescale.v This is done because of the
54
// simulation of the few cores in a one joined project.
55
//
56
// Revision 1.2  2001/09/11 14:17:00  mohor
57
// Few little NCSIM warnings fixed.
58
//
59
// Revision 1.1  2001/08/06 14:44:29  mohor
60
// A define FPGA added to select between Artisan RAM (for ASIC) and Block Ram (For Virtex).
61
// Include files fixed to contain no path.
62
// File names and module names changed ta have a eth_ prologue in the name.
63
// File eth_timescale.v is used to define timescale
64
// All pin names on the top module are changed to contain _I, _O or _OE at the end.
65
// Bidirectional signal MDIO is changed to three signals (Mdc_O, Mdi_I, Mdo_O
66
// and Mdo_OE. The bidirectional signal must be created on the top level. This
67
// is done due to the ASIC tools.
68
//
69
// Revision 1.1  2001/07/30 21:23:42  mohor
70
// Directory structure changed. Files checked and joind together.
71
//
72
// Revision 1.4  2001/06/27 21:27:45  mohor
73
// Few typos fixed.
74
//
75
// Revision 1.2  2001/06/19 10:38:07  mohor
76
// Minor changes in header.
77
//
78
// Revision 1.1  2001/06/19 10:27:57  mohor
79
// TxEthMAC initial release.
80
//
81
//
82
//
83
 
84
 
85
`include "timescale.v"
86
 
87
 
88
module eth_txcounters (StatePreamble, StateIPG, StateData, StatePAD, StateFCS, StateJam,
89
                       StateBackOff, StateDefer, StateIdle, StartDefer, StartIPG, StartFCS,
90
                       StartJam, StartBackoff, TxStartFrm, MTxClk, Reset, MinFL, MaxFL, HugEn,
91
                       ExDfrEn, PacketFinished_q, DlyCrcEn, StateSFD, ByteCnt, NibCnt,
92
                       ExcessiveDefer, NibCntEq7, NibCntEq15, MaxFrame, NibbleMinFl, DlyCrcCnt
93
                      );
94
 
95
parameter Tp = 1;
96
 
97
input MTxClk;             // Tx clock
98
input Reset;              // Reset
99
input StatePreamble;      // Preamble state
100
input StateIPG;           // IPG state
101
input [1:0] StateData;    // Data state
102
input StatePAD;           // PAD state
103
input StateFCS;           // FCS state
104
input StateJam;           // Jam state
105
input StateBackOff;       // Backoff state
106
input StateDefer;         // Defer state
107
input StateIdle;          // Idle state
108
input StateSFD;           // SFD state
109
input StartDefer;         // Defer state will be activated in next clock
110
input StartIPG;           // IPG state will be activated in next clock
111
input StartFCS;           // FCS state will be activated in next clock
112
input StartJam;           // Jam state will be activated in next clock
113
input StartBackoff;       // Backoff state will be activated in next clock
114
input TxStartFrm;         // Tx start frame
115
input [15:0] MinFL;       // Minimum frame length (in bytes)
116
input [15:0] MaxFL;       // Miximum frame length (in bytes)
117
input HugEn;              // Pakets bigger then MaxFL enabled
118
input ExDfrEn;            // Excessive deferral enabled
119
input PacketFinished_q;
120
input DlyCrcEn;           // Delayed CRC enabled
121
 
122
output [15:0] ByteCnt;    // Byte counter
123
output [15:0] NibCnt;     // Nibble counter
124
output ExcessiveDefer;    // Excessive Deferral occuring
125
output NibCntEq7;         // Nibble counter is equal to 7
126
output NibCntEq15;        // Nibble counter is equal to 15
127
output MaxFrame;          // Maximum frame occured
128
output NibbleMinFl;       // Nibble counter is greater than the minimum frame length
129
output [2:0] DlyCrcCnt;   // Delayed CRC Count
130
 
131
wire ExcessiveDeferCnt;
132
wire ResetNibCnt;
133
wire IncrementNibCnt;
134
wire ResetByteCnt;
135
wire IncrementByteCnt;
136
wire ByteCntMax;
137
 
138
reg [15:0] NibCnt;
139
reg [15:0] ByteCnt;
140
reg  [2:0] DlyCrcCnt;
141
 
142
 
143
 
144
assign IncrementNibCnt = StateIPG | StatePreamble | (|StateData) | StatePAD
145
                       | StateFCS | StateJam | StateBackOff | StateDefer & ~ExcessiveDefer & TxStartFrm;
146
 
147
 
148
assign ResetNibCnt = StateDefer & ExcessiveDefer & ~TxStartFrm | StatePreamble & NibCntEq15
149
                   | StateJam & NibCntEq7 | StateIdle | StartDefer | StartIPG | StartFCS | StartJam;
150
 
151
// Nibble Counter
152
always @ (posedge MTxClk or posedge Reset)
153
begin
154
  if(Reset)
155 403 julius
    NibCnt <=  16'h0;
156 6 julius
  else
157
    begin
158
      if(ResetNibCnt)
159 403 julius
        NibCnt <=  16'h0;
160 6 julius
      else
161
      if(IncrementNibCnt)
162 439 julius
        NibCnt <=  NibCnt + 16'd1;
163 6 julius
     end
164
end
165
 
166
 
167
assign NibCntEq7   = &NibCnt[2:0];
168
assign NibCntEq15  = &NibCnt[3:0];
169
 
170 439 julius
assign NibbleMinFl = NibCnt >= (((MinFL-16'd4)<<1) -1);  // FCS should not be included in NibbleMinFl
171 6 julius
 
172 439 julius
assign ExcessiveDeferCnt = NibCnt[13:0] == 14'h17b7;
173 6 julius
 
174 439 julius
assign ExcessiveDefer  = NibCnt[13:0] == 14'h17b7 & ~ExDfrEn;   // 6071 nibbles
175 6 julius
 
176
assign IncrementByteCnt = StateData[1] & ~ByteCntMax
177
                        | StateBackOff & (&NibCnt[6:0])
178
                        | (StatePAD | StateFCS) & NibCnt[0] & ~ByteCntMax;
179
 
180
assign ResetByteCnt = StartBackoff | StateIdle & TxStartFrm | PacketFinished_q;
181
 
182
 
183
// Transmit Byte Counter
184
always @ (posedge MTxClk or posedge Reset)
185
begin
186
  if(Reset)
187 403 julius
    ByteCnt[15:0] <=  16'h0;
188 6 julius
  else
189
    begin
190
      if(ResetByteCnt)
191 403 julius
        ByteCnt[15:0] <=  16'h0;
192 6 julius
      else
193
      if(IncrementByteCnt)
194 439 julius
        ByteCnt[15:0] <=  ByteCnt[15:0] + 16'd1;
195 6 julius
    end
196
end
197
 
198
 
199
assign MaxFrame = ByteCnt[15:0] == MaxFL[15:0] & ~HugEn;
200
 
201
assign ByteCntMax = &ByteCnt[15:0];
202
 
203
 
204
// Delayed CRC counter
205
always @ (posedge MTxClk or posedge Reset)
206
begin
207
  if(Reset)
208 403 julius
    DlyCrcCnt <=  3'h0;
209 6 julius
  else
210
    begin
211
      if(StateData[1] & DlyCrcCnt == 3'h4 | StartJam | PacketFinished_q)
212 403 julius
        DlyCrcCnt <=  3'h0;
213 6 julius
      else
214
      if(DlyCrcEn & (StateSFD | StateData[1] & (|DlyCrcCnt[2:0])))
215 439 julius
        DlyCrcCnt <=  DlyCrcCnt + 3'd1;
216 6 julius
    end
217
end
218
 
219
 
220
 
221
endmodule

powered by: WebSVN 2.1.0

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