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

Subversion Repositories or1k

[/] [or1k/] [tags/] [first/] [orp/] [orp_soc/] [rtl/] [verilog/] [ethernet.old/] [eth_maccontrol.v] - Blame information for rev 746

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 746 lampret
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  eth_maccontrol.v                                            ////
4
////                                                              ////
5
////  This file is part of the Ethernet IP core project           ////
6
////  http://www.opencores.org/projects/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.3  2002/01/23 10:28:16  mohor
45
// Link in the header changed.
46
//
47
// 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
// 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
// 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
`include "timescale.v"
73
 
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
 
138
 
139
// Signal TxUsedDataOut was detected (a transfer is already in progress)
140
always @ (posedge MTxClk or posedge TxReset)
141
begin
142
  if(TxReset)
143
    TxUsedDataOutDetected <= #Tp 1'b0;
144
  else
145
  if(TxDoneIn | TxAbortIn)
146
    TxUsedDataOutDetected <= #Tp 1'b0;
147
  else
148
  if(TxUsedDataOut)
149
    TxUsedDataOutDetected <= #Tp 1'b1;
150
end
151
 
152
 
153
// Latching variables
154
always @ (posedge MTxClk or posedge TxReset)
155
begin
156
  if(TxReset)
157
    begin
158
      TxAbortInLatched <= #Tp 1'b0;
159
      TxDoneInLatched  <= #Tp 1'b0;
160
    end
161
  else
162
    begin
163
      TxAbortInLatched <= #Tp TxAbortIn;
164
      TxDoneInLatched  <= #Tp TxDoneIn;
165
    end
166
end
167
 
168
 
169
 
170
// Generating muxed abort signal
171
always @ (posedge MTxClk or posedge TxReset)
172
begin
173
  if(TxReset)
174
    MuxedAbort <= #Tp 1'b0;
175
  else
176
  if(TxStartFrmIn)
177
    MuxedAbort <= #Tp 1'b0;
178
  else
179
  if(TxAbortIn & ~TxAbortInLatched & TxUsedDataOutDetected)
180
    MuxedAbort <= #Tp 1'b1;
181
end
182
 
183
 
184
// Generating muxed done signal
185
always @ (posedge MTxClk or posedge TxReset)
186
begin
187
  if(TxReset)
188
    MuxedDone <= #Tp 1'b0;
189
  else
190
  if(TxStartFrmIn)
191
    MuxedDone <= #Tp 1'b0;
192
  else
193
  if(TxDoneIn & ~TxDoneInLatched & TxUsedDataOutDetected)
194
    MuxedDone <= #Tp 1'b1;
195
end
196
 
197
// TxDoneOut
198
assign TxDoneOut  = CtrlMux? (~TxStartFrmIn & MuxedDone) :
199
                             (~TxStartFrmIn & TxDoneIn);
200
 
201
// TxAbortOut
202
assign TxAbortOut  = CtrlMux? (~TxStartFrmIn & MuxedAbort) :
203
                              (TxAbortIn);
204
 
205
// TxUsedDataOut
206
assign TxUsedDataOut  = ~CtrlMux & TxUsedDataIn;
207
 
208
// TxStartFrmOut
209
assign TxStartFrmOut = CtrlMux? TxCtrlStartFrm : (TxStartFrmIn & ~Pause);
210
 
211
 
212
// TxEndFrmOut
213
assign TxEndFrmOut = CtrlMux? TxCtrlEndFrm : TxEndFrmIn;
214
 
215
 
216
// TxDataOut[7:0]
217
assign TxDataOut[7:0] = CtrlMux? ControlData[7:0] : TxDataIn[7:0];
218
 
219
 
220
// PadOut
221
assign PadOut = PadIn | SendingCtrlFrm;
222
 
223
 
224
// CrcEnOut
225
assign CrcEnOut = CrcEnIn | SendingCtrlFrm;
226
 
227
 
228
 
229
// Connecting receivecontrol module
230
eth_receivecontrol receivecontrol1
231
(
232
 .MTxClk(MTxClk), .MRxClk(MRxClk), .TxReset(TxReset), .RxReset(RxReset), .RxData(RxData),
233
 .RxValid(RxValid), .RxStartFrm(RxStartFrm), .RxEndFrm(RxEndFrm), .RxFlow(RxFlow),
234
 .ReceiveEnd(ReceiveEnd), .MAC(MAC), .PassAll(PassAll), .DlyCrcEn(DlyCrcEn), .TxDoneIn(TxDoneIn),
235
 .TxAbortIn(TxAbortIn), .TxStartFrmOut(TxStartFrmOut), .ReceivedLengthOK(ReceivedLengthOK),
236
 .ReceivedPacketGood(ReceivedPacketGood), .TxUsedDataOutDetected(TxUsedDataOutDetected),
237
 .Pause(Pause), .ReceivedPauseFrm(ReceivedPauseFrm)
238
);
239
 
240
 
241
eth_transmitcontrol transmitcontrol1
242
(
243
 .MTxClk(MTxClk), .TxReset(TxReset), .TxUsedDataIn(TxUsedDataIn), .TxUsedDataOut(TxUsedDataOut),
244
 .TxDoneIn(TxDoneIn), .TxAbortIn(TxAbortIn), .TxStartFrmIn(TxStartFrmIn), .TPauseRq(TPauseRq),
245
 .TxUsedDataOutDetected(TxUsedDataOutDetected), .TxFlow(TxFlow), .DlyCrcEn(DlyCrcEn), .TxPauseTV(TxPauseTV),
246
 .MAC(MAC), .TxCtrlStartFrm(TxCtrlStartFrm), .TxCtrlEndFrm(TxCtrlEndFrm), .SendingCtrlFrm(SendingCtrlFrm),
247
 .CtrlMux(CtrlMux), .ControlData(ControlData), .WillSendControlFrame(WillSendControlFrame)
248
);
249
 
250
 
251
 
252
endmodule

powered by: WebSVN 2.1.0

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