source: XOpenSparcT1/trunk/OC-Ethernet/eth_rxstatem.v @ 6

Revision 6, 7.0 KB checked in by pntsvt00, 13 years ago (diff)

versione iniziale opensparc

Line 
1//////////////////////////////////////////////////////////////////////
2////                                                              ////
3////  eth_rxstatem.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////      - Novan Hartadi (novan@vlsi.itb.ac.id)                  ////
11////      - Mahmud Galela (mgalela@vlsi.itb.ac.id)                ////
12////                                                              ////
13////  All additional information is avaliable in the Readme.txt   ////
14////  file.                                                       ////
15////                                                              ////
16//////////////////////////////////////////////////////////////////////
17////                                                              ////
18//// Copyright (C) 2001 Authors                                   ////
19////                                                              ////
20//// This source file may be used and distributed without         ////
21//// restriction provided that this copyright statement is not    ////
22//// removed from the file and that any derivative work contains  ////
23//// the original copyright notice and the associated disclaimer. ////
24////                                                              ////
25//// This source file is free software; you can redistribute it   ////
26//// and/or modify it under the terms of the GNU Lesser General   ////
27//// Public License as published by the Free Software Foundation; ////
28//// either version 2.1 of the License, or (at your option) any   ////
29//// later version.                                               ////
30////                                                              ////
31//// This source is distributed in the hope that it will be       ////
32//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
33//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
34//// PURPOSE.  See the GNU Lesser General Public License for more ////
35//// details.                                                     ////
36////                                                              ////
37//// You should have received a copy of the GNU Lesser General    ////
38//// Public License along with this source; if not, download it   ////
39//// from http://www.opencores.org/lgpl.shtml                     ////
40////                                                              ////
41//////////////////////////////////////////////////////////////////////
42//
43// CVS Revision History
44//
45// $Log: not supported by cvs2svn $
46// Revision 1.5  2002/01/23 10:28:16  mohor
47// Link in the header changed.
48//
49// Revision 1.4  2001/10/19 08:43:51  mohor
50// eth_timescale.v changed to timescale.v This is done because of the
51// simulation of the few cores in a one joined project.
52//
53// Revision 1.3  2001/10/18 12:07:11  mohor
54// Status signals changed, Adress decoding changed, interrupt controller
55// added.
56//
57// Revision 1.2  2001/09/11 14:17:00  mohor
58// Few little NCSIM warnings fixed.
59//
60// Revision 1.1  2001/08/06 14:44:29  mohor
61// A define FPGA added to select between Artisan RAM (for ASIC) and Block Ram (For Virtex).
62// Include files fixed to contain no path.
63// File names and module names changed ta have a eth_ prologue in the name.
64// File eth_timescale.v is used to define timescale
65// All pin names on the top module are changed to contain _I, _O or _OE at the end.
66// Bidirectional signal MDIO is changed to three signals (Mdc_O, Mdi_I, Mdo_O
67// and Mdo_OE. The bidirectional signal must be created on the top level. This
68// is done due to the ASIC tools.
69//
70// Revision 1.1  2001/07/30 21:23:42  mohor
71// Directory structure changed. Files checked and joind together.
72//
73// Revision 1.2  2001/07/03 12:55:41  mohor
74// Minor changes because of the synthesys warnings.
75//
76//
77// Revision 1.1  2001/06/27 21:26:19  mohor
78// Initial release of the RxEthMAC module.
79//
80//
81//
82//
83
84
85`include "timescale.v"
86
87
88module eth_rxstatem (MRxClk, Reset, MRxDV, ByteCntEq0, ByteCntGreat2, Transmitting, MRxDEq5, MRxDEqD, 
89                     IFGCounterEq24, ByteCntMaxFrame, StateData, StateIdle, StatePreamble, StateSFD, 
90                     StateDrop
91                    );
92
93parameter Tp = 1;
94
95input         MRxClk;
96input         Reset;
97input         MRxDV;
98input         ByteCntEq0;
99input         ByteCntGreat2;
100input         MRxDEq5;
101input         Transmitting;
102input         MRxDEqD;
103input         IFGCounterEq24;
104input         ByteCntMaxFrame;
105
106output [1:0]  StateData;
107output        StateIdle;
108output        StateDrop;
109output        StatePreamble;
110output        StateSFD;
111
112reg           StateData0;
113reg           StateData1;
114reg           StateIdle;
115reg           StateDrop;
116reg           StatePreamble;
117reg           StateSFD;
118
119wire          StartIdle;
120wire          StartDrop;
121wire          StartData0;
122wire          StartData1;
123wire          StartPreamble;
124wire          StartSFD;
125
126
127// Defining the next state
128assign StartIdle = ~MRxDV & (StateDrop | StatePreamble | StateSFD | (|StateData));
129
130assign StartPreamble = MRxDV & ~MRxDEq5 & (StateIdle & ~Transmitting);
131
132assign StartSFD = MRxDV & MRxDEq5 & (StateIdle & ~Transmitting | StatePreamble);
133
134assign StartData0 = MRxDV & (StateSFD & MRxDEqD & IFGCounterEq24 | StateData1);
135
136assign StartData1 = MRxDV & StateData0 & (~ByteCntMaxFrame);
137
138assign StartDrop = MRxDV & (StateIdle & Transmitting | StateSFD & ~IFGCounterEq24 &  MRxDEqD
139                         |  StateData0 &  ByteCntMaxFrame
140                           );
141
142// Rx State Machine
143always @ (posedge MRxClk or posedge Reset)
144begin
145  if(Reset)
146    begin
147      StateIdle     <= #Tp 1'b0;
148      StateDrop     <= #Tp 1'b1;
149      StatePreamble <= #Tp 1'b0;
150      StateSFD      <= #Tp 1'b0;
151      StateData0    <= #Tp 1'b0;
152      StateData1    <= #Tp 1'b0;
153    end
154  else
155    begin
156      if(StartPreamble | StartSFD | StartDrop)
157        StateIdle <= #Tp 1'b0;
158      else
159      if(StartIdle)
160        StateIdle <= #Tp 1'b1;
161
162      if(StartIdle)
163        StateDrop <= #Tp 1'b0;
164      else
165      if(StartDrop)
166        StateDrop <= #Tp 1'b1;
167
168      if(StartSFD | StartIdle | StartDrop)
169        StatePreamble <= #Tp 1'b0;
170      else
171      if(StartPreamble)
172        StatePreamble <= #Tp 1'b1;
173
174      if(StartPreamble | StartIdle | StartData0 | StartDrop)
175        StateSFD <= #Tp 1'b0;
176      else
177      if(StartSFD)
178        StateSFD <= #Tp 1'b1;
179
180      if(StartIdle | StartData1 | StartDrop)
181        StateData0 <= #Tp 1'b0;
182      else
183      if(StartData0)
184        StateData0 <= #Tp 1'b1;
185
186      if(StartIdle | StartData0 | StartDrop)
187        StateData1 <= #Tp 1'b0;
188      else
189      if(StartData1)
190        StateData1 <= #Tp 1'b1;
191    end
192end
193
194assign StateData[1:0] = {StateData1, StateData0};
195
196endmodule
Note: See TracBrowser for help on using the repository browser.