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

Subversion Repositories ethmac

[/] [ethmac/] [trunk/] [rtl/] [verilog/] [eth_macstatus.v] - Blame information for rev 37

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

Line No. Rev Author Line
1 15 mohor
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  eth_macstatus.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.3  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.2  2001/09/11 14:17:00  mohor
49
// Few little NCSIM warnings fixed.
50
//
51 18 mohor
// 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 15 mohor
// Revision 1.1  2001/07/30 21:23:42  mohor
62
// Directory structure changed. Files checked and joind together.
63
//
64
//
65
//
66
//
67
//
68
 
69 22 mohor
`include "timescale.v"
70 15 mohor
 
71
 
72
module eth_macstatus(
73
                      MRxClk, Reset, ReceivedLengthOK, ReceiveEnd, TransmitEnd, ReceivedPacketGood, RxCrcError,
74
                      MRxErr, MRxDV, RxStateSFD, RxStateData, RxStatePreamble, RxStateIdle, Transmitting,
75
                      RxByteCnt, RxByteCntEq0, RxByteCntGreat2, RxByteCntMaxFrame, ReceivedPauseFrm
76
                    );
77
 
78
 
79
 
80
parameter Tp = 1;
81
 
82
 
83
input         MRxClk;
84
input         Reset;
85
input         RxCrcError;
86
input         MRxErr;
87
input         MRxDV;
88
 
89
input         RxStateSFD;
90
input   [1:0] RxStateData;
91
input         RxStatePreamble;
92
input         RxStateIdle;
93
input         Transmitting;
94
input  [15:0] RxByteCnt;
95
input         RxByteCntEq0;
96
input         RxByteCntGreat2;
97
input         RxByteCntMaxFrame;
98
input         ReceivedPauseFrm;
99
 
100
output        ReceivedLengthOK;
101
output        ReceiveEnd;
102
output        ReceivedPacketGood;
103
output        TransmitEnd;
104
 
105
reg           ReceiveEnd;
106
 
107
reg           LatchedCrcError;
108
reg           LatchedMRxErr;
109
reg           PreloadRxStatus;
110
reg    [15:0] LatchedRxByteCnt;
111
 
112
wire          TakeSample;
113
 
114
 
115
// Crc error
116
always @ (posedge MRxClk or posedge Reset)
117
begin
118
  if(Reset)
119
    LatchedCrcError <=#Tp 1'b0;
120
  else
121
    begin
122
      if(RxStateSFD)
123
        LatchedCrcError <=#Tp 1'b0;
124
      else
125
      if(RxStateData[0])
126
        LatchedCrcError <=#Tp RxCrcError & ~RxByteCntEq0;
127
    end
128
end
129
 
130
 
131
// LatchedMRxErr
132
always @ (posedge MRxClk or posedge Reset)
133
begin
134
  if(Reset)
135
    LatchedMRxErr <=#Tp 1'b0;
136
  else
137
  if(~MRxErr & MRxDV & RxStateIdle & ~Transmitting)
138
    LatchedMRxErr <=#Tp 1'b0;
139
  else
140 18 mohor
  if(MRxErr & MRxDV & (RxStatePreamble | RxStateSFD | (|RxStateData) | RxStateIdle & ~Transmitting))
141 15 mohor
    LatchedMRxErr <=#Tp 1'b1;
142
end
143
 
144
 
145
// ReceivedPacketGood
146
assign ReceivedPacketGood = ~LatchedCrcError & ~LatchedMRxErr;
147
 
148
 
149
// ReceivedLengthOK
150
assign ReceivedLengthOK = LatchedRxByteCnt[15:0] > 63 & LatchedRxByteCnt[15:0] < 1519;
151
 
152
 
153
 
154
// LatchedRxByteCnt[15:0]
155
always @ (posedge MRxClk or posedge Reset)
156
begin
157
  if(Reset)
158
    LatchedRxByteCnt[15:0] <=#Tp 16'h0;
159
  else
160
    begin
161
      if(RxStateSFD)
162
        LatchedRxByteCnt[15:0] <=#Tp RxByteCnt[15:0];
163
      else
164
      if(RxStateData[0])
165
        LatchedRxByteCnt[15:0] <=#Tp RxByteCnt[15:0];
166
    end
167
end
168
 
169
 
170
 
171
// Time to take a sample
172
assign TakeSample = |RxStateData     & ~MRxDV & RxByteCntGreat2  |
173
                     RxStateData[0]  &  MRxDV & RxByteCntMaxFrame;
174
 
175
 
176
// PreloadRxStatus
177
always @ (posedge MRxClk or posedge Reset)
178
begin
179
  if(Reset)
180
    PreloadRxStatus <=#Tp 1'b0;
181
  else
182
    PreloadRxStatus <=#Tp TakeSample;
183
end
184
 
185
 
186
 
187
// ReceiveEnd
188
always @ (posedge MRxClk or posedge Reset)
189
begin
190
  if(Reset)
191
    ReceiveEnd  <=#Tp 1'b0;
192
  else
193
    ReceiveEnd  <=#Tp PreloadRxStatus;
194
end
195
 
196
 
197
endmodule

powered by: WebSVN 2.1.0

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