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

Subversion Repositories ethmac

[/] [ethmac/] [tags/] [rel_7/] [rtl/] [verilog/] [eth_transmitcontrol.v] - Blame information for rev 338

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 15 mohor
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  eth_transmitcontrol.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
////                                                              ////
11
////  All additional information is avaliable in the Readme.txt   ////
12
////  file.                                                       ////
13
////                                                              ////
14
//////////////////////////////////////////////////////////////////////
15
////                                                              ////
16
//// Copyright (C) 2001 Authors                                   ////
17
////                                                              ////
18
//// This source file may be used and distributed without         ////
19
//// restriction provided that this copyright statement is not    ////
20
//// removed from the file and that any derivative work contains  ////
21
//// the original copyright notice and the associated disclaimer. ////
22
////                                                              ////
23
//// This source file is free software; you can redistribute it   ////
24
//// and/or modify it under the terms of the GNU Lesser General   ////
25
//// Public License as published by the Free Software Foundation; ////
26
//// either version 2.1 of the License, or (at your option) any   ////
27
//// later version.                                               ////
28
////                                                              ////
29
//// This source is distributed in the hope that it will be       ////
30
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
31
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
32
//// PURPOSE.  See the GNU Lesser General Public License for more ////
33
//// details.                                                     ////
34
////                                                              ////
35
//// You should have received a copy of the GNU Lesser General    ////
36
//// Public License along with this source; if not, download it   ////
37
//// from http://www.opencores.org/lgpl.shtml                     ////
38
////                                                              ////
39
//////////////////////////////////////////////////////////////////////
40
//
41
// CVS Revision History
42
//
43
// $Log: not supported by cvs2svn $
44 37 mohor
// Revision 1.3  2001/10/19 08:43:51  mohor
45
// eth_timescale.v changed to timescale.v This is done because of the
46
// simulation of the few cores in a one joined project.
47
//
48 22 mohor
// Revision 1.2  2001/09/11 14:17:00  mohor
49
// Few little NCSIM warnings fixed.
50
//
51 18 mohor
// Revision 1.1  2001/08/06 14:44:29  mohor
52
// A define FPGA added to select between Artisan RAM (for ASIC) and Block Ram (For Virtex).
53
// Include files fixed to contain no path.
54
// File names and module names changed ta have a eth_ prologue in the name.
55
// File eth_timescale.v is used to define timescale
56
// All pin names on the top module are changed to contain _I, _O or _OE at the end.
57
// Bidirectional signal MDIO is changed to three signals (Mdc_O, Mdi_I, Mdo_O
58
// and Mdo_OE. The bidirectional signal must be created on the top level. This
59
// is done due to the ASIC tools.
60
//
61 15 mohor
// Revision 1.1  2001/07/30 21:23:42  mohor
62
// Directory structure changed. Files checked and joind together.
63
//
64
// Revision 1.1  2001/07/03 12:51:54  mohor
65
// Initial release of the MAC Control module.
66
//
67
//
68
//
69
//
70
//
71
//
72
 
73
 
74 22 mohor
`include "timescale.v"
75 15 mohor
 
76
 
77
module eth_transmitcontrol (MTxClk, TxReset, TxUsedDataIn, TxUsedDataOut, TxDoneIn, TxAbortIn,
78
                            TxStartFrmIn, TPauseRq, TxUsedDataOutDetected, TxFlow, DlyCrcEn,
79
                            TxPauseTV, MAC, TxCtrlStartFrm, TxCtrlEndFrm, SendingCtrlFrm, CtrlMux,
80
                            ControlData, WillSendControlFrame
81
                           );
82
 
83
parameter Tp = 1;
84
 
85
 
86
input         MTxClk;
87
input         TxReset;
88
input         TxUsedDataIn;
89
input         TxUsedDataOut;
90
input         TxDoneIn;
91
input         TxAbortIn;
92
input         TxStartFrmIn;
93
input         TPauseRq;
94
input         TxUsedDataOutDetected;
95
input         TxFlow;
96
input         DlyCrcEn;
97
input  [15:0] TxPauseTV;
98
input  [47:0] MAC;
99
 
100
output        TxCtrlStartFrm;
101
output        TxCtrlEndFrm;
102
output        SendingCtrlFrm;
103
output        CtrlMux;
104
output [7:0]  ControlData;
105
output        WillSendControlFrame;
106
 
107
reg           SendingCtrlFrm;
108
reg           CtrlMux;
109
reg           WillSendControlFrame;
110
reg    [3:0]  DlyCrcCnt;
111
reg    [5:0]  ByteCnt;
112
reg           ControlEnd_q;
113
reg    [7:0]  MuxedCtrlData;
114
reg           TxCtrlStartFrm;
115
reg           TxCtrlStartFrm_q;
116
reg           TxCtrlEndFrm;
117
reg    [7:0]  ControlData;
118
reg           TxUsedDataIn_q;
119
 
120
wire          IncrementDlyCrcCnt;
121
wire          ResetByteCnt;
122
wire          IncrementByteCnt;
123
wire          ControlEnd;
124
 
125
 
126
// A command for Sending the control frame is active (latched)
127
always @ (posedge MTxClk or posedge TxReset)
128
begin
129
  if(TxReset)
130
    WillSendControlFrame <= #Tp 1'b0;
131
  else
132
  if(TxCtrlEndFrm & CtrlMux)
133
    WillSendControlFrame <= #Tp 1'b0;
134
  else
135
  if(TPauseRq & TxFlow)
136
    WillSendControlFrame <= #Tp 1'b1;
137
end
138
 
139
 
140
// Generation of the transmit control packet start frame
141
always @ (posedge MTxClk or posedge TxReset)
142
begin
143
  if(TxReset)
144
    TxCtrlStartFrm <= #Tp 1'b0;
145
  else
146
  if(TxUsedDataIn_q & CtrlMux)
147
    TxCtrlStartFrm <= #Tp 1'b0;
148
  else
149
  if(WillSendControlFrame & ~TxUsedDataOut & (TxDoneIn | TxAbortIn | TxStartFrmIn | ~TxUsedDataOutDetected))
150
    TxCtrlStartFrm <= #Tp 1'b1;
151
end
152
 
153
 
154
 
155
// Generation of the transmit control packet end frame
156
always @ (posedge MTxClk or posedge TxReset)
157
begin
158
  if(TxReset)
159
    TxCtrlEndFrm <= #Tp 1'b0;
160
  else
161
  if(ControlEnd | ControlEnd_q)
162
    TxCtrlEndFrm <= #Tp 1'b1;
163
  else
164
    TxCtrlEndFrm <= #Tp 1'b0;
165
end
166
 
167
 
168
// Generation of the multiplexer signal (controls muxes for switching between
169
// normal and control packets)
170
always @ (posedge MTxClk or posedge TxReset)
171
begin
172
  if(TxReset)
173
    CtrlMux <= #Tp 1'b0;
174
  else
175
  if(WillSendControlFrame & ~TxUsedDataOut)
176
    CtrlMux <= #Tp 1'b1;
177
  else
178
  if(TxDoneIn)
179
    CtrlMux <= #Tp 1'b0;
180
end
181
 
182
 
183
 
184
// Generation of the Sending Control Frame signal (enables padding and CRC)
185
always @ (posedge MTxClk or posedge TxReset)
186
begin
187
  if(TxReset)
188
    SendingCtrlFrm <= #Tp 1'b0;
189
  else
190
  if(WillSendControlFrame & TxCtrlStartFrm)
191
    SendingCtrlFrm <= #Tp 1'b1;
192
  else
193
  if(TxDoneIn)
194
    SendingCtrlFrm <= #Tp 1'b0;
195
end
196
 
197
 
198
always @ (posedge MTxClk or posedge TxReset)
199
begin
200
  if(TxReset)
201
    TxUsedDataIn_q <= #Tp 1'b0;
202
  else
203
    TxUsedDataIn_q <= #Tp TxUsedDataIn;
204
end
205
 
206
 
207
always @ (posedge MTxClk)
208
begin
209
  ControlEnd_q     <= #Tp ControlEnd;
210
  TxCtrlStartFrm_q <= #Tp TxCtrlStartFrm;
211
end
212
 
213
 
214
assign IncrementDlyCrcCnt = CtrlMux & TxUsedDataIn &  ~DlyCrcCnt[2];
215
 
216
 
217
// Delayed CRC counter
218
always @ (posedge MTxClk or posedge TxReset)
219
begin
220
  if(TxReset)
221
    DlyCrcCnt <= #Tp 4'h0;
222
  else
223
  if(ResetByteCnt)
224
    DlyCrcCnt <= #Tp 4'h0;
225
  else
226
  if(IncrementDlyCrcCnt)
227
    DlyCrcCnt <= #Tp DlyCrcCnt + 1'b1;
228
end
229
 
230
 
231
assign ResetByteCnt = TxReset | (~TxCtrlStartFrm & (TxDoneIn | TxAbortIn));
232
assign IncrementByteCnt = CtrlMux & (TxCtrlStartFrm & ~TxCtrlStartFrm_q & ~TxUsedDataIn | TxUsedDataIn & ~ControlEnd);
233
 
234
 
235
// Byte counter
236
always @ (posedge MTxClk or posedge TxReset)
237
begin
238
  if(TxReset)
239
    ByteCnt <= #Tp 6'h0;
240
  else
241
  if(ResetByteCnt)
242
    ByteCnt <= #Tp 6'h0;
243
  else
244 18 mohor
  if(IncrementByteCnt & (~DlyCrcEn | DlyCrcEn & (&DlyCrcCnt[1:0])))
245 15 mohor
    ByteCnt <= #Tp (ByteCnt[5:0] ) + 1'b1;
246
end
247
 
248
 
249
assign ControlEnd = ByteCnt[5:0] == 6'h22;
250
 
251
 
252
// Control data generation (goes to the TxEthMAC module)
253
always @ (ByteCnt or DlyCrcEn or MAC or TxPauseTV or DlyCrcCnt)
254
begin
255
  case(ByteCnt)
256 18 mohor
    6'h0:    if(~DlyCrcEn | DlyCrcEn & (&DlyCrcCnt[1:0]))
257 15 mohor
               MuxedCtrlData[7:0] = 8'h01;                   // Reserved Multicast Address
258
             else
259
                                                         MuxedCtrlData[7:0] = 8'h0;
260
    6'h2:      MuxedCtrlData[7:0] = 8'h80;
261
    6'h4:      MuxedCtrlData[7:0] = 8'hC2;
262
    6'h6:      MuxedCtrlData[7:0] = 8'h00;
263
    6'h8:      MuxedCtrlData[7:0] = 8'h00;
264
    6'hA:      MuxedCtrlData[7:0] = 8'h01;
265
    6'hC:      MuxedCtrlData[7:0] = MAC[47:40];
266
    6'hE:      MuxedCtrlData[7:0] = MAC[39:32];
267
    6'h10:     MuxedCtrlData[7:0] = MAC[31:24];
268
    6'h12:     MuxedCtrlData[7:0] = MAC[23:16];
269
    6'h14:     MuxedCtrlData[7:0] = MAC[15:8];
270
    6'h16:     MuxedCtrlData[7:0] = MAC[7:0];
271
    6'h18:     MuxedCtrlData[7:0] = 8'h88;                   // Type/Length
272
    6'h1A:     MuxedCtrlData[7:0] = 8'h08;
273
    6'h1C:     MuxedCtrlData[7:0] = 8'h00;                   // Opcode
274
    6'h1E:     MuxedCtrlData[7:0] = 8'h01;
275
    6'h20:     MuxedCtrlData[7:0] = TxPauseTV[15:8];         // Pause timer value
276
    6'h22:     MuxedCtrlData[7:0] = TxPauseTV[7:0];
277
    default:   MuxedCtrlData[7:0] = 8'h0;
278
  endcase
279
end
280
 
281
 
282
// Latched Control data
283
always @ (posedge MTxClk or posedge TxReset)
284
begin
285
  if(TxReset)
286
    ControlData[7:0] <= #Tp 8'h0;
287
  else
288
  if(~ByteCnt[0])
289
    ControlData[7:0] <= #Tp MuxedCtrlData[7:0];
290
end
291
 
292
 
293
 
294
endmodule

powered by: WebSVN 2.1.0

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