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

Subversion Repositories openarty

[/] [openarty/] [trunk/] [rtl/] [rxeipchk.v] - Blame information for rev 37

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

Line No. Rev Author Line
1 33 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    rxeipchk.v
4
//
5
// Project:     OpenArty, an entirely open SoC based upon the Arty platform
6
//
7
// Purpose:     To cull any IP packets (EtherType=0x0806) from the stream
8
//              whose packet header checksums don't match.
9
//
10
// Creator:     Dan Gisselquist, Ph.D.
11
//              Gisselquist Technology, LLC
12
//
13
////////////////////////////////////////////////////////////////////////////////
14
//
15
// Copyright (C) 2016, Gisselquist Technology, LLC
16
//
17
// This program is free software (firmware): you can redistribute it and/or
18
// modify it under the terms of  the GNU General Public License as published
19
// by the Free Software Foundation, either version 3 of the License, or (at
20
// your option) any later version.
21
//
22
// This program is distributed in the hope that it will be useful, but WITHOUT
23
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
24
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
25
// for more details.
26
//
27
// You should have received a copy of the GNU General Public License along
28
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
29
// target there if the PDF file isn't present.)  If not, see
30
// <http://www.gnu.org/licenses/> for a copy.
31
//
32
// License:     GPL, v3, as defined and found on www.gnu.org,
33
//              http://www.gnu.org/licenses/gpl.html
34
//
35
//
36
////////////////////////////////////////////////////////////////////////////////
37
//
38
//
39
module rxeipchk(i_clk, i_ce, i_en, i_cancel, i_v, i_d, o_err);
40
        input                   i_clk, i_ce, i_en, i_cancel;
41
        input                   i_v;    // Valid
42
        input           [3:0]    i_d;    // Data nibble
43
        output  reg             o_err;
44
 
45
        reg             r_v;
46
        reg     [15:0]   r_word;
47
        reg     [7:0]    r_cnt;
48
        reg     [5:0]    r_idx;
49
        always @(posedge i_clk)
50
        if (i_ce)
51
        begin
52
                if ((!i_v)||(i_cancel))
53
                begin
54
                        r_cnt <= 0;
55
                        r_idx <= 0;
56
                end else if(i_v)
57
                begin
58
                        if (!(&r_cnt))
59
                                r_cnt <= r_cnt + 1'b1;
60
                        if (&r_cnt)
61
                                r_v <= 1'b0;
62
                        else
63
                                r_v <= (r_cnt[1:0] == 2'b11);
64
                        if (r_cnt[1:0]==2'b11)
65
                                r_idx[5:0] <= r_cnt[7:2];
66
                        if (!r_cnt[0])
67
                                r_word <= { r_word[7:0], 4'h0, i_d };
68
                        else
69
                                r_word[7:4] <= i_d;
70
                end
71
        end
72
 
73
        reg             r_ip;
74
        reg     [5:0]    r_hlen;
75
        reg     [16:0]   r_check;
76
        always @(posedge i_clk)
77
        if (i_ce)
78
        begin
79
                if ((!i_v)||(i_cancel))
80
                begin
81
                        o_err   <= 0;
82
                        r_check <= 0;
83
                        r_ip    <= 0;
84
                end else if (r_v)
85
                begin
86
                        if (r_idx == 6'h6)
87
                                r_ip <= (r_word == 16'h0800);
88
                        else if (r_idx == r_hlen)
89
                                r_ip <= 1'b0;
90
                        if (r_idx == 6'h7)
91
                                r_hlen <= {r_word[11:8], 1'b0 } + 5'h7;
92
                        if (r_idx == r_hlen)
93
                                o_err <= (r_ip)&&(i_en)&&(r_check[15:0] != 16'hffff);
94
                        if (r_ip)
95
                                r_check <= r_check[15:0] + r_word + { 15'h0, r_check[16]};
96
                end
97
        end
98
 
99
endmodule

powered by: WebSVN 2.1.0

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