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

Subversion Repositories ethmac

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

powered by: WebSVN 2.1.0

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