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

Subversion Repositories openarty

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 31 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    rxewrite.v
4
//
5
// Project:     OpenArty, an entirely open SoC based upon the Arty platform
6
//
7
// Purpose:     The purpose of this module is quite simple: to simplify the
8
//              receive process.  By running the receive data through a 
9
//      series of "filter" processes (of which this is one), I hope to reduce
10
//      the complexity of the filter design.  This particular filter determines
11
//      if/when to write to memory, and at what address to write to.  Further,
12
//      because nibbles come into the interface in LSB order, and because we
13
//      are storing the first byte in the MSB, we need to shuffle bytes around
14
//      in this interface.  Therefore, this interface is also design to make
15
//      certain that, no matter how many bytes come in, we have always 
16
//      written a complete word to the output.  Hence, each word may be
17
//      written 8-times (once for each nibble) ... but that be as it may.
18
//
19
//      This routine also measures packet length in bytes.
20
//
21
// Creator:     Dan Gisselquist, Ph.D.
22
//              Gisselquist Technology, LLC
23
//
24
////////////////////////////////////////////////////////////////////////////////
25
//
26
// Copyright (C) 2016, Gisselquist Technology, LLC
27
//
28
// This program is free software (firmware): you can redistribute it and/or
29
// modify it under the terms of  the GNU General Public License as published
30
// by the Free Software Foundation, either version 3 of the License, or (at
31
// your option) any later version.
32
//
33
// This program is distributed in the hope that it will be useful, but WITHOUT
34
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
35
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
36
// for more details.
37
//
38
// You should have received a copy of the GNU General Public License along
39
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
40
// target there if the PDF file isn't present.)  If not, see
41
// <http://www.gnu.org/licenses/> for a copy.
42
//
43
// License:     GPL, v3, as defined and found on www.gnu.org,
44
//              http://www.gnu.org/licenses/gpl.html
45
//
46
//
47
////////////////////////////////////////////////////////////////////////////////
48
//
49
//
50
module  rxewrite(i_clk, i_ce, i_cancel, i_v, i_d, o_v, o_addr, o_data, o_len);
51
        parameter       AW = 12;
52
        localparam      DW = 32;
53
        input                           i_clk, i_ce;
54
        input                           i_cancel;
55
        input                           i_v;
56
        input           [3:0]            i_d;
57
        output  reg                     o_v;
58
        output  reg     [(AW-1):0]       o_addr;
59
        output  reg     [(DW-1):0]       o_data;
60
        output  wire    [(AW+1):0]       o_len;
61
 
62
        reg     [(AW+2):0]       lcl_addr, r_len;
63
 
64
        initial r_len = 0;
65
        always @(posedge i_clk)
66
        if (i_ce)
67
        begin
68
                lcl_addr <= lcl_addr + 1'b1;
69
                if (i_v)
70
                        r_len <= lcl_addr  + {{(AW+1){1'b0}},2'b10}; // i.e. +2
71
                o_v <= i_v;
72
                case(lcl_addr[2:0])
73
                3'b000: o_data <= { 4'h0, i_d, 24'h00 };
74
                3'b001: o_data <= { i_d, o_data[27:24], 24'h00 };
75
                3'b010: o_data <= { o_data[31:24], 4'h0, i_d, 16'h00 };
76
                3'b011: o_data <= { o_data[31:24], i_d, o_data[19:16], 16'h00 };
77
                3'b100: o_data <= { o_data[31:16], 4'h0, i_d, 8'h00 };
78
                3'b101: o_data <= { o_data[31:16], i_d, o_data[11:8], 8'h00 };
79
                3'b110: o_data <= { o_data[31: 8], 4'h0, i_d };
80
                3'b111: o_data <= { o_data[31: 8], i_d, o_data[3:0] };
81
                endcase
82
                o_addr <= lcl_addr[(AW+2):3];
83
 
84
                if (((!i_v)&&(!o_v))||(i_cancel))
85
                begin
86
                        o_v <= 0;
87
                        lcl_addr <= 0;
88
                end
89
        end
90
 
91
        assign  o_len  = r_len[(AW+2):1];
92
 
93
endmodule
94
 

powered by: WebSVN 2.1.0

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