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

Subversion Repositories ethmac

[/] [ethmac/] [branches/] [unneback/] [rtl/] [verilog/] [eth_rxaddrcheck.v] - Blame information for rev 50

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
// Revision 1.1  2002/02/08 12:51:54  ditt
44
// Initial release of the ethernet addresscheck module.
45
//
46
//
47
//
48
//
49
//
50
 
51
 
52
`include "timescale.v"
53
 
54
 
55
module eth_rxaddrcheck(  MRxClk,  Reset, RxData, Broadcast ,r_Bro ,r_Pro,
56
                                                 ByteCntEq2, ByteCntEq3, ByteCntEq4, ByteCntEq5,
57
                                             ByteCntEq6, ByteCntEq7, HASH0, HASH1,
58
                                                 CrcHash, CrcHashGood, StateData, RxEndFrm,
59
                                                 Multicast, MAC, RxAbort
60
                       );
61
 
62
parameter Tp = 1;
63
 
64
  input        MRxClk;
65
  input        Reset;
66
  input [7:0]  RxData;
67
  input        Broadcast;
68
  input        r_Bro;
69
  input        r_Pro;
70
  input        ByteCntEq2;
71
  input        ByteCntEq3;
72
  input        ByteCntEq4;
73
  input        ByteCntEq5;
74
  input        ByteCntEq6;
75
  input        ByteCntEq7;
76
  input [31:0] HASH0;
77
  input [31:0] HASH1;
78
  input [5:0]  CrcHash;
79
  input        CrcHashGood;
80
  input        Multicast;
81
  input [47:0] MAC;
82
  input [1:0]  StateData;
83
  input        RxEndFrm;
84
 
85
  output       RxAbort;
86
 
87
 
88
 wire BroadcastOK;
89
 wire ByteCntEq2;
90
 wire ByteCntEq3;
91
 wire ByteCntEq4;
92
 wire ByteCntEq5;
93
 wire RxAddressInvalid;
94
 wire RxCheckEn;
95
 reg [31:0] IntHash;
96
 reg [7:0]  ByteHash;
97
 reg MulticastOK;
98
 reg UnicastOK;
99
 reg RxAbort;
100
 reg CrcHashGood_d;  // delay HashGood by one cycle
101
 reg HashBit;
102
 
103
 assign RxAddressInvalid = ~(UnicastOK | BroadcastOK | MulticastOK);
104
 
105
 
106
 assign BroadcastOK = (Broadcast & ~r_Bro ) | r_Pro;
107
 
108
 assign RxCheckEn   = | StateData;
109
 
110
 // Address Error Reported at end of address cycle
111
 // RxAbort clears after one cycle
112
 
113
 always @ (posedge MRxClk or posedge Reset)
114
 begin
115
   if(Reset)
116
     RxAbort <= #Tp 1'b0;
117
   else if( CrcHashGood_d & RxAddressInvalid & RxCheckEn)
118
        RxAbort <= #Tp 1'b1;
119
   else
120
      RxAbort <= #Tp 1'b0;
121
 end
122
 
123
 // Hash Address Check, Multicast
124
 
125
 
126
// delay CrcHashGood by 1 cycle
127
always @ (posedge MRxClk or posedge Reset)
128
  begin
129
    if(Reset)
130
      CrcHashGood_d <= #Tp 1'b0;
131
        else
132
          CrcHashGood_d <= #Tp CrcHashGood;
133
  end
134
 
135
 always @ (posedge MRxClk or posedge Reset)
136
  begin
137
    if(Reset)
138
      MulticastOK <= #Tp 1'b0;
139
        else if (RxEndFrm | RxAbort)
140
       MulticastOK <= #Tp 1'b0;
141
    else if(CrcHashGood & Multicast)
142
          MulticastOK <= #Tp HashBit;
143
 
144
  end
145
 
146
 
147
 
148
 
149
 // Address Detection (unicast)
150
 // start with ByteCntEq2 due to delay of addres from RxData
151
 
152
always @ (posedge MRxClk or posedge Reset)
153
begin
154
  if(Reset)
155
    UnicastOK <= #Tp 1'b0;
156
  else
157
  if( RxCheckEn & ByteCntEq2)
158
    UnicastOK <= #Tp   RxData[7:0] == MAC[7:0];
159
  else
160
  if( RxCheckEn & ByteCntEq3)
161
    UnicastOK <= #Tp ( RxData[7:0] == MAC[15:8]) & UnicastOK;
162
  else
163
  if( RxCheckEn & ByteCntEq4)
164
    UnicastOK <= #Tp ( RxData[7:0] == MAC[23:16]) & UnicastOK;
165
  else
166
  if( RxCheckEn & ByteCntEq5)
167
    UnicastOK <= #Tp ( RxData[7:0] == MAC[31:24]) & UnicastOK;
168
  else
169
  if( RxCheckEn & ByteCntEq6)
170
    UnicastOK <= #Tp ( RxData[7:0] == MAC[39:32])  & UnicastOK;
171
  else
172
  if( RxCheckEn & ByteCntEq7)
173
    UnicastOK <= #Tp ( RxData[7:0] == MAC[47:40]) & UnicastOK;
174
  else
175
  if(RxEndFrm | RxAbort)
176
    UnicastOK <= #Tp 1'b0;
177
end
178
 
179
 always@(HASH0 or HASH1 or CrcHash[5])
180
        begin
181
        if (CrcHash[5])
182
          IntHash = HASH1;
183
        else
184
          IntHash = HASH0;
185
 
186
        end
187
 
188
    always@(CrcHash or IntHash)
189
                begin
190
                  case(CrcHash[4:3])
191
                    2'b00: ByteHash = IntHash[7:0];
192
                    2'b01: ByteHash = IntHash[15:8];
193
                    2'b10: ByteHash = IntHash[23:16];
194
                    2'b11: ByteHash = IntHash[31:24];
195
                  endcase
196
            end
197
 
198
  always@(CrcHash or ByteHash)
199
     begin
200
           case(CrcHash[2:0])
201
                 3'h0: HashBit =  ByteHash[0];
202
                 3'h1: HashBit =  ByteHash[1];
203
                 3'h2: HashBit =  ByteHash[2];
204
                 3'h3: HashBit =  ByteHash[3];
205
                 3'h4: HashBit =  ByteHash[4];
206
                 3'h5: HashBit =  ByteHash[5];
207
                 3'h6: HashBit =  ByteHash[6];
208
                 3'h7: HashBit =  ByteHash[7];
209
           endcase
210
         end
211
 
212
endmodule

powered by: WebSVN 2.1.0

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