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

Subversion Repositories openarty

[/] [openarty/] [trunk/] [rtl/] [rxemin.v] - Blame information for rev 50

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 33 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    rxemin.v
4
//
5
// Project:     OpenArty, an entirely open SoC based upon the Arty platform
6
//
7
// Purpose:     To force the minimum received packet size of an ethernet frame
8
//              to be a minimum of 64 bytes.  Packets less than 64-bytes
9
//              (including CRC) need to be dropped.  This module handles that
10
//      logic.
11
//
12
// Creator:     Dan Gisselquist, Ph.D.
13
//              Gisselquist Technology, LLC
14
//
15
////////////////////////////////////////////////////////////////////////////////
16
//
17
// Copyright (C) 2016, Gisselquist Technology, LLC
18
//
19
// This program is free software (firmware): you can redistribute it and/or
20
// modify it under the terms of  the GNU General Public License as published
21
// by the Free Software Foundation, either version 3 of the License, or (at
22
// your option) any later version.
23
//
24
// This program is distributed in the hope that it will be useful, but WITHOUT
25
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
26
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
27
// for more details.
28
//
29
// You should have received a copy of the GNU General Public License along
30
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
31
// target there if the PDF file isn't present.)  If not, see
32
// <http://www.gnu.org/licenses/> for a copy.
33
//
34
// License:     GPL, v3, as defined and found on www.gnu.org,
35
//              http://www.gnu.org/licenses/gpl.html
36
//
37
//
38
////////////////////////////////////////////////////////////////////////////////
39
//
40
//
41 50 dgisselq
module rxemin(i_clk, i_ce, i_en, i_cancel, i_v, i_d, o_err);
42 33 dgisselq
        parameter       MINNIBBLES=120;
43
        localparam      LGNCOUNT=(MINNIBBLES<63)? 6
44
                                :((MINNIBBLES<127)? 7:((MINNIBBLES<255)? 8:9));
45
        input                   i_clk, i_ce, i_en, i_cancel;
46
        input                   i_v;    // Valid
47
        input           [3:0]    i_d;    // Data nibble
48
        output  reg             o_err;
49
 
50
        reg     last_v;
51
        reg     [(LGNCOUNT-1):0] r_ncnt;
52
        initial last_v = 1'b0;
53
        always @(posedge i_clk)
54
        if (i_ce)
55
        begin
56
                last_v <= i_v;
57
 
58 50 dgisselq
                if ((!i_v)||(i_cancel))
59 33 dgisselq
                begin
60 50 dgisselq
                        // Here's our reset.  If th input isn't valid (i.e., no
61
                        // packet present), or if we are cancelling the packet,
62
                        // then we come in here and reset our interface.
63 33 dgisselq
                        r_ncnt <= 0;
64
                        o_err  <= 0;
65
                end else if (i_v)
66
                begin
67
                        r_ncnt <= (r_ncnt<MINNIBBLES) ? r_ncnt+1'b1 : r_ncnt;
68
                end else if (last_v)
69
                        o_err <= (i_en)&&(r_ncnt < MINNIBBLES);
70
        end
71
 
72
endmodule

powered by: WebSVN 2.1.0

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