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 15

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

powered by: WebSVN 2.1.0

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