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

Subversion Repositories openarty

[/] [openarty/] [trunk/] [rtl/] [addepad.v] - Blame information for rev 33

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    addepad.v
4
//
5
// Project:     OpenArty, an entirely open SoC based upon the Arty platform
6
//
7
// Purpose:     To force the minimum packet size of an ethernet frame to be
8
//              a minimum of 64 bytes.  This assumes that the CRC will be
9
//      adding 32-bits to the packet after us, so instead of padding to
10
//      64 bytes, we'll pad to 60 bytes instead.  If the user is providing
11
//      their own CRC, they'll need to adjust the padding themselves.
12
//
13
// Creator:     Dan Gisselquist, Ph.D.
14
//              Gisselquist Technology, LLC
15
//
16
////////////////////////////////////////////////////////////////////////////////
17
//
18
// Copyright (C) 2015-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 addepad(i_clk, i_ce, i_en, i_cancel, i_v, i_d, o_v, o_d);
43 33 dgisselq
        parameter       MINNIBBLES=120;
44
        localparam      LGNCOUNT=(MINNIBBLES<63)? 6
45
                                :((MINNIBBLES<127)? 7:((MINNIBBLES<255)? 8:9));
46 30 dgisselq
        input                   i_clk, i_ce, i_en, i_cancel;
47
        input                   i_v;    // Valid
48
        input           [3:0]    i_d;    // Data nibble
49
        output  reg             o_v;
50
        output  reg     [3:0]    o_d;
51
 
52 33 dgisselq
        reg     [(LGNCOUNT-1):0] r_ncnt;
53 30 dgisselq
        initial o_v = 1'b0;
54
        always @(posedge i_clk)
55
        if (i_ce)
56
        begin
57
                if (((!i_v)&&(!o_v))||(i_cancel))
58
                begin
59 33 dgisselq
                        r_ncnt <= 0;
60 30 dgisselq
                        o_v <= 1'b0;
61
                end else if (i_v)
62
                begin
63
                        o_v <= i_v;
64 33 dgisselq
                        r_ncnt <= (r_ncnt<MINNIBBLES) ? r_ncnt+1'b1 : r_ncnt;
65 30 dgisselq
                end else begin
66 33 dgisselq
                        o_v <= (r_ncnt<MINNIBBLES);
67
                        r_ncnt <= (r_ncnt<MINNIBBLES) ? r_ncnt+1'b1 : r_ncnt;
68 30 dgisselq
                end
69
 
70
                if (i_v)
71
                        o_d <= i_d;
72
                else
73
                        o_d <= 4'h0;
74
        end
75
 
76
endmodule

powered by: WebSVN 2.1.0

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