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

Subversion Repositories ethmac

[/] [ethmac/] [tags/] [rel_14/] [rtl/] [verilog/] [eth_txcounters.v] - Blame information for rev 37

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

powered by: WebSVN 2.1.0

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