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

Subversion Repositories openarty

[/] [openarty/] [trunk/] [rtl/] [rxehwmac.v] - Blame information for rev 31

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

Line No. Rev Author Line
1 31 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    rxehwmac.v
4
//
5
// Project:     OpenArty, an entirely open SoC based upon the Arty platform
6
//
7
// Purpose:     To remove MACs that aren't our own.  The input is a nibble
8
//              stream, where the first nibble is the first nibble of the
9
//      destination MAC (our MAC).  If enabled, this MAC is removed from the
10
//      stream.  If the MAC matches, the stream is allowed to continue.  If
11
//      the MAC doesn't match, the packet is thrown away.
12
//
13
// Creator:     Dan Gisselquist, Ph.D.
14
//              Gisselquist Technology, LLC
15
//
16
////////////////////////////////////////////////////////////////////////////////
17
//
18
// Copyright (C) 2016, Gisselquist Technology, LLC
19
//
20
// This program is free software (firmware): you can redistribute it and/or
21
// modify it under the terms of  the GNU General Public License as published
22
// by the Free Software Foundation, either version 3 of the License, or (at
23
// your option) any later version.
24
//
25
// This program is distributed in the hope that it will be useful, but WITHOUT
26
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
27
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
28
// for more details.
29
//
30
// You should have received a copy of the GNU General Public License along
31
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
32
// target there if the PDF file isn't present.)  If not, see
33
// <http://www.gnu.org/licenses/> for a copy.
34
//
35
// License:     GPL, v3, as defined and found on www.gnu.org,
36
//              http://www.gnu.org/licenses/gpl.html
37
//
38
//
39
////////////////////////////////////////////////////////////////////////////////
40
//
41
//
42
module  rxehwmac(i_clk, i_ce, i_en, i_cancel, i_hwmac, i_v, i_d, o_v, o_d, o_err, o_broadcast);
43
        input                   i_clk, i_ce, i_en, i_cancel;
44
        input           [47:0]   i_hwmac;
45
        input                   i_v;
46
        input           [3:0]    i_d;
47
        output  reg             o_v;
48
        output  reg     [3:0]    o_d;
49
        output  wire            o_err;
50
        output  reg             o_broadcast;
51
 
52
        reg     [47:0]   r_hwmac;
53
        reg             r_cancel, r_err, r_hwmatch, r_broadcast;
54
        reg     [19:0]   r_buf;
55
        reg     [29:0]   r_p;
56
 
57
        always @(posedge i_clk)
58
        if (i_ce)
59
        begin
60
                if (i_cancel)
61
                        r_cancel <= 1'b1;
62
                else if ((!i_v)&&(!o_v))
63
                        r_cancel <= 1'b0;
64
 
65
                if ((i_en)&&(i_v)&&(r_p[11]))
66
                begin
67
                        if (r_hwmac[47:44] != i_d)
68
                                r_hwmatch <= 1'b0;
69
                        if (4'hf != i_d)
70
                                r_broadcast<= 1'b0;
71
                end
72
 
73
                r_err <= (i_en)&&(!r_hwmatch)&&(!r_broadcast)&&(i_v);
74
                o_broadcast <= (r_broadcast)&&(!r_p[11])&&(i_v);
75
 
76
                r_buf <= { r_buf[14:0], i_v, i_d };
77
                if (((!i_v)&&(!o_v))||(i_cancel))
78
                begin
79
                        r_p <= 30'h3fff_ffff;
80
                        r_hwmac <= i_hwmac;
81
                        r_hwmatch   <= 1'b1;
82
                        r_broadcast <= 1'b1;
83
                        r_buf[ 4] <= 1'b0;
84
                        r_buf[ 9] <= 1'b0;
85
                        r_buf[14] <= 1'b0;
86
                        r_buf[19] <= 1'b0;
87
                        o_v <= 1'b0;
88
                        o_d <= i_d;
89
                end else begin
90
                        r_p <= { r_p[28:0], 1'b0 };
91
                        if (i_en)
92
                        begin
93
                                // Skip the first 6 bytes, and everything
94
                                // following if the MAC doesn't match
95
                                o_v <= (!r_p[11])&&(!r_cancel)&&(i_v);
96
                                o_d <= i_d;
97
                        end else begin
98
                                // In this case, we wish to ignore everything,
99
                                // but still duplicate the EtherType words
100
                                if (r_p[27])
101
                                        { o_v, o_d } <= { (i_v)&&(!r_cancel), i_d };
102
                                else
103
                                        { o_v, o_d } <= { (r_buf[19])&&(!r_cancel), r_buf[18:15] };
104
                        end
105
                end
106
 
107
                if ((!i_en)&&(r_p[27]))
108
                begin // Clear out the top half of the EtherType word
109
                        r_buf[18:15] <= 4'h0;
110
                        r_buf[13:10] <= 4'h0;
111
                end
112
        end
113
 
114
        assign  o_err = r_err;
115
 
116
endmodule

powered by: WebSVN 2.1.0

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