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

Subversion Repositories ethmac

[/] [ethmac/] [trunk/] [rtl/] [verilog/] [eth_maccontrol.v] - Blame information for rev 354

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

Line No. Rev Author Line
1 15 mohor
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  eth_maccontrol.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 272 tadejm
// Revision 1.6  2002/11/22 01:57:06  mohor
45
// Rx Flow control fixed. CF flag added to the RX buffer descriptor. RxAbort
46
// synchronized.
47
//
48 261 mohor
// Revision 1.5  2002/11/21 00:14:39  mohor
49
// TxDone and TxAbort changed so they're not propagated to the wishbone
50
// module when control frame is transmitted.
51
//
52 256 mohor
// Revision 1.4  2002/11/19 17:37:32  mohor
53
// When control frame (PAUSE) was sent, status was written in the
54
// eth_wishbone module and both TXB and TXC interrupts were set. Fixed.
55
// Only TXC interrupt is set.
56
//
57 251 mohor
// Revision 1.3  2002/01/23 10:28:16  mohor
58
// Link in the header changed.
59
//
60 37 mohor
// Revision 1.2  2001/10/19 08:43:51  mohor
61
// eth_timescale.v changed to timescale.v This is done because of the
62
// simulation of the few cores in a one joined project.
63
//
64 22 mohor
// Revision 1.1  2001/08/06 14:44:29  mohor
65
// A define FPGA added to select between Artisan RAM (for ASIC) and Block Ram (For Virtex).
66
// Include files fixed to contain no path.
67
// File names and module names changed ta have a eth_ prologue in the name.
68
// File eth_timescale.v is used to define timescale
69
// All pin names on the top module are changed to contain _I, _O or _OE at the end.
70
// Bidirectional signal MDIO is changed to three signals (Mdc_O, Mdi_I, Mdo_O
71
// and Mdo_OE. The bidirectional signal must be created on the top level. This
72
// is done due to the ASIC tools.
73
//
74 15 mohor
// Revision 1.1  2001/07/30 21:23:42  mohor
75
// Directory structure changed. Files checked and joind together.
76
//
77
// Revision 1.1  2001/07/03 12:51:54  mohor
78
// Initial release of the MAC Control module.
79
//
80
//
81
//
82
//
83
 
84
 
85 22 mohor
`include "timescale.v"
86 15 mohor
 
87
 
88
module eth_maccontrol (MTxClk, MRxClk, TxReset, RxReset, TPauseRq, TxDataIn, TxStartFrmIn, TxUsedDataIn,
89
                       TxEndFrmIn, TxDoneIn, TxAbortIn, RxData, RxValid, RxStartFrm, RxEndFrm, ReceiveEnd,
90 261 mohor
                       ReceivedPacketGood, ReceivedLengthOK, TxFlow, RxFlow, DlyCrcEn, TxPauseTV,
91 15 mohor
                       MAC, PadIn, PadOut, CrcEnIn, CrcEnOut, TxDataOut, TxStartFrmOut, TxEndFrmOut,
92
                       TxDoneOut, TxAbortOut, TxUsedDataOut, WillSendControlFrame, TxCtrlEndFrm,
93 272 tadejm
                       ReceivedPauseFrm, ControlFrmAddressOK, SetPauseTimer, r_PassAll, RxStatusWriteLatched_sync2
94 15 mohor
                      );
95
 
96
 
97
 
98
input         MTxClk;                   // Transmit clock (from PHY)
99
input         MRxClk;                   // Receive clock (from PHY)
100
input         TxReset;                  // Transmit reset
101
input         RxReset;                  // Receive reset
102
input         TPauseRq;                 // Transmit control frame (from host)
103
input   [7:0] TxDataIn;                 // Transmit packet data byte (from host)
104
input         TxStartFrmIn;             // Transmit packet start frame input (from host)
105
input         TxUsedDataIn;             // Transmit packet used data (from TxEthMAC)
106
input         TxEndFrmIn;               // Transmit packet end frame input (from host)
107
input         TxDoneIn;                 // Transmit packet done (from TxEthMAC)
108
input         TxAbortIn;                // Transmit packet abort (input from TxEthMAC)
109
input         PadIn;                    // Padding (input from registers)
110
input         CrcEnIn;                  // Crc append (input from registers)
111
input   [7:0] RxData;                   // Receive Packet Data (from RxEthMAC)
112
input         RxValid;                  // Received a valid packet
113
input         RxStartFrm;               // Receive packet start frame (input from RxEthMAC)
114
input         RxEndFrm;                 // Receive packet end frame (input from RxEthMAC)
115
input         ReceiveEnd;               // End of receiving of the current packet (input from RxEthMAC)
116
input         ReceivedPacketGood;       // Received packet is good
117
input         ReceivedLengthOK;         // Length of the received packet is OK
118
input         TxFlow;                   // Tx flow control (from registers)
119
input         RxFlow;                   // Rx flow control (from registers)
120
input         DlyCrcEn;                 // Delayed CRC enabled (from registers)
121
input  [15:0] TxPauseTV;                // Transmit Pause Timer Value (from registers)
122
input  [47:0] MAC;                      // MAC address (from registers)
123 272 tadejm
input         RxStatusWriteLatched_sync2;
124
input         r_PassAll;
125 15 mohor
 
126
output  [7:0] TxDataOut;                // Transmit Packet Data (to TxEthMAC)
127
output        TxStartFrmOut;            // Transmit packet start frame (output to TxEthMAC)
128
output        TxEndFrmOut;              // Transmit packet end frame (output to TxEthMAC)
129
output        TxDoneOut;                // Transmit packet done (to host)
130
output        TxAbortOut;               // Transmit packet aborted (to host)
131
output        TxUsedDataOut;            // Transmit packet used data (to host)
132
output        PadOut;                   // Padding (output to TxEthMAC)
133
output        CrcEnOut;                 // Crc append (output to TxEthMAC)
134
output        WillSendControlFrame;
135
output        TxCtrlEndFrm;
136
output        ReceivedPauseFrm;
137 261 mohor
output        ControlFrmAddressOK;
138
output        SetPauseTimer;
139 15 mohor
 
140
reg           TxUsedDataOutDetected;
141
reg           TxAbortInLatched;
142
reg           TxDoneInLatched;
143
reg           MuxedDone;
144
reg           MuxedAbort;
145
 
146
wire          Pause;
147
wire          TxCtrlStartFrm;
148
wire    [7:0] ControlData;
149
wire          CtrlMux;
150
wire          SendingCtrlFrm;           // Sending Control Frame (enables padding and CRC)
151 251 mohor
wire          BlockTxDone;
152 15 mohor
 
153
 
154
// Signal TxUsedDataOut was detected (a transfer is already in progress)
155
always @ (posedge MTxClk or posedge TxReset)
156
begin
157
  if(TxReset)
158 352 olof
    TxUsedDataOutDetected <=  1'b0;
159 15 mohor
  else
160
  if(TxDoneIn | TxAbortIn)
161 352 olof
    TxUsedDataOutDetected <=  1'b0;
162 15 mohor
  else
163
  if(TxUsedDataOut)
164 352 olof
    TxUsedDataOutDetected <=  1'b1;
165 15 mohor
end
166
 
167
 
168
// Latching variables
169
always @ (posedge MTxClk or posedge TxReset)
170
begin
171
  if(TxReset)
172
    begin
173 352 olof
      TxAbortInLatched <=  1'b0;
174
      TxDoneInLatched  <=  1'b0;
175 15 mohor
    end
176
  else
177
    begin
178 352 olof
      TxAbortInLatched <=  TxAbortIn;
179
      TxDoneInLatched  <=  TxDoneIn;
180 15 mohor
    end
181
end
182
 
183
 
184
 
185
// Generating muxed abort signal
186
always @ (posedge MTxClk or posedge TxReset)
187
begin
188
  if(TxReset)
189 352 olof
    MuxedAbort <=  1'b0;
190 15 mohor
  else
191
  if(TxStartFrmIn)
192 352 olof
    MuxedAbort <=  1'b0;
193 15 mohor
  else
194
  if(TxAbortIn & ~TxAbortInLatched & TxUsedDataOutDetected)
195 352 olof
    MuxedAbort <=  1'b1;
196 15 mohor
end
197
 
198
 
199
// Generating muxed done signal
200
always @ (posedge MTxClk or posedge TxReset)
201
begin
202
  if(TxReset)
203 352 olof
    MuxedDone <=  1'b0;
204 15 mohor
  else
205
  if(TxStartFrmIn)
206 352 olof
    MuxedDone <=  1'b0;
207 15 mohor
  else
208 256 mohor
  if(TxDoneIn & (~TxDoneInLatched) & TxUsedDataOutDetected)
209 352 olof
    MuxedDone <=  1'b1;
210 15 mohor
end
211
 
212 251 mohor
 
213 15 mohor
// TxDoneOut
214 256 mohor
assign TxDoneOut  = CtrlMux? ((~TxStartFrmIn) & (~BlockTxDone) & MuxedDone) :
215
                             ((~TxStartFrmIn) & (~BlockTxDone) & TxDoneIn);
216 15 mohor
 
217
// TxAbortOut
218 256 mohor
assign TxAbortOut  = CtrlMux? ((~TxStartFrmIn) & (~BlockTxDone) & MuxedAbort) :
219
                              ((~TxStartFrmIn) & (~BlockTxDone) & TxAbortIn);
220 15 mohor
 
221
// TxUsedDataOut
222
assign TxUsedDataOut  = ~CtrlMux & TxUsedDataIn;
223
 
224
// TxStartFrmOut
225
assign TxStartFrmOut = CtrlMux? TxCtrlStartFrm : (TxStartFrmIn & ~Pause);
226
 
227
 
228
// TxEndFrmOut
229
assign TxEndFrmOut = CtrlMux? TxCtrlEndFrm : TxEndFrmIn;
230
 
231
 
232
// TxDataOut[7:0]
233
assign TxDataOut[7:0] = CtrlMux? ControlData[7:0] : TxDataIn[7:0];
234
 
235
 
236
// PadOut
237
assign PadOut = PadIn | SendingCtrlFrm;
238
 
239
 
240
// CrcEnOut
241
assign CrcEnOut = CrcEnIn | SendingCtrlFrm;
242
 
243
 
244
 
245
// Connecting receivecontrol module
246 352 olof
eth_receivecontrol receivecontrol1
247 15 mohor
(
248
 .MTxClk(MTxClk), .MRxClk(MRxClk), .TxReset(TxReset), .RxReset(RxReset), .RxData(RxData),
249
 .RxValid(RxValid), .RxStartFrm(RxStartFrm), .RxEndFrm(RxEndFrm), .RxFlow(RxFlow),
250 261 mohor
 .ReceiveEnd(ReceiveEnd), .MAC(MAC), .DlyCrcEn(DlyCrcEn), .TxDoneIn(TxDoneIn),
251 15 mohor
 .TxAbortIn(TxAbortIn), .TxStartFrmOut(TxStartFrmOut), .ReceivedLengthOK(ReceivedLengthOK),
252
 .ReceivedPacketGood(ReceivedPacketGood), .TxUsedDataOutDetected(TxUsedDataOutDetected),
253 261 mohor
 .Pause(Pause), .ReceivedPauseFrm(ReceivedPauseFrm), .AddressOK(ControlFrmAddressOK),
254 272 tadejm
 .r_PassAll(r_PassAll), .RxStatusWriteLatched_sync2(RxStatusWriteLatched_sync2), .SetPauseTimer(SetPauseTimer)
255 15 mohor
);
256
 
257
 
258 352 olof
eth_transmitcontrol transmitcontrol1
259 15 mohor
(
260
 .MTxClk(MTxClk), .TxReset(TxReset), .TxUsedDataIn(TxUsedDataIn), .TxUsedDataOut(TxUsedDataOut),
261
 .TxDoneIn(TxDoneIn), .TxAbortIn(TxAbortIn), .TxStartFrmIn(TxStartFrmIn), .TPauseRq(TPauseRq),
262
 .TxUsedDataOutDetected(TxUsedDataOutDetected), .TxFlow(TxFlow), .DlyCrcEn(DlyCrcEn), .TxPauseTV(TxPauseTV),
263
 .MAC(MAC), .TxCtrlStartFrm(TxCtrlStartFrm), .TxCtrlEndFrm(TxCtrlEndFrm), .SendingCtrlFrm(SendingCtrlFrm),
264 251 mohor
 .CtrlMux(CtrlMux), .ControlData(ControlData), .WillSendControlFrame(WillSendControlFrame), .BlockTxDone(BlockTxDone)
265 15 mohor
);
266
 
267
 
268
 
269
endmodule

powered by: WebSVN 2.1.0

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