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

Subversion Repositories ethmac

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

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

powered by: WebSVN 2.1.0

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