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

Subversion Repositories ethmac

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

powered by: WebSVN 2.1.0

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