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

Subversion Repositories openarty

[/] [openarty/] [trunk/] [rtl/] [addepreamble.v] - Blame information for rev 30

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    addepreamble.v
4
//
5
// Project:     OpenArty, an entirely open SoC based upon the Arty platform
6
//
7
// Purpose:     To add the ethernet preamble to a stream of values (i.e., to
8
//              an ethernet packet ...)
9
//
10
// Creator:     Dan Gisselquist, Ph.D.
11
//              Gisselquist Technology, LLC
12
//
13
////////////////////////////////////////////////////////////////////////////////
14
//
15
// Copyright (C) 2015-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 addepreamble(i_clk, i_ce, i_en, i_cancel, i_v, i_d, o_v, o_d);
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  wire            o_v;
44
        output  wire    [3:0]    o_d;
45
 
46
        reg     [84:0]   shiftreg;
47
        reg             r_v;
48
        reg     [3:0]    r_d;
49
 
50
        initial r_v = 1'b0;
51
        always @(posedge i_clk)
52
        if (i_ce)
53
        begin
54
                shiftreg <= { shiftreg[79:0], { i_v, i_d }};
55
                r_v <= shiftreg[84];
56
                r_d <= shiftreg[83:80];
57
                if (((!i_v)&&(!o_v))||(i_cancel))
58
                begin
59
                        shiftreg <= { 5'h00, 5'h15, 5'h15, 5'h15, 5'h15,
60
                                5'h15, 5'h15, 5'h15, 5'h15,
61
                                5'h15, 5'h15, 5'h15, 5'h15,
62
                                5'h15, 5'h15, 5'h15, 5'h1d };
63
                        if (!i_en)
64
                        begin
65
                                shiftreg[ 4] <= 1'b0;
66
                                shiftreg[ 9] <= 1'b0;
67
                                shiftreg[14] <= 1'b0;
68
                                shiftreg[19] <= 1'b0;
69
                                shiftreg[24] <= 1'b0;
70
                                shiftreg[29] <= 1'b0;
71
                                shiftreg[34] <= 1'b0;
72
                                shiftreg[39] <= 1'b0;
73
                                shiftreg[44] <= 1'b0;
74
                                shiftreg[49] <= 1'b0;
75
                                shiftreg[54] <= 1'b0;
76
                                shiftreg[59] <= 1'b0;
77
                                shiftreg[64] <= 1'b0;
78
                                shiftreg[69] <= 1'b0;
79
                                shiftreg[74] <= 1'b0;
80
                                shiftreg[79] <= 1'b0;
81
                        end
82
                end
83
        end
84
 
85
        assign  o_v = r_v;
86
        assign  o_d = r_d;
87
 
88
endmodule

powered by: WebSVN 2.1.0

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