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 11

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
  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 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
 
57
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
// Beginning of automatic wires (for undeclared instantiated-module outputs)
84
// End of automatics
85
 
86
 
87
reg             txd_ovflow;
88
reg             next_txd_ovflow;
89
 
90
 
91
 
92
// Full status if data fifo is almost full.
93
// Current packet can complete transfer since data input rate
94
// matches output rate. But next packet must wait for more headroom.
95
 
96
assign pkt_tx_full = txdfifo_walmost_full;
97
 
98
 
99
 
100
always @(posedge clk_156m25 or negedge reset_156m25_n) begin
101
 
102
    if (reset_156m25_n == 1'b0) begin
103
 
104
        txd_ovflow <= 1'b0;
105
 
106
        status_txdfifo_ovflow_tog <= 1'b0;
107
 
108
    end
109
    else begin
110
 
111
        txd_ovflow <= next_txd_ovflow;
112
 
113
        //---
114
        // FIFO errors, used to generate interrupts
115
 
116
        if (next_txd_ovflow && !txd_ovflow) begin
117
            status_txdfifo_ovflow_tog <= ~status_txdfifo_ovflow_tog;
118
        end
119
 
120
    end
121
 
122
end
123
 
124 6 antanguay
always @(/*AS*/pkt_tx_data or pkt_tx_eop or pkt_tx_mod or pkt_tx_sop
125
         or pkt_tx_val or txd_ovflow or txdfifo_wfull) begin
126 2 antanguay
 
127
    txdfifo_wstatus = `TXSTATUS_NONE;
128
    txdfifo_wdata = pkt_tx_data;
129
    txdfifo_wen = pkt_tx_val;
130
 
131
    next_txd_ovflow = txd_ovflow;
132
 
133
 
134
    // Write SOP marker to fifo.
135
 
136
    if (pkt_tx_val && pkt_tx_sop) begin
137
 
138 6 antanguay
        txdfifo_wstatus[`TXSTATUS_SOP] = 1'b1;
139 2 antanguay
 
140
    end
141
 
142
 
143
    // Write EOP marker to fifo.
144
 
145
    if (pkt_tx_val) begin
146
 
147 6 antanguay
        if (pkt_tx_eop) begin
148
            txdfifo_wstatus[2:0] = pkt_tx_mod;
149
            txdfifo_wstatus[`TXSTATUS_EOP] = 1'b1;
150 2 antanguay
        end
151
 
152
    end
153
 
154
 
155
    // Overflow indication
156
 
157
    if (pkt_tx_val) begin
158
 
159
        if (txdfifo_wfull) begin
160
 
161
            next_txd_ovflow = 1'b1;
162
 
163
        end
164
        else if (pkt_tx_sop) begin
165
 
166
            next_txd_ovflow = 1'b0;
167
 
168
        end
169
    end
170
 
171
end
172
 
173
 
174
endmodule
175
 

powered by: WebSVN 2.1.0

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