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

Subversion Repositories ethmac

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

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
parameter Tp = 1;
86
 
87
  input        MRxClk;
88
  input        Reset;
89
  input [7:0]  RxData;
90
  input        Broadcast;
91
  input        r_Bro;
92
  input        r_Pro;
93 341 olof
  input        ByteCntEq0;
94 50 billditt
  input        ByteCntEq2;
95
  input        ByteCntEq3;
96
  input        ByteCntEq4;
97
  input        ByteCntEq5;
98
  input        ByteCntEq6;
99
  input        ByteCntEq7;
100
  input [31:0] HASH0;
101
  input [31:0] HASH1;
102
  input [5:0]  CrcHash;
103
  input        CrcHashGood;
104
  input        Multicast;
105
  input [47:0] MAC;
106
  input [1:0]  StateData;
107
  input        RxEndFrm;
108 261 mohor
  input        PassAll;
109
  input        ControlFrmAddressOK;
110 50 billditt
 
111
  output       RxAbort;
112 250 mohor
  output       AddressMiss;
113 50 billditt
 
114
 wire BroadcastOK;
115
 wire ByteCntEq2;
116
 wire ByteCntEq3;
117
 wire ByteCntEq4;
118
 wire ByteCntEq5;
119
 wire RxAddressInvalid;
120
 wire RxCheckEn;
121 65 mohor
 wire HashBit;
122
 wire [31:0] IntHash;
123 50 billditt
 reg [7:0]  ByteHash;
124
 reg MulticastOK;
125
 reg UnicastOK;
126
 reg RxAbort;
127 250 mohor
 reg AddressMiss;
128 50 billditt
 
129 93 mohor
assign RxAddressInvalid = ~(UnicastOK | BroadcastOK | MulticastOK | r_Pro);
130 50 billditt
 
131 75 mohor
assign BroadcastOK = Broadcast & ~r_Bro;
132 50 billditt
 
133 65 mohor
assign RxCheckEn   = | StateData;
134 50 billditt
 
135
 // Address Error Reported at end of address cycle
136
 // RxAbort clears after one cycle
137
 
138 65 mohor
always @ (posedge MRxClk or posedge Reset)
139
begin
140
  if(Reset)
141
    RxAbort <= #Tp 1'b0;
142 148 mohor
  else if(RxAddressInvalid & ByteCntEq7 & RxCheckEn)
143 65 mohor
    RxAbort <= #Tp 1'b1;
144
  else
145
    RxAbort <= #Tp 1'b0;
146
end
147 50 billditt
 
148
 
149 250 mohor
// This ff holds the "Address Miss" information that is written to the RX BD status.
150
always @ (posedge MRxClk or posedge Reset)
151
begin
152
  if(Reset)
153
    AddressMiss <= #Tp 1'b0;
154 341 olof
  else if(ByteCntEq0)
155
    AddressMiss <= #Tp 1'b0;
156 250 mohor
  else if(ByteCntEq7 & RxCheckEn)
157 261 mohor
    AddressMiss <= #Tp (~(UnicastOK | BroadcastOK | MulticastOK | (PassAll & ControlFrmAddressOK)));
158 250 mohor
end
159 50 billditt
 
160 250 mohor
 
161
// Hash Address Check, Multicast
162 50 billditt
always @ (posedge MRxClk or posedge Reset)
163 65 mohor
begin
164
  if(Reset)
165
    MulticastOK <= #Tp 1'b0;
166
  else if(RxEndFrm | RxAbort)
167
    MulticastOK <= #Tp 1'b0;
168
  else if(CrcHashGood & Multicast)
169
    MulticastOK <= #Tp HashBit;
170
end
171 50 billditt
 
172
 
173 65 mohor
// Address Detection (unicast)
174
// start with ByteCntEq2 due to delay of addres from RxData
175 50 billditt
always @ (posedge MRxClk or posedge Reset)
176
begin
177
  if(Reset)
178
    UnicastOK <= #Tp 1'b0;
179
  else
180 65 mohor
  if(RxCheckEn & ByteCntEq2)
181 83 mohor
    UnicastOK <= #Tp   RxData[7:0] == MAC[47:40];
182 50 billditt
  else
183 65 mohor
  if(RxCheckEn & ByteCntEq3)
184 83 mohor
    UnicastOK <= #Tp ( RxData[7:0] == MAC[39:32]) & UnicastOK;
185 50 billditt
  else
186 65 mohor
  if(RxCheckEn & ByteCntEq4)
187 83 mohor
    UnicastOK <= #Tp ( RxData[7:0] == MAC[31:24]) & UnicastOK;
188 50 billditt
  else
189 65 mohor
  if(RxCheckEn & ByteCntEq5)
190 83 mohor
    UnicastOK <= #Tp ( RxData[7:0] == MAC[23:16]) & UnicastOK;
191 50 billditt
  else
192 65 mohor
  if(RxCheckEn & ByteCntEq6)
193 83 mohor
    UnicastOK <= #Tp ( RxData[7:0] == MAC[15:8])  & UnicastOK;
194 50 billditt
  else
195 65 mohor
  if(RxCheckEn & ByteCntEq7)
196 83 mohor
    UnicastOK <= #Tp ( RxData[7:0] == MAC[7:0])   & UnicastOK;
197 50 billditt
  else
198
  if(RxEndFrm | RxAbort)
199
    UnicastOK <= #Tp 1'b0;
200
end
201
 
202 65 mohor
assign IntHash = (CrcHash[5])? HASH1 : HASH0;
203
 
204
always@(CrcHash or IntHash)
205
begin
206
  case(CrcHash[4:3])
207
    2'b00: ByteHash = IntHash[7:0];
208
    2'b01: ByteHash = IntHash[15:8];
209
    2'b10: ByteHash = IntHash[23:16];
210
    2'b11: ByteHash = IntHash[31:24];
211
  endcase
212
end
213
 
214
assign HashBit = ByteHash[CrcHash[2:0]];
215 50 billditt
 
216 65 mohor
 
217
endmodule

powered by: WebSVN 2.1.0

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