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 15

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
// Revision 1.1  2001/07/30 21:23:42  mohor
47
// Directory structure changed. Files checked and joind together.
48
//
49
// Revision 1.4  2001/06/27 21:27:45  mohor
50
// Few typos fixed.
51
//
52
// Revision 1.2  2001/06/19 10:38:07  mohor
53
// Minor changes in header.
54
//
55
// Revision 1.1  2001/06/19 10:27:57  mohor
56
// TxEthMAC initial release.
57
//
58
//
59
//
60
 
61
 
62
`include "eth_timescale.v"
63
 
64
 
65
module eth_txcounters (StatePreamble, StateIPG, StateData, StatePAD, StateFCS, StateJam,
66
                       StateBackOff, StateDefer, StateIdle, StartDefer, StartIPG, StartFCS,
67
                       StartJam, StartBackoff, TxStartFrm, MTxClk, Reset, MinFL, MaxFL, HugEn,
68
                       ExDfrEn, PacketFinished_q, DlyCrcEn, StateSFD, ByteCnt, NibCnt,
69
                       ExcessiveDefer, NibCntEq7, NibCntEq15, MaxFrame, NibbleMinFl, DlyCrcCnt
70
                      );
71
 
72
parameter Tp = 1;
73
 
74
input MTxClk;             // Tx clock
75
input Reset;              // Reset
76
input StatePreamble;      // Preamble state
77
input StateIPG;           // IPG state
78
input [1:0] StateData;    // Data state
79
input StatePAD;           // PAD state
80
input StateFCS;           // FCS state
81
input StateJam;           // Jam state
82
input StateBackOff;       // Backoff state
83
input StateDefer;         // Defer state
84
input StateIdle;          // Idle state
85
input StateSFD;           // SFD state
86
input StartDefer;         // Defer state will be activated in next clock
87
input StartIPG;           // IPG state will be activated in next clock
88
input StartFCS;           // FCS state will be activated in next clock
89
input StartJam;           // Jam state will be activated in next clock
90
input StartBackoff;       // Backoff state will be activated in next clock
91
input TxStartFrm;         // Tx start frame
92
input [15:0] MinFL;       // Minimum frame length (in bytes)
93
input [15:0] MaxFL;       // Miximum frame length (in bytes)
94
input HugEn;              // Pakets bigger then MaxFL enabled
95
input ExDfrEn;            // Excessive deferral enabled
96
input PacketFinished_q;
97
input DlyCrcEn;           // Delayed CRC enabled
98
 
99
output [15:0] ByteCnt;    // Byte counter
100
output [15:0] NibCnt;     // Nibble counter
101
output ExcessiveDefer;    // Excessive Deferral occuring
102
output NibCntEq7;         // Nibble counter is equal to 7
103
output NibCntEq15;        // Nibble counter is equal to 15
104
output MaxFrame;          // Maximum frame occured
105
output NibbleMinFl;       // Nibble counter is greater than the minimum frame length
106
output [2:0] DlyCrcCnt;   // Delayed CRC Count
107
 
108
wire ExcessiveDeferCnt;
109
wire ResetNibCnt;
110
wire IncrementNibCnt;
111
wire ResetByteCnt;
112
wire IncrementByteCnt;
113
wire ByteCntMax;
114
 
115
reg [15:0] NibCnt;
116
reg [15:0] ByteCnt;
117
reg  [2:0] DlyCrcCnt;
118
 
119
 
120
 
121
assign IncrementNibCnt = StateIPG | StatePreamble | |StateData & ~|DlyCrcCnt[2:0] | StatePAD
122
                       | StateFCS | StateJam | StateBackOff | StateDefer & ~ExcessiveDefer & TxStartFrm;
123
 
124
 
125
assign ResetNibCnt = StateDefer & ExcessiveDefer & ~TxStartFrm | StatePreamble & NibCntEq15
126
                   | StateJam & NibCntEq7 | StateIdle | StartDefer | StartIPG | StartFCS | StartJam;
127
 
128
// Nibble Counter
129
always @ (posedge MTxClk or posedge Reset)
130
begin
131
  if(Reset)
132
    NibCnt <= #Tp 16'h0;
133
  else
134
    begin
135
      if(ResetNibCnt)
136
        NibCnt <= #Tp 16'h0;
137
      else
138
      if(IncrementNibCnt)
139
        NibCnt <= #Tp NibCnt + 1'b1;
140
     end
141
end
142
 
143
 
144
assign NibCntEq7   = &NibCnt[2:0];
145
assign NibCntEq15  = &NibCnt[3:0];
146
 
147
assign NibbleMinFl = NibCnt >= ((MinFL<<1) -1);
148
 
149
assign ExcessiveDeferCnt = NibCnt[13:0] == 16'h17b7;
150
 
151
assign ExcessiveDefer  = NibCnt[13:0] == 16'h17b7 & ~ExDfrEn;   // 6071 nibbles
152
 
153
assign IncrementByteCnt = StateData[1] & ~ByteCntMax & ~|DlyCrcCnt[2:0]
154
                        | StateBackOff & (&NibCnt[6:0])
155
                        | (StatePAD | StateFCS) & NibCnt[0] & ~ByteCntMax;
156
 
157
assign ResetByteCnt = StartBackoff | StateIdle & TxStartFrm | PacketFinished_q;
158
 
159
 
160
// Transmit Byte Counter
161
always @ (posedge MTxClk or posedge Reset)
162
begin
163
  if(Reset)
164
    ByteCnt[15:0] <= #Tp 16'h0;
165
  else
166
    begin
167
      if(ResetByteCnt)
168
        ByteCnt[15:0] <= #Tp 16'h0;
169
      else
170
      if(IncrementByteCnt)
171
        ByteCnt[15:0] <= #Tp ByteCnt[15:0] + 1'b1;
172
    end
173
end
174
 
175
 
176
assign MaxFrame = ByteCnt[15:0] == MaxFL[15:0] & ~HugEn;
177
 
178
assign ByteCntMax = &ByteCnt[15:0];
179
 
180
 
181
// Delayed CRC counter
182
always @ (posedge MTxClk or posedge Reset)
183
begin
184
  if(Reset)
185
    DlyCrcCnt <= #Tp 3'h0;
186
  else
187
    begin
188
      if(StateData[1] & DlyCrcCnt == 3'h4 | StartJam | PacketFinished_q)
189
        DlyCrcCnt <= #Tp 3'h0;
190
      else
191
      if(DlyCrcEn & (StateSFD | StateData[1] & (|DlyCrcCnt[2:0])))
192
        DlyCrcCnt <= #Tp DlyCrcCnt + 1'b1;
193
    end
194
end
195
 
196
 
197
 
198
endmodule

powered by: WebSVN 2.1.0

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