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

Subversion Repositories xge_mac

[/] [xge_mac/] [tags/] [initial/] [rtl/] [verilog/] [tx_enqueue.v] - Blame information for rev 7

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
  pkt_tx_full, txdfifo_wdata, txdfifo_wstatus, txdfifo_wen,
44
  status_txdfifo_ovflow_tog,
45
  // Inputs
46
  clk_156m25, reset_156m25_n, pkt_tx_data, pkt_tx_val, pkt_tx_sop,
47
  pkt_tx_eop, txdfifo_wfull, txdfifo_walmost_full
48
  );
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
 
57
input  [63:0] pkt_tx_data;
58
input         pkt_tx_val;
59
input         pkt_tx_sop;
60
input  [7:0]  pkt_tx_eop;
61
 
62
input         txdfifo_wfull;
63
input         txdfifo_walmost_full;
64
 
65
output        pkt_tx_full;
66
 
67
output [63:0] txdfifo_wdata;
68
output [7:0]  txdfifo_wstatus;
69
output        txdfifo_wen;
70
 
71
output        status_txdfifo_ovflow_tog;
72
 
73
/*AUTOREG*/
74
// Beginning of automatic regs (for this module's undeclared outputs)
75
reg                     status_txdfifo_ovflow_tog;
76
reg [63:0]              txdfifo_wdata;
77
reg                     txdfifo_wen;
78
reg [7:0]               txdfifo_wstatus;
79
// End of automatics
80
 
81
/*AUTOWIRE*/
82
// Beginning of automatic wires (for undeclared instantiated-module outputs)
83
// End of automatics
84
 
85
 
86
reg             txd_ovflow;
87
reg             next_txd_ovflow;
88
 
89
 
90
 
91
// Full status if data fifo is almost full.
92
// Current packet can complete transfer since data input rate
93
// matches output rate. But next packet must wait for more headroom.
94
 
95
assign pkt_tx_full = txdfifo_walmost_full;
96
 
97
 
98
 
99
always @(posedge clk_156m25 or negedge reset_156m25_n) begin
100
 
101
    if (reset_156m25_n == 1'b0) begin
102
 
103
        txd_ovflow <= 1'b0;
104
 
105
        status_txdfifo_ovflow_tog <= 1'b0;
106
 
107
    end
108
    else begin
109
 
110
        txd_ovflow <= next_txd_ovflow;
111
 
112
        //---
113
        // FIFO errors, used to generate interrupts
114
 
115
        if (next_txd_ovflow && !txd_ovflow) begin
116
            status_txdfifo_ovflow_tog <= ~status_txdfifo_ovflow_tog;
117
        end
118
 
119
    end
120
 
121
end
122
 
123
always @(/*AS*/pkt_tx_data or pkt_tx_eop or pkt_tx_sop or pkt_tx_val
124
         or txd_ovflow or txdfifo_wfull) begin
125
 
126
    txdfifo_wstatus = `TXSTATUS_NONE;
127
    txdfifo_wdata = pkt_tx_data;
128
    txdfifo_wen = pkt_tx_val;
129
 
130
    next_txd_ovflow = txd_ovflow;
131
 
132
 
133
    // Write SOP marker to fifo.
134
 
135
    if (pkt_tx_val && pkt_tx_sop) begin
136
 
137
        txdfifo_wstatus = `TXSTATUS_SOP;
138
 
139
    end
140
 
141
 
142
    // Write EOP marker to fifo.
143
 
144
    if (pkt_tx_val) begin
145
 
146
        if (pkt_tx_eop[0]) begin
147
            txdfifo_wstatus = `TXSTATUS_EOP0;
148
        end
149
        else if (pkt_tx_eop[1]) begin
150
            txdfifo_wstatus = `TXSTATUS_EOP1;
151
        end
152
        else if (pkt_tx_eop[2]) begin
153
            txdfifo_wstatus = `TXSTATUS_EOP2;
154
        end
155
        else if (pkt_tx_eop[3]) begin
156
            txdfifo_wstatus = `TXSTATUS_EOP3;
157
        end
158
        else if (pkt_tx_eop[4]) begin
159
            txdfifo_wstatus = `TXSTATUS_EOP4;
160
        end
161
        else if (pkt_tx_eop[5]) begin
162
            txdfifo_wstatus = `TXSTATUS_EOP5;
163
        end
164
        else if (pkt_tx_eop[6]) begin
165
            txdfifo_wstatus = `TXSTATUS_EOP6;
166
        end
167
        else if (pkt_tx_eop[7]) begin
168
            txdfifo_wstatus = `TXSTATUS_EOP7;
169
        end
170
 
171
    end
172
 
173
 
174
    // Overflow indication
175
 
176
    if (pkt_tx_val) begin
177
 
178
        if (txdfifo_wfull) begin
179
 
180
            next_txd_ovflow = 1'b1;
181
 
182
        end
183
        else if (pkt_tx_sop) begin
184
 
185
            next_txd_ovflow = 1'b0;
186
 
187
        end
188
    end
189
 
190
end
191
 
192
 
193
endmodule
194
 

powered by: WebSVN 2.1.0

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