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

Subversion Repositories or1k

[/] [or1k/] [tags/] [first/] [orp/] [orp_soc/] [rtl/] [verilog/] [ethernet.old/] [eth_transmitcontrol.v] - Blame information for rev 1778

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

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

powered by: WebSVN 2.1.0

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