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 251

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

powered by: WebSVN 2.1.0

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