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

Subversion Repositories ethmac

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

powered by: WebSVN 2.1.0

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