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

Subversion Repositories ethmac

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

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
////  http://www.opencores.org/cores/ethmac/                      ////
7
////                                                              ////
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 18 mohor
// Revision 1.1  2001/08/06 14:44:29  mohor
45
// A define FPGA added to select between Artisan RAM (for ASIC) and Block Ram (For Virtex).
46
// Include files fixed to contain no path.
47
// File names and module names changed ta have a eth_ prologue in the name.
48
// File eth_timescale.v is used to define timescale
49
// All pin names on the top module are changed to contain _I, _O or _OE at the end.
50
// Bidirectional signal MDIO is changed to three signals (Mdc_O, Mdi_I, Mdo_O
51
// and Mdo_OE. The bidirectional signal must be created on the top level. This
52
// is done due to the ASIC tools.
53
//
54 15 mohor
// Revision 1.1  2001/07/30 21:23:42  mohor
55
// Directory structure changed. Files checked and joind together.
56
//
57
// Revision 1.1  2001/07/03 12:51:54  mohor
58
// Initial release of the MAC Control module.
59
//
60
//
61
//
62
//
63
//
64
//
65
 
66
 
67
`include "eth_timescale.v"
68
 
69
 
70
module eth_transmitcontrol (MTxClk, TxReset, TxUsedDataIn, TxUsedDataOut, TxDoneIn, TxAbortIn,
71
                            TxStartFrmIn, TPauseRq, TxUsedDataOutDetected, TxFlow, DlyCrcEn,
72
                            TxPauseTV, MAC, TxCtrlStartFrm, TxCtrlEndFrm, SendingCtrlFrm, CtrlMux,
73
                            ControlData, WillSendControlFrame
74
                           );
75
 
76
parameter Tp = 1;
77
 
78
 
79
input         MTxClk;
80
input         TxReset;
81
input         TxUsedDataIn;
82
input         TxUsedDataOut;
83
input         TxDoneIn;
84
input         TxAbortIn;
85
input         TxStartFrmIn;
86
input         TPauseRq;
87
input         TxUsedDataOutDetected;
88
input         TxFlow;
89
input         DlyCrcEn;
90
input  [15:0] TxPauseTV;
91
input  [47:0] MAC;
92
 
93
output        TxCtrlStartFrm;
94
output        TxCtrlEndFrm;
95
output        SendingCtrlFrm;
96
output        CtrlMux;
97
output [7:0]  ControlData;
98
output        WillSendControlFrame;
99
 
100
reg           SendingCtrlFrm;
101
reg           CtrlMux;
102
reg           WillSendControlFrame;
103
reg    [3:0]  DlyCrcCnt;
104
reg    [5:0]  ByteCnt;
105
reg           ControlEnd_q;
106
reg    [7:0]  MuxedCtrlData;
107
reg           TxCtrlStartFrm;
108
reg           TxCtrlStartFrm_q;
109
reg           TxCtrlEndFrm;
110
reg    [7:0]  ControlData;
111
reg           TxUsedDataIn_q;
112
 
113
wire          IncrementDlyCrcCnt;
114
wire          ResetByteCnt;
115
wire          IncrementByteCnt;
116
wire          ControlEnd;
117
 
118
 
119
// A command for Sending the control frame is active (latched)
120
always @ (posedge MTxClk or posedge TxReset)
121
begin
122
  if(TxReset)
123
    WillSendControlFrame <= #Tp 1'b0;
124
  else
125
  if(TxCtrlEndFrm & CtrlMux)
126
    WillSendControlFrame <= #Tp 1'b0;
127
  else
128
  if(TPauseRq & TxFlow)
129
    WillSendControlFrame <= #Tp 1'b1;
130
end
131
 
132
 
133
// Generation of the transmit control packet start frame
134
always @ (posedge MTxClk or posedge TxReset)
135
begin
136
  if(TxReset)
137
    TxCtrlStartFrm <= #Tp 1'b0;
138
  else
139
  if(TxUsedDataIn_q & CtrlMux)
140
    TxCtrlStartFrm <= #Tp 1'b0;
141
  else
142
  if(WillSendControlFrame & ~TxUsedDataOut & (TxDoneIn | TxAbortIn | TxStartFrmIn | ~TxUsedDataOutDetected))
143
    TxCtrlStartFrm <= #Tp 1'b1;
144
end
145
 
146
 
147
 
148
// Generation of the transmit control packet end frame
149
always @ (posedge MTxClk or posedge TxReset)
150
begin
151
  if(TxReset)
152
    TxCtrlEndFrm <= #Tp 1'b0;
153
  else
154
  if(ControlEnd | ControlEnd_q)
155
    TxCtrlEndFrm <= #Tp 1'b1;
156
  else
157
    TxCtrlEndFrm <= #Tp 1'b0;
158
end
159
 
160
 
161
// Generation of the multiplexer signal (controls muxes for switching between
162
// normal and control packets)
163
always @ (posedge MTxClk or posedge TxReset)
164
begin
165
  if(TxReset)
166
    CtrlMux <= #Tp 1'b0;
167
  else
168
  if(WillSendControlFrame & ~TxUsedDataOut)
169
    CtrlMux <= #Tp 1'b1;
170
  else
171
  if(TxDoneIn)
172
    CtrlMux <= #Tp 1'b0;
173
end
174
 
175
 
176
 
177
// Generation of the Sending Control Frame signal (enables padding and CRC)
178
always @ (posedge MTxClk or posedge TxReset)
179
begin
180
  if(TxReset)
181
    SendingCtrlFrm <= #Tp 1'b0;
182
  else
183
  if(WillSendControlFrame & TxCtrlStartFrm)
184
    SendingCtrlFrm <= #Tp 1'b1;
185
  else
186
  if(TxDoneIn)
187
    SendingCtrlFrm <= #Tp 1'b0;
188
end
189
 
190
 
191
always @ (posedge MTxClk or posedge TxReset)
192
begin
193
  if(TxReset)
194
    TxUsedDataIn_q <= #Tp 1'b0;
195
  else
196
    TxUsedDataIn_q <= #Tp TxUsedDataIn;
197
end
198
 
199
 
200
always @ (posedge MTxClk)
201
begin
202
  ControlEnd_q     <= #Tp ControlEnd;
203
  TxCtrlStartFrm_q <= #Tp TxCtrlStartFrm;
204
end
205
 
206
 
207
assign IncrementDlyCrcCnt = CtrlMux & TxUsedDataIn &  ~DlyCrcCnt[2];
208
 
209
 
210
// Delayed CRC counter
211
always @ (posedge MTxClk or posedge TxReset)
212
begin
213
  if(TxReset)
214
    DlyCrcCnt <= #Tp 4'h0;
215
  else
216
  if(ResetByteCnt)
217
    DlyCrcCnt <= #Tp 4'h0;
218
  else
219
  if(IncrementDlyCrcCnt)
220
    DlyCrcCnt <= #Tp DlyCrcCnt + 1'b1;
221
end
222
 
223
 
224
assign ResetByteCnt = TxReset | (~TxCtrlStartFrm & (TxDoneIn | TxAbortIn));
225
assign IncrementByteCnt = CtrlMux & (TxCtrlStartFrm & ~TxCtrlStartFrm_q & ~TxUsedDataIn | TxUsedDataIn & ~ControlEnd);
226
 
227
 
228
// Byte counter
229
always @ (posedge MTxClk or posedge TxReset)
230
begin
231
  if(TxReset)
232
    ByteCnt <= #Tp 6'h0;
233
  else
234
  if(ResetByteCnt)
235
    ByteCnt <= #Tp 6'h0;
236
  else
237 18 mohor
  if(IncrementByteCnt & (~DlyCrcEn | DlyCrcEn & (&DlyCrcCnt[1:0])))
238 15 mohor
    ByteCnt <= #Tp (ByteCnt[5:0] ) + 1'b1;
239
end
240
 
241
 
242
assign ControlEnd = ByteCnt[5:0] == 6'h22;
243
 
244
 
245
// Control data generation (goes to the TxEthMAC module)
246
always @ (ByteCnt or DlyCrcEn or MAC or TxPauseTV or DlyCrcCnt)
247
begin
248
  case(ByteCnt)
249 18 mohor
    6'h0:    if(~DlyCrcEn | DlyCrcEn & (&DlyCrcCnt[1:0]))
250 15 mohor
               MuxedCtrlData[7:0] = 8'h01;                   // Reserved Multicast Address
251
             else
252
                                                         MuxedCtrlData[7:0] = 8'h0;
253
    6'h2:      MuxedCtrlData[7:0] = 8'h80;
254
    6'h4:      MuxedCtrlData[7:0] = 8'hC2;
255
    6'h6:      MuxedCtrlData[7:0] = 8'h00;
256
    6'h8:      MuxedCtrlData[7:0] = 8'h00;
257
    6'hA:      MuxedCtrlData[7:0] = 8'h01;
258
    6'hC:      MuxedCtrlData[7:0] = MAC[47:40];
259
    6'hE:      MuxedCtrlData[7:0] = MAC[39:32];
260
    6'h10:     MuxedCtrlData[7:0] = MAC[31:24];
261
    6'h12:     MuxedCtrlData[7:0] = MAC[23:16];
262
    6'h14:     MuxedCtrlData[7:0] = MAC[15:8];
263
    6'h16:     MuxedCtrlData[7:0] = MAC[7:0];
264
    6'h18:     MuxedCtrlData[7:0] = 8'h88;                   // Type/Length
265
    6'h1A:     MuxedCtrlData[7:0] = 8'h08;
266
    6'h1C:     MuxedCtrlData[7:0] = 8'h00;                   // Opcode
267
    6'h1E:     MuxedCtrlData[7:0] = 8'h01;
268
    6'h20:     MuxedCtrlData[7:0] = TxPauseTV[15:8];         // Pause timer value
269
    6'h22:     MuxedCtrlData[7:0] = TxPauseTV[7:0];
270
    default:   MuxedCtrlData[7:0] = 8'h0;
271
  endcase
272
end
273
 
274
 
275
// Latched Control data
276
always @ (posedge MTxClk or posedge TxReset)
277
begin
278
  if(TxReset)
279
    ControlData[7:0] <= #Tp 8'h0;
280
  else
281
  if(~ByteCnt[0])
282
    ControlData[7:0] <= #Tp MuxedCtrlData[7:0];
283
end
284
 
285
 
286
 
287
endmodule

powered by: WebSVN 2.1.0

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