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

Subversion Repositories xge_mac

[/] [xge_mac/] [trunk/] [rtl/] [verilog/] [tx_enqueue.v] - Blame information for rev 15

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

Line No. Rev Author Line
1 2 antanguay
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  File name "tx_enqueue.v"                                    ////
4
////                                                              ////
5
////  This file is part of the "10GE MAC" project                 ////
6
////  http://www.opencores.org/cores/xge_mac/                     ////
7
////                                                              ////
8
////  Author(s):                                                  ////
9
////      - A. Tanguay (antanguay@opencores.org)                  ////
10
////                                                              ////
11
//////////////////////////////////////////////////////////////////////
12
////                                                              ////
13
//// Copyright (C) 2008 AUTHORS. All rights reserved.             ////
14
////                                                              ////
15
//// This source file may be used and distributed without         ////
16
//// restriction provided that this copyright statement is not    ////
17
//// removed from the file and that any derivative work contains  ////
18
//// the original copyright notice and the associated disclaimer. ////
19
////                                                              ////
20
//// This source file is free software; you can redistribute it   ////
21
//// and/or modify it under the terms of the GNU Lesser General   ////
22
//// Public License as published by the Free Software Foundation; ////
23
//// either version 2.1 of the License, or (at your option) any   ////
24
//// later version.                                               ////
25
////                                                              ////
26
//// This source is distributed in the hope that it will be       ////
27
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
28
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
29
//// PURPOSE.  See the GNU Lesser General Public License for more ////
30
//// details.                                                     ////
31
////                                                              ////
32
//// You should have received a copy of the GNU Lesser General    ////
33
//// Public License along with this source; if not, download it   ////
34
//// from http://www.opencores.org/lgpl.shtml                     ////
35
////                                                              ////
36
//////////////////////////////////////////////////////////////////////
37
 
38
 
39
`include "defines.v"
40
 
41
module tx_enqueue(/*AUTOARG*/
42
  // Outputs
43 12 antanguay
  pkt_tx_full, txdfifo_wdata, txdfifo_wstatus, txdfifo_wen,
44
  status_txdfifo_ovflow_tog,
45 2 antanguay
  // Inputs
46 12 antanguay
  clk_156m25, reset_156m25_n, pkt_tx_data, pkt_tx_val, pkt_tx_sop,
47 6 antanguay
  pkt_tx_eop, pkt_tx_mod, txdfifo_wfull, txdfifo_walmost_full
48 2 antanguay
  );
49
 
50
`include "CRC32_D64.v"
51
`include "CRC32_D8.v"
52
`include "utils.v"
53
 
54
input         clk_156m25;
55
input         reset_156m25_n;
56 12 antanguay
 
57 2 antanguay
input  [63:0] pkt_tx_data;
58
input         pkt_tx_val;
59
input         pkt_tx_sop;
60 6 antanguay
input         pkt_tx_eop;
61
input  [2:0]  pkt_tx_mod;
62 2 antanguay
 
63
input         txdfifo_wfull;
64
input         txdfifo_walmost_full;
65
 
66
output        pkt_tx_full;
67
 
68
output [63:0] txdfifo_wdata;
69
output [7:0]  txdfifo_wstatus;
70
output        txdfifo_wen;
71
 
72
output        status_txdfifo_ovflow_tog;
73
 
74
/*AUTOREG*/
75
// Beginning of automatic regs (for this module's undeclared outputs)
76
reg                     status_txdfifo_ovflow_tog;
77
reg [63:0]              txdfifo_wdata;
78
reg                     txdfifo_wen;
79
reg [7:0]               txdfifo_wstatus;
80
// End of automatics
81
 
82
/*AUTOWIRE*/
83
 
84
 
85
reg             txd_ovflow;
86
reg             next_txd_ovflow;
87
 
88
 
89
 
90
// Full status if data fifo is almost full.
91
// Current packet can complete transfer since data input rate
92
// matches output rate. But next packet must wait for more headroom.
93
 
94
assign pkt_tx_full = txdfifo_walmost_full;
95
 
96
 
97
 
98
always @(posedge clk_156m25 or negedge reset_156m25_n) begin
99
 
100
    if (reset_156m25_n == 1'b0) begin
101
 
102
        txd_ovflow <= 1'b0;
103
 
104
        status_txdfifo_ovflow_tog <= 1'b0;
105
 
106
    end
107
    else begin
108
 
109
        txd_ovflow <= next_txd_ovflow;
110
 
111
        //---
112
        // FIFO errors, used to generate interrupts
113 12 antanguay
 
114 2 antanguay
        if (next_txd_ovflow && !txd_ovflow) begin
115
            status_txdfifo_ovflow_tog <= ~status_txdfifo_ovflow_tog;
116
        end
117
 
118
    end
119
 
120
end
121
 
122 6 antanguay
always @(/*AS*/pkt_tx_data or pkt_tx_eop or pkt_tx_mod or pkt_tx_sop
123
         or pkt_tx_val or txd_ovflow or txdfifo_wfull) begin
124 2 antanguay
 
125
    txdfifo_wstatus = `TXSTATUS_NONE;
126
    txdfifo_wen = pkt_tx_val;
127
 
128
    next_txd_ovflow = txd_ovflow;
129
 
130 12 antanguay
    `ifdef BIGENDIAN
131
    txdfifo_wdata = {pkt_tx_data[7:0], pkt_tx_data[15:8], pkt_tx_data[23:16], pkt_tx_data[31:24],
132
                     pkt_tx_data[39:32], pkt_tx_data[47:40], pkt_tx_data[55:48],
133
                     pkt_tx_data[63:56]};
134
    `else
135
    txdfifo_wdata = pkt_tx_data;
136
    `endif
137 2 antanguay
 
138
    // Write SOP marker to fifo.
139 12 antanguay
 
140 2 antanguay
    if (pkt_tx_val && pkt_tx_sop) begin
141
 
142 6 antanguay
        txdfifo_wstatus[`TXSTATUS_SOP] = 1'b1;
143 2 antanguay
 
144
    end
145
 
146 12 antanguay
 
147 2 antanguay
    // Write EOP marker to fifo.
148 12 antanguay
 
149 2 antanguay
    if (pkt_tx_val) begin
150
 
151 6 antanguay
        if (pkt_tx_eop) begin
152
            txdfifo_wstatus[2:0] = pkt_tx_mod;
153
            txdfifo_wstatus[`TXSTATUS_EOP] = 1'b1;
154 2 antanguay
        end
155
 
156
    end
157
 
158
 
159
    // Overflow indication
160
 
161
    if (pkt_tx_val) begin
162
 
163
        if (txdfifo_wfull) begin
164
 
165
            next_txd_ovflow = 1'b1;
166
 
167
        end
168
        else if (pkt_tx_sop) begin
169
 
170
            next_txd_ovflow = 1'b0;
171
 
172
        end
173
    end
174
 
175
end
176
 
177
 
178
endmodule

powered by: WebSVN 2.1.0

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