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

Subversion Repositories ethmac

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

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

powered by: WebSVN 2.1.0

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