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

Subversion Repositories ethmac

[/] [ethmac/] [trunk/] [rtl/] [verilog/] [eth_transmitcontrol.v] - Blame information for rev 352

Go to most recent revision | 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 346 olof
////  http://www.opencores.org/project,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 257 mohor
// Revision 1.5  2002/11/19 17:37:32  mohor
45
// When control frame (PAUSE) was sent, status was written in the
46
// eth_wishbone module and both TXB and TXC interrupts were set. Fixed.
47
// Only TXC interrupt is set.
48
//
49 251 mohor
// Revision 1.4  2002/01/23 10:28:16  mohor
50
// Link in the header changed.
51
//
52 37 mohor
// 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 22 mohor
// Revision 1.2  2001/09/11 14:17:00  mohor
57
// Few little NCSIM warnings fixed.
58
//
59 18 mohor
// 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 15 mohor
// Revision 1.1  2001/07/30 21:23:42  mohor
70
// Directory structure changed. Files checked and joind together.
71
//
72
// Revision 1.1  2001/07/03 12:51:54  mohor
73
// Initial release of the MAC Control module.
74
//
75
//
76
//
77
//
78
//
79
//
80
 
81
 
82 22 mohor
`include "timescale.v"
83 15 mohor
 
84
 
85
module eth_transmitcontrol (MTxClk, TxReset, TxUsedDataIn, TxUsedDataOut, TxDoneIn, TxAbortIn,
86
                            TxStartFrmIn, TPauseRq, TxUsedDataOutDetected, TxFlow, DlyCrcEn,
87
                            TxPauseTV, MAC, TxCtrlStartFrm, TxCtrlEndFrm, SendingCtrlFrm, CtrlMux,
88 251 mohor
                            ControlData, WillSendControlFrame, BlockTxDone
89 15 mohor
                           );
90
 
91
 
92
input         MTxClk;
93
input         TxReset;
94
input         TxUsedDataIn;
95
input         TxUsedDataOut;
96
input         TxDoneIn;
97
input         TxAbortIn;
98
input         TxStartFrmIn;
99
input         TPauseRq;
100
input         TxUsedDataOutDetected;
101
input         TxFlow;
102
input         DlyCrcEn;
103
input  [15:0] TxPauseTV;
104
input  [47:0] MAC;
105
 
106
output        TxCtrlStartFrm;
107
output        TxCtrlEndFrm;
108
output        SendingCtrlFrm;
109
output        CtrlMux;
110
output [7:0]  ControlData;
111
output        WillSendControlFrame;
112 251 mohor
output        BlockTxDone;
113 15 mohor
 
114
reg           SendingCtrlFrm;
115
reg           CtrlMux;
116
reg           WillSendControlFrame;
117
reg    [3:0]  DlyCrcCnt;
118
reg    [5:0]  ByteCnt;
119
reg           ControlEnd_q;
120
reg    [7:0]  MuxedCtrlData;
121
reg           TxCtrlStartFrm;
122
reg           TxCtrlStartFrm_q;
123
reg           TxCtrlEndFrm;
124
reg    [7:0]  ControlData;
125
reg           TxUsedDataIn_q;
126 251 mohor
reg           BlockTxDone;
127 15 mohor
 
128
wire          IncrementDlyCrcCnt;
129
wire          ResetByteCnt;
130
wire          IncrementByteCnt;
131
wire          ControlEnd;
132 257 mohor
wire          IncrementByteCntBy2;
133
wire          EnableCnt;
134 15 mohor
 
135
 
136
// A command for Sending the control frame is active (latched)
137
always @ (posedge MTxClk or posedge TxReset)
138
begin
139
  if(TxReset)
140 352 olof
    WillSendControlFrame <=  1'b0;
141 15 mohor
  else
142
  if(TxCtrlEndFrm & CtrlMux)
143 352 olof
    WillSendControlFrame <=  1'b0;
144 15 mohor
  else
145
  if(TPauseRq & TxFlow)
146 352 olof
    WillSendControlFrame <=  1'b1;
147 15 mohor
end
148
 
149
 
150
// Generation of the transmit control packet start frame
151
always @ (posedge MTxClk or posedge TxReset)
152
begin
153
  if(TxReset)
154 352 olof
    TxCtrlStartFrm <=  1'b0;
155 15 mohor
  else
156
  if(TxUsedDataIn_q & CtrlMux)
157 352 olof
    TxCtrlStartFrm <=  1'b0;
158 15 mohor
  else
159 251 mohor
  if(WillSendControlFrame & ~TxUsedDataOut & (TxDoneIn | TxAbortIn | TxStartFrmIn | (~TxUsedDataOutDetected)))
160 352 olof
    TxCtrlStartFrm <=  1'b1;
161 15 mohor
end
162
 
163
 
164
 
165
// Generation of the transmit control packet end frame
166
always @ (posedge MTxClk or posedge TxReset)
167
begin
168
  if(TxReset)
169 352 olof
    TxCtrlEndFrm <=  1'b0;
170 15 mohor
  else
171
  if(ControlEnd | ControlEnd_q)
172 352 olof
    TxCtrlEndFrm <=  1'b1;
173 15 mohor
  else
174 352 olof
    TxCtrlEndFrm <=  1'b0;
175 15 mohor
end
176
 
177
 
178
// Generation of the multiplexer signal (controls muxes for switching between
179
// normal and control packets)
180
always @ (posedge MTxClk or posedge TxReset)
181
begin
182
  if(TxReset)
183 352 olof
    CtrlMux <=  1'b0;
184 15 mohor
  else
185
  if(WillSendControlFrame & ~TxUsedDataOut)
186 352 olof
    CtrlMux <=  1'b1;
187 15 mohor
  else
188
  if(TxDoneIn)
189 352 olof
    CtrlMux <=  1'b0;
190 15 mohor
end
191
 
192
 
193
 
194
// Generation of the Sending Control Frame signal (enables padding and CRC)
195
always @ (posedge MTxClk or posedge TxReset)
196
begin
197
  if(TxReset)
198 352 olof
    SendingCtrlFrm <=  1'b0;
199 15 mohor
  else
200
  if(WillSendControlFrame & TxCtrlStartFrm)
201 352 olof
    SendingCtrlFrm <=  1'b1;
202 15 mohor
  else
203
  if(TxDoneIn)
204 352 olof
    SendingCtrlFrm <=  1'b0;
205 15 mohor
end
206
 
207
 
208
always @ (posedge MTxClk or posedge TxReset)
209
begin
210
  if(TxReset)
211 352 olof
    TxUsedDataIn_q <=  1'b0;
212 15 mohor
  else
213 352 olof
    TxUsedDataIn_q <=  TxUsedDataIn;
214 15 mohor
end
215
 
216
 
217 251 mohor
 
218
// Generation of the signal that will block sending the Done signal to the eth_wishbone module
219
// While sending the control frame
220
always @ (posedge MTxClk or posedge TxReset)
221
begin
222
  if(TxReset)
223 352 olof
    BlockTxDone <=  1'b0;
224 251 mohor
  else
225
  if(TxCtrlStartFrm)
226 352 olof
    BlockTxDone <=  1'b1;
227 251 mohor
  else
228 257 mohor
  if(TxStartFrmIn)
229 352 olof
    BlockTxDone <=  1'b0;
230 251 mohor
end
231
 
232
 
233 15 mohor
always @ (posedge MTxClk)
234
begin
235 352 olof
  ControlEnd_q     <=  ControlEnd;
236
  TxCtrlStartFrm_q <=  TxCtrlStartFrm;
237 15 mohor
end
238
 
239
 
240
assign IncrementDlyCrcCnt = CtrlMux & TxUsedDataIn &  ~DlyCrcCnt[2];
241
 
242
 
243
// Delayed CRC counter
244
always @ (posedge MTxClk or posedge TxReset)
245
begin
246
  if(TxReset)
247 352 olof
    DlyCrcCnt <=  4'h0;
248 15 mohor
  else
249
  if(ResetByteCnt)
250 352 olof
    DlyCrcCnt <=  4'h0;
251 15 mohor
  else
252
  if(IncrementDlyCrcCnt)
253 352 olof
    DlyCrcCnt <=  DlyCrcCnt + 1'b1;
254 15 mohor
end
255
 
256
 
257
assign ResetByteCnt = TxReset | (~TxCtrlStartFrm & (TxDoneIn | TxAbortIn));
258
assign IncrementByteCnt = CtrlMux & (TxCtrlStartFrm & ~TxCtrlStartFrm_q & ~TxUsedDataIn | TxUsedDataIn & ~ControlEnd);
259 257 mohor
assign IncrementByteCntBy2 = CtrlMux & TxCtrlStartFrm & (~TxCtrlStartFrm_q) & TxUsedDataIn;     // When TxUsedDataIn and CtrlMux are set at the same time
260 15 mohor
 
261 257 mohor
assign EnableCnt = (~DlyCrcEn | DlyCrcEn & (&DlyCrcCnt[1:0]));
262 15 mohor
// Byte counter
263
always @ (posedge MTxClk or posedge TxReset)
264
begin
265
  if(TxReset)
266 352 olof
    ByteCnt <=  6'h0;
267 15 mohor
  else
268
  if(ResetByteCnt)
269 352 olof
    ByteCnt <=  6'h0;
270 15 mohor
  else
271 257 mohor
  if(IncrementByteCntBy2 & EnableCnt)
272 352 olof
    ByteCnt <=  (ByteCnt[5:0] ) + 2'h2;
273 257 mohor
  else
274
  if(IncrementByteCnt & EnableCnt)
275 352 olof
    ByteCnt <=  (ByteCnt[5:0] ) + 1'b1;
276 15 mohor
end
277
 
278
 
279
assign ControlEnd = ByteCnt[5:0] == 6'h22;
280
 
281
 
282
// Control data generation (goes to the TxEthMAC module)
283
always @ (ByteCnt or DlyCrcEn or MAC or TxPauseTV or DlyCrcCnt)
284
begin
285
  case(ByteCnt)
286 18 mohor
    6'h0:    if(~DlyCrcEn | DlyCrcEn & (&DlyCrcCnt[1:0]))
287 15 mohor
               MuxedCtrlData[7:0] = 8'h01;                   // Reserved Multicast Address
288
             else
289
                                                         MuxedCtrlData[7:0] = 8'h0;
290
    6'h2:      MuxedCtrlData[7:0] = 8'h80;
291
    6'h4:      MuxedCtrlData[7:0] = 8'hC2;
292
    6'h6:      MuxedCtrlData[7:0] = 8'h00;
293
    6'h8:      MuxedCtrlData[7:0] = 8'h00;
294
    6'hA:      MuxedCtrlData[7:0] = 8'h01;
295
    6'hC:      MuxedCtrlData[7:0] = MAC[47:40];
296
    6'hE:      MuxedCtrlData[7:0] = MAC[39:32];
297
    6'h10:     MuxedCtrlData[7:0] = MAC[31:24];
298
    6'h12:     MuxedCtrlData[7:0] = MAC[23:16];
299
    6'h14:     MuxedCtrlData[7:0] = MAC[15:8];
300
    6'h16:     MuxedCtrlData[7:0] = MAC[7:0];
301
    6'h18:     MuxedCtrlData[7:0] = 8'h88;                   // Type/Length
302
    6'h1A:     MuxedCtrlData[7:0] = 8'h08;
303
    6'h1C:     MuxedCtrlData[7:0] = 8'h00;                   // Opcode
304
    6'h1E:     MuxedCtrlData[7:0] = 8'h01;
305
    6'h20:     MuxedCtrlData[7:0] = TxPauseTV[15:8];         // Pause timer value
306
    6'h22:     MuxedCtrlData[7:0] = TxPauseTV[7:0];
307
    default:   MuxedCtrlData[7:0] = 8'h0;
308
  endcase
309
end
310
 
311
 
312
// Latched Control data
313
always @ (posedge MTxClk or posedge TxReset)
314
begin
315
  if(TxReset)
316 352 olof
    ControlData[7:0] <=  8'h0;
317 15 mohor
  else
318
  if(~ByteCnt[0])
319 352 olof
    ControlData[7:0] <=  MuxedCtrlData[7:0];
320 15 mohor
end
321
 
322
 
323
 
324
endmodule

powered by: WebSVN 2.1.0

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