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

Subversion Repositories ethmac

[/] [ethmac/] [tags/] [rel_14/] [rtl/] [verilog/] [eth_transmitcontrol.v] - Blame information for rev 22

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

powered by: WebSVN 2.1.0

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