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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [rtl/] [verilog/] [ethmac/] [eth_transmitcontrol.v] - Blame information for rev 862

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 julius
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  eth_transmitcontrol.v                                       ////
4
////                                                              ////
5
////  This file is part of the Ethernet IP core project           ////
6 570 olof
////  http://www.opencores.org/project,ethmac                     ////
7 6 julius
////                                                              ////
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 403 julius
// $Log: not supported by cvs2svn $
44 6 julius
// 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
// Revision 1.4  2002/01/23 10:28:16  mohor
50
// Link in the header changed.
51
//
52
// 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
// Revision 1.2  2001/09/11 14:17:00  mohor
57
// Few little NCSIM warnings fixed.
58
//
59
// 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
// 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
`include "timescale.v"
83
 
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
                            ControlData, WillSendControlFrame, BlockTxDone
89
                           );
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
output        BlockTxDone;
113
 
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
reg           BlockTxDone;
127
 
128
wire          IncrementDlyCrcCnt;
129
wire          ResetByteCnt;
130
wire          IncrementByteCnt;
131
wire          ControlEnd;
132
wire          IncrementByteCntBy2;
133
wire          EnableCnt;
134
 
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 403 julius
    WillSendControlFrame <=  1'b0;
141 6 julius
  else
142
  if(TxCtrlEndFrm & CtrlMux)
143 403 julius
    WillSendControlFrame <=  1'b0;
144 6 julius
  else
145
  if(TPauseRq & TxFlow)
146 403 julius
    WillSendControlFrame <=  1'b1;
147 6 julius
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 403 julius
    TxCtrlStartFrm <=  1'b0;
155 6 julius
  else
156
  if(TxUsedDataIn_q & CtrlMux)
157 403 julius
    TxCtrlStartFrm <=  1'b0;
158 6 julius
  else
159
  if(WillSendControlFrame & ~TxUsedDataOut & (TxDoneIn | TxAbortIn | TxStartFrmIn | (~TxUsedDataOutDetected)))
160 403 julius
    TxCtrlStartFrm <=  1'b1;
161 6 julius
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 403 julius
    TxCtrlEndFrm <=  1'b0;
170 6 julius
  else
171
  if(ControlEnd | ControlEnd_q)
172 403 julius
    TxCtrlEndFrm <=  1'b1;
173 6 julius
  else
174 403 julius
    TxCtrlEndFrm <=  1'b0;
175 6 julius
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 403 julius
    CtrlMux <=  1'b0;
184 6 julius
  else
185
  if(WillSendControlFrame & ~TxUsedDataOut)
186 403 julius
    CtrlMux <=  1'b1;
187 6 julius
  else
188
  if(TxDoneIn)
189 403 julius
    CtrlMux <=  1'b0;
190 6 julius
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 403 julius
    SendingCtrlFrm <=  1'b0;
199 6 julius
  else
200
  if(WillSendControlFrame & TxCtrlStartFrm)
201 403 julius
    SendingCtrlFrm <=  1'b1;
202 6 julius
  else
203
  if(TxDoneIn)
204 403 julius
    SendingCtrlFrm <=  1'b0;
205 6 julius
end
206
 
207
 
208
always @ (posedge MTxClk or posedge TxReset)
209
begin
210
  if(TxReset)
211 403 julius
    TxUsedDataIn_q <=  1'b0;
212 6 julius
  else
213 403 julius
    TxUsedDataIn_q <=  TxUsedDataIn;
214 6 julius
end
215
 
216
 
217
 
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 403 julius
    BlockTxDone <=  1'b0;
224 6 julius
  else
225
  if(TxCtrlStartFrm)
226 403 julius
    BlockTxDone <=  1'b1;
227 6 julius
  else
228
  if(TxStartFrmIn)
229 403 julius
    BlockTxDone <=  1'b0;
230 6 julius
end
231
 
232
 
233
always @ (posedge MTxClk)
234
begin
235 403 julius
  ControlEnd_q     <=  ControlEnd;
236
  TxCtrlStartFrm_q <=  TxCtrlStartFrm;
237 6 julius
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 403 julius
    DlyCrcCnt <=  4'h0;
248 6 julius
  else
249
  if(ResetByteCnt)
250 403 julius
    DlyCrcCnt <=  4'h0;
251 6 julius
  else
252
  if(IncrementDlyCrcCnt)
253 439 julius
    DlyCrcCnt <=  DlyCrcCnt + 4'd1;
254 6 julius
end
255
 
256
 
257
assign ResetByteCnt = TxReset | (~TxCtrlStartFrm & (TxDoneIn | TxAbortIn));
258
assign IncrementByteCnt = CtrlMux & (TxCtrlStartFrm & ~TxCtrlStartFrm_q & ~TxUsedDataIn | TxUsedDataIn & ~ControlEnd);
259
assign IncrementByteCntBy2 = CtrlMux & TxCtrlStartFrm & (~TxCtrlStartFrm_q) & TxUsedDataIn;     // When TxUsedDataIn and CtrlMux are set at the same time
260
 
261
assign EnableCnt = (~DlyCrcEn | DlyCrcEn & (&DlyCrcCnt[1:0]));
262
// Byte counter
263
always @ (posedge MTxClk or posedge TxReset)
264
begin
265
  if(TxReset)
266 403 julius
    ByteCnt <=  6'h0;
267 6 julius
  else
268
  if(ResetByteCnt)
269 403 julius
    ByteCnt <=  6'h0;
270 6 julius
  else
271
  if(IncrementByteCntBy2 & EnableCnt)
272 439 julius
    ByteCnt <=  (ByteCnt[5:0] ) + 6'd2;
273 6 julius
  else
274
  if(IncrementByteCnt & EnableCnt)
275 439 julius
    ByteCnt <=  (ByteCnt[5:0] ) + 6'd1;
276 6 julius
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
    6'h0:    if(~DlyCrcEn | DlyCrcEn & (&DlyCrcCnt[1:0]))
287
               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 403 julius
    ControlData[7:0] <=  8'h0;
317 6 julius
  else
318
  if(~ByteCnt[0])
319 403 julius
    ControlData[7:0] <=  MuxedCtrlData[7:0];
320 6 julius
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.