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

Subversion Repositories ethmac

[/] [ethmac/] [trunk/] [rtl/] [verilog/] [eth_rxaddrcheck.v] - Blame information for rev 352

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

Line No. Rev Author Line
1 50 billditt
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  eth_rxaddrcheck.v                                           ////
4
////                                                              ////
5
////  This file is part of the Ethernet IP core project           ////
6 341 olof
////  http://www.opencores.org/project,ethmac/                    ////
7 50 billditt
////                                                              ////
8
////  Author(s):                                                  ////
9
////      - Bill Dittenhofer (billditt@aol.com)                   ////
10 341 olof
////      - Olof Kindgren    (olof@opencores.org)                 ////
11 50 billditt
////                                                              ////
12
////  All additional information is avaliable in the Readme.txt   ////
13
////  file.                                                       ////
14
////                                                              ////
15
//////////////////////////////////////////////////////////////////////
16
////                                                              ////
17 341 olof
//// Copyright (C) 2011 Authors                                   ////
18 50 billditt
////                                                              ////
19
//// This source file may be used and distributed without         ////
20
//// restriction provided that this copyright statement is not    ////
21
//// removed from the file and that any derivative work contains  ////
22
//// the original copyright notice and the associated disclaimer. ////
23
////                                                              ////
24
//// This source file is free software; you can redistribute it   ////
25
//// and/or modify it under the terms of the GNU Lesser General   ////
26
//// Public License as published by the Free Software Foundation; ////
27
//// either version 2.1 of the License, or (at your option) any   ////
28
//// later version.                                               ////
29
////                                                              ////
30
//// This source is distributed in the hope that it will be       ////
31
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
32
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
33
//// PURPOSE.  See the GNU Lesser General Public License for more ////
34
//// details.                                                     ////
35
////                                                              ////
36
//// You should have received a copy of the GNU Lesser General    ////
37
//// Public License along with this source; if not, download it   ////
38
//// from http://www.opencores.org/lgpl.shtml                     ////
39
////                                                              ////
40
//////////////////////////////////////////////////////////////////////
41
//
42 341 olof
// 2011-07-06 Olof Kindgren <olof@opencores.org>
43
// Reset AdressMiss when a new frame arrives. Otherwise it will report
44
// the last value when a frame is less than seven bytes
45
//
46 50 billditt
// CVS Revision History
47
//
48 341 olof
//
49 85 mohor
// $Log: not supported by cvs2svn $
50 341 olof
//
51
//  // Revision 1.8  2002/11/19 17:34:52  mohor
52 261 mohor
// AddressMiss status is connecting to the Rx BD. AddressMiss is identifying
53
// that a frame was received because of the promiscous mode.
54
//
55 250 mohor
// Revision 1.7  2002/09/04 18:41:06  mohor
56
// Bug when last byte of destination address was not checked fixed.
57
//
58 148 mohor
// Revision 1.6  2002/03/20 15:14:11  mohor
59
// When in promiscous mode some frames were not received correctly. Fixed.
60
//
61 93 mohor
// Revision 1.5  2002/03/02 21:06:32  mohor
62
// Log info was missing.
63 85 mohor
//
64 93 mohor
//
65 50 billditt
// Revision 1.1  2002/02/08 12:51:54  ditt
66
// Initial release of the ethernet addresscheck module.
67
//
68
//
69
//
70
//
71
//
72
 
73
 
74
`include "timescale.v"
75
 
76
 
77 65 mohor
module eth_rxaddrcheck(MRxClk,  Reset, RxData, Broadcast ,r_Bro ,r_Pro,
78
                       ByteCntEq2, ByteCntEq3, ByteCntEq4, ByteCntEq5,
79 341 olof
                       ByteCntEq6, ByteCntEq7, HASH0, HASH1, ByteCntEq0,
80 65 mohor
                       CrcHash,    CrcHashGood, StateData, RxEndFrm,
81 261 mohor
                       Multicast, MAC, RxAbort, AddressMiss, PassAll,
82
                       ControlFrmAddressOK
83 65 mohor
                      );
84 50 billditt
 
85
 
86
  input        MRxClk;
87
  input        Reset;
88
  input [7:0]  RxData;
89
  input        Broadcast;
90
  input        r_Bro;
91
  input        r_Pro;
92 341 olof
  input        ByteCntEq0;
93 50 billditt
  input        ByteCntEq2;
94
  input        ByteCntEq3;
95
  input        ByteCntEq4;
96
  input        ByteCntEq5;
97
  input        ByteCntEq6;
98
  input        ByteCntEq7;
99
  input [31:0] HASH0;
100
  input [31:0] HASH1;
101
  input [5:0]  CrcHash;
102
  input        CrcHashGood;
103
  input        Multicast;
104
  input [47:0] MAC;
105
  input [1:0]  StateData;
106
  input        RxEndFrm;
107 261 mohor
  input        PassAll;
108
  input        ControlFrmAddressOK;
109 50 billditt
 
110
  output       RxAbort;
111 250 mohor
  output       AddressMiss;
112 50 billditt
 
113
 wire BroadcastOK;
114
 wire ByteCntEq2;
115
 wire ByteCntEq3;
116
 wire ByteCntEq4;
117
 wire ByteCntEq5;
118
 wire RxAddressInvalid;
119
 wire RxCheckEn;
120 65 mohor
 wire HashBit;
121
 wire [31:0] IntHash;
122 50 billditt
 reg [7:0]  ByteHash;
123
 reg MulticastOK;
124
 reg UnicastOK;
125
 reg RxAbort;
126 250 mohor
 reg AddressMiss;
127 50 billditt
 
128 93 mohor
assign RxAddressInvalid = ~(UnicastOK | BroadcastOK | MulticastOK | r_Pro);
129 50 billditt
 
130 75 mohor
assign BroadcastOK = Broadcast & ~r_Bro;
131 50 billditt
 
132 65 mohor
assign RxCheckEn   = | StateData;
133 50 billditt
 
134
 // Address Error Reported at end of address cycle
135
 // RxAbort clears after one cycle
136
 
137 65 mohor
always @ (posedge MRxClk or posedge Reset)
138
begin
139
  if(Reset)
140 352 olof
    RxAbort <=  1'b0;
141 148 mohor
  else if(RxAddressInvalid & ByteCntEq7 & RxCheckEn)
142 352 olof
    RxAbort <=  1'b1;
143 65 mohor
  else
144 352 olof
    RxAbort <=  1'b0;
145 65 mohor
end
146 50 billditt
 
147
 
148 250 mohor
// This ff holds the "Address Miss" information that is written to the RX BD status.
149
always @ (posedge MRxClk or posedge Reset)
150
begin
151
  if(Reset)
152 352 olof
    AddressMiss <=  1'b0;
153 341 olof
  else if(ByteCntEq0)
154 352 olof
    AddressMiss <=  1'b0;
155 250 mohor
  else if(ByteCntEq7 & RxCheckEn)
156 352 olof
    AddressMiss <=  (~(UnicastOK | BroadcastOK | MulticastOK | (PassAll & ControlFrmAddressOK)));
157 250 mohor
end
158 50 billditt
 
159 250 mohor
 
160
// Hash Address Check, Multicast
161 50 billditt
always @ (posedge MRxClk or posedge Reset)
162 65 mohor
begin
163
  if(Reset)
164 352 olof
    MulticastOK <=  1'b0;
165 65 mohor
  else if(RxEndFrm | RxAbort)
166 352 olof
    MulticastOK <=  1'b0;
167 65 mohor
  else if(CrcHashGood & Multicast)
168 352 olof
    MulticastOK <=  HashBit;
169 65 mohor
end
170 50 billditt
 
171
 
172 65 mohor
// Address Detection (unicast)
173
// start with ByteCntEq2 due to delay of addres from RxData
174 50 billditt
always @ (posedge MRxClk or posedge Reset)
175
begin
176
  if(Reset)
177 352 olof
    UnicastOK <=  1'b0;
178 50 billditt
  else
179 65 mohor
  if(RxCheckEn & ByteCntEq2)
180 352 olof
    UnicastOK <=    RxData[7:0] == MAC[47:40];
181 50 billditt
  else
182 65 mohor
  if(RxCheckEn & ByteCntEq3)
183 352 olof
    UnicastOK <=  ( RxData[7:0] == MAC[39:32]) & UnicastOK;
184 50 billditt
  else
185 65 mohor
  if(RxCheckEn & ByteCntEq4)
186 352 olof
    UnicastOK <=  ( RxData[7:0] == MAC[31:24]) & UnicastOK;
187 50 billditt
  else
188 65 mohor
  if(RxCheckEn & ByteCntEq5)
189 352 olof
    UnicastOK <=  ( RxData[7:0] == MAC[23:16]) & UnicastOK;
190 50 billditt
  else
191 65 mohor
  if(RxCheckEn & ByteCntEq6)
192 352 olof
    UnicastOK <=  ( RxData[7:0] == MAC[15:8])  & UnicastOK;
193 50 billditt
  else
194 65 mohor
  if(RxCheckEn & ByteCntEq7)
195 352 olof
    UnicastOK <=  ( RxData[7:0] == MAC[7:0])   & UnicastOK;
196 50 billditt
  else
197
  if(RxEndFrm | RxAbort)
198 352 olof
    UnicastOK <=  1'b0;
199 50 billditt
end
200
 
201 65 mohor
assign IntHash = (CrcHash[5])? HASH1 : HASH0;
202
 
203
always@(CrcHash or IntHash)
204
begin
205
  case(CrcHash[4:3])
206
    2'b00: ByteHash = IntHash[7:0];
207
    2'b01: ByteHash = IntHash[15:8];
208
    2'b10: ByteHash = IntHash[23:16];
209
    2'b11: ByteHash = IntHash[31:24];
210
  endcase
211
end
212
 
213
assign HashBit = ByteHash[CrcHash[2:0]];
214 50 billditt
 
215 65 mohor
 
216
endmodule

powered by: WebSVN 2.1.0

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