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

Subversion Repositories ethmac

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

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 354 olof
//// Copyright (C) 2001, 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 85 mohor
// $Log: not supported by cvs2svn $
49 354 olof
// Revision 1.8  2002/11/19 17:34:52  mohor
50 261 mohor
// AddressMiss status is connecting to the Rx BD. AddressMiss is identifying
51
// that a frame was received because of the promiscous mode.
52
//
53 250 mohor
// Revision 1.7  2002/09/04 18:41:06  mohor
54
// Bug when last byte of destination address was not checked fixed.
55
//
56 148 mohor
// Revision 1.6  2002/03/20 15:14:11  mohor
57
// When in promiscous mode some frames were not received correctly. Fixed.
58
//
59 93 mohor
// Revision 1.5  2002/03/02 21:06:32  mohor
60
// Log info was missing.
61 85 mohor
//
62 93 mohor
//
63 50 billditt
// Revision 1.1  2002/02/08 12:51:54  ditt
64
// Initial release of the ethernet addresscheck module.
65
//
66
//
67
//
68
//
69
//
70
 
71
 
72
`include "timescale.v"
73
 
74
 
75 65 mohor
module eth_rxaddrcheck(MRxClk,  Reset, RxData, Broadcast ,r_Bro ,r_Pro,
76
                       ByteCntEq2, ByteCntEq3, ByteCntEq4, ByteCntEq5,
77 341 olof
                       ByteCntEq6, ByteCntEq7, HASH0, HASH1, ByteCntEq0,
78 65 mohor
                       CrcHash,    CrcHashGood, StateData, RxEndFrm,
79 261 mohor
                       Multicast, MAC, RxAbort, AddressMiss, PassAll,
80
                       ControlFrmAddressOK
81 65 mohor
                      );
82 50 billditt
 
83
 
84
  input        MRxClk;
85
  input        Reset;
86
  input [7:0]  RxData;
87
  input        Broadcast;
88
  input        r_Bro;
89
  input        r_Pro;
90 341 olof
  input        ByteCntEq0;
91 50 billditt
  input        ByteCntEq2;
92
  input        ByteCntEq3;
93
  input        ByteCntEq4;
94
  input        ByteCntEq5;
95
  input        ByteCntEq6;
96
  input        ByteCntEq7;
97
  input [31:0] HASH0;
98
  input [31:0] HASH1;
99
  input [5:0]  CrcHash;
100
  input        CrcHashGood;
101
  input        Multicast;
102
  input [47:0] MAC;
103
  input [1:0]  StateData;
104
  input        RxEndFrm;
105 261 mohor
  input        PassAll;
106
  input        ControlFrmAddressOK;
107 50 billditt
 
108
  output       RxAbort;
109 250 mohor
  output       AddressMiss;
110 50 billditt
 
111
 wire BroadcastOK;
112
 wire ByteCntEq2;
113
 wire ByteCntEq3;
114
 wire ByteCntEq4;
115
 wire ByteCntEq5;
116
 wire RxAddressInvalid;
117
 wire RxCheckEn;
118 65 mohor
 wire HashBit;
119
 wire [31:0] IntHash;
120 50 billditt
 reg [7:0]  ByteHash;
121
 reg MulticastOK;
122
 reg UnicastOK;
123
 reg RxAbort;
124 250 mohor
 reg AddressMiss;
125 50 billditt
 
126 93 mohor
assign RxAddressInvalid = ~(UnicastOK | BroadcastOK | MulticastOK | r_Pro);
127 50 billditt
 
128 75 mohor
assign BroadcastOK = Broadcast & ~r_Bro;
129 50 billditt
 
130 65 mohor
assign RxCheckEn   = | StateData;
131 50 billditt
 
132
 // Address Error Reported at end of address cycle
133
 // RxAbort clears after one cycle
134
 
135 65 mohor
always @ (posedge MRxClk or posedge Reset)
136
begin
137
  if(Reset)
138 352 olof
    RxAbort <=  1'b0;
139 148 mohor
  else if(RxAddressInvalid & ByteCntEq7 & RxCheckEn)
140 352 olof
    RxAbort <=  1'b1;
141 65 mohor
  else
142 352 olof
    RxAbort <=  1'b0;
143 65 mohor
end
144 50 billditt
 
145
 
146 250 mohor
// This ff holds the "Address Miss" information that is written to the RX BD status.
147
always @ (posedge MRxClk or posedge Reset)
148
begin
149
  if(Reset)
150 352 olof
    AddressMiss <=  1'b0;
151 341 olof
  else if(ByteCntEq0)
152 352 olof
    AddressMiss <=  1'b0;
153 250 mohor
  else if(ByteCntEq7 & RxCheckEn)
154 352 olof
    AddressMiss <=  (~(UnicastOK | BroadcastOK | MulticastOK | (PassAll & ControlFrmAddressOK)));
155 250 mohor
end
156 50 billditt
 
157 250 mohor
 
158
// Hash Address Check, Multicast
159 50 billditt
always @ (posedge MRxClk or posedge Reset)
160 65 mohor
begin
161
  if(Reset)
162 352 olof
    MulticastOK <=  1'b0;
163 65 mohor
  else if(RxEndFrm | RxAbort)
164 352 olof
    MulticastOK <=  1'b0;
165 65 mohor
  else if(CrcHashGood & Multicast)
166 352 olof
    MulticastOK <=  HashBit;
167 65 mohor
end
168 50 billditt
 
169
 
170 65 mohor
// Address Detection (unicast)
171
// start with ByteCntEq2 due to delay of addres from RxData
172 50 billditt
always @ (posedge MRxClk or posedge Reset)
173
begin
174
  if(Reset)
175 352 olof
    UnicastOK <=  1'b0;
176 50 billditt
  else
177 65 mohor
  if(RxCheckEn & ByteCntEq2)
178 352 olof
    UnicastOK <=    RxData[7:0] == MAC[47:40];
179 50 billditt
  else
180 65 mohor
  if(RxCheckEn & ByteCntEq3)
181 352 olof
    UnicastOK <=  ( RxData[7:0] == MAC[39:32]) & UnicastOK;
182 50 billditt
  else
183 65 mohor
  if(RxCheckEn & ByteCntEq4)
184 352 olof
    UnicastOK <=  ( RxData[7:0] == MAC[31:24]) & UnicastOK;
185 50 billditt
  else
186 65 mohor
  if(RxCheckEn & ByteCntEq5)
187 352 olof
    UnicastOK <=  ( RxData[7:0] == MAC[23:16]) & UnicastOK;
188 50 billditt
  else
189 65 mohor
  if(RxCheckEn & ByteCntEq6)
190 352 olof
    UnicastOK <=  ( RxData[7:0] == MAC[15:8])  & UnicastOK;
191 50 billditt
  else
192 65 mohor
  if(RxCheckEn & ByteCntEq7)
193 352 olof
    UnicastOK <=  ( RxData[7:0] == MAC[7:0])   & UnicastOK;
194 50 billditt
  else
195
  if(RxEndFrm | RxAbort)
196 352 olof
    UnicastOK <=  1'b0;
197 50 billditt
end
198
 
199 65 mohor
assign IntHash = (CrcHash[5])? HASH1 : HASH0;
200
 
201
always@(CrcHash or IntHash)
202
begin
203
  case(CrcHash[4:3])
204
    2'b00: ByteHash = IntHash[7:0];
205
    2'b01: ByteHash = IntHash[15:8];
206
    2'b10: ByteHash = IntHash[23:16];
207
    2'b11: ByteHash = IntHash[31:24];
208
  endcase
209
end
210
 
211
assign HashBit = ByteHash[CrcHash[2:0]];
212 50 billditt
 
213 65 mohor
 
214
endmodule

powered by: WebSVN 2.1.0

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