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

Subversion Repositories ethmac

[/] [ethmac/] [tags/] [rel_14/] [rtl/] [verilog/] [eth_maccontrol.v] - Blame information for rev 338

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

powered by: WebSVN 2.1.0

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