1 //////////////////////////////////////////////////////////////////////
3 //// eth_rxaddrcheck.v ////
5 //// This file is part of the Ethernet IP core project ////
6 //// http://www.opencores.org/cores/ethmac/ ////
9 //// - Bill Dittenhofer (billditt@aol.com) ////
11 //// All additional information is avaliable in the Readme.txt ////
14 //////////////////////////////////////////////////////////////////////
16 //// Copyright (C) 2001 Authors ////
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. ////
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. ////
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 ////
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 ////
39 //////////////////////////////////////////////////////////////////////
41 // CVS Revision History
43 // $Log: eth_rxaddrcheck.v,v $
44 // Revision 1.9 2002/11/22 01:57:06 mohor
45 // Rx Flow control fixed. CF flag added to the RX buffer descriptor. RxAbort
48 // Revision 1.8 2002/11/19 17:34:52 mohor
49 // AddressMiss status is connecting to the Rx BD. AddressMiss is identifying
50 // that a frame was received because of the promiscous mode.
52 // Revision 1.7 2002/09/04 18:41:06 mohor
53 // Bug when last byte of destination address was not checked fixed.
55 // Revision 1.6 2002/03/20 15:14:11 mohor
56 // When in promiscous mode some frames were not received correctly. Fixed.
58 // Revision 1.5 2002/03/02 21:06:32 mohor
59 // Log info was missing.
62 // Revision 1.1 2002/02/08 12:51:54 ditt
63 // Initial release of the ethernet addresscheck module.
71 `include "timescale.v"
74 module eth_rxaddrcheck(MRxClk
, Reset
, RxData
, Broadcast
,r_Bro
,r_Pro
,
75 ByteCntEq2
, ByteCntEq3
, ByteCntEq4
, ByteCntEq5
,
76 ByteCntEq6
, ByteCntEq7
, HASH0
, HASH1
,
77 CrcHash
, CrcHashGood
, StateData
, RxEndFrm
,
78 Multicast
, MAC
, RxAbort
, AddressMiss
, PassAll
,
102 input [1:0] StateData
;
105 input ControlFrmAddressOK
;
115 wire RxAddressInvalid
;
125 assign RxAddressInvalid
= ~(UnicastOK | BroadcastOK | MulticastOK | r_Pro
);
127 assign BroadcastOK
= Broadcast
& ~r_Bro
;
129 assign RxCheckEn
= | StateData
;
131 // Address Error Reported at end of address cycle
132 // RxAbort clears after one cycle
134 always @ (posedge MRxClk
or posedge Reset
)
138 else if(RxAddressInvalid
& ByteCntEq7
& RxCheckEn
)
145 // This ff holds the "Address Miss" information that is written to the RX BD status.
146 always @ (posedge MRxClk
or posedge Reset
)
149 AddressMiss
<= #Tp
1'b0;
150 else if(ByteCntEq7
& RxCheckEn
)
151 AddressMiss
<= #
Tp (~(UnicastOK | BroadcastOK | MulticastOK |
(PassAll
& ControlFrmAddressOK
)));
155 // Hash Address Check, Multicast
156 always @ (posedge MRxClk
or posedge Reset
)
159 MulticastOK
<= #Tp
1'b0;
160 else if(RxEndFrm | RxAbort
)
161 MulticastOK
<= #Tp
1'b0;
162 else if(CrcHashGood
& Multicast
)
163 MulticastOK
<= #Tp HashBit
;
167 // Address Detection (unicast)
168 // start with ByteCntEq2 due to delay of addres from RxData
169 always @ (posedge MRxClk
or posedge Reset
)
172 UnicastOK
<= #Tp
1'b0;
174 if(RxCheckEn
& ByteCntEq2
)
175 UnicastOK
<= #Tp RxData
[7:0] == MAC
[47:40];
177 if(RxCheckEn
& ByteCntEq3
)
178 UnicastOK
<= #
Tp ( RxData
[7:0] == MAC
[39:32]) & UnicastOK
;
180 if(RxCheckEn
& ByteCntEq4
)
181 UnicastOK
<= #
Tp ( RxData
[7:0] == MAC
[31:24]) & UnicastOK
;
183 if(RxCheckEn
& ByteCntEq5
)
184 UnicastOK
<= #
Tp ( RxData
[7:0] == MAC
[23:16]) & UnicastOK
;
186 if(RxCheckEn
& ByteCntEq6
)
187 UnicastOK
<= #
Tp ( RxData
[7:0] == MAC
[15:8]) & UnicastOK
;
189 if(RxCheckEn
& ByteCntEq7
)
190 UnicastOK
<= #
Tp ( RxData
[7:0] == MAC
[7:0]) & UnicastOK
;
192 if(RxEndFrm | RxAbort
)
193 UnicastOK
<= #Tp
1'b0;
196 assign IntHash
= (CrcHash
[5])? HASH1
: HASH0
;
198 always@(CrcHash
or IntHash
)
201 2'b00: ByteHash
= IntHash
[7:0];
202 2'b01: ByteHash
= IntHash
[15:8];
203 2'b10: ByteHash
= IntHash
[23:16];
204 2'b11: ByteHash
= IntHash
[31:24];
208 assign HashBit
= ByteHash
[CrcHash
[2:0]];