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

Subversion Repositories xge_mac

[/] [xge_mac/] [trunk/] [rtl/] [verilog/] [rx_dequeue.v] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 antanguay
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  File name "rx_dequeue.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 rx_dequeue(/*AUTOARG*/
42
  // Outputs
43 12 antanguay
  rxdfifo_ren, pkt_rx_data, pkt_rx_val, pkt_rx_sop, pkt_rx_eop,
44
  pkt_rx_err, pkt_rx_mod, pkt_rx_avail, status_rxdfifo_udflow_tog,
45 2 antanguay
  // Inputs
46 12 antanguay
  clk_156m25, reset_156m25_n, rxdfifo_rdata, rxdfifo_rstatus,
47 2 antanguay
  rxdfifo_rempty, rxdfifo_ralmost_empty, pkt_rx_ren
48
  );
49
 
50
input         clk_156m25;
51
input         reset_156m25_n;
52 12 antanguay
 
53 2 antanguay
input [63:0]  rxdfifo_rdata;
54
input [7:0]   rxdfifo_rstatus;
55
input         rxdfifo_rempty;
56
input         rxdfifo_ralmost_empty;
57
 
58
input         pkt_rx_ren;
59
 
60
output        rxdfifo_ren;
61 12 antanguay
 
62 2 antanguay
output [63:0] pkt_rx_data;
63
output        pkt_rx_val;
64
output        pkt_rx_sop;
65 6 antanguay
output        pkt_rx_eop;
66 2 antanguay
output        pkt_rx_err;
67 6 antanguay
output [2:0]  pkt_rx_mod;
68 2 antanguay
output        pkt_rx_avail;
69
 
70
output        status_rxdfifo_udflow_tog;
71
 
72
/*AUTOREG*/
73
// Beginning of automatic regs (for this module's undeclared outputs)
74
reg                     pkt_rx_avail;
75
reg [63:0]              pkt_rx_data;
76 6 antanguay
reg                     pkt_rx_eop;
77 2 antanguay
reg                     pkt_rx_err;
78 6 antanguay
reg [2:0]               pkt_rx_mod;
79 2 antanguay
reg                     pkt_rx_sop;
80
reg                     pkt_rx_val;
81
reg                     status_rxdfifo_udflow_tog;
82
// End of automatics
83
 
84
reg           end_eop;
85
 
86
/*AUTOWIRE*/
87
 
88
 
89
// End eop to force one cycle between packets
90
 
91
assign rxdfifo_ren = !rxdfifo_rempty && pkt_rx_ren && !end_eop;
92
 
93
 
94
 
95
always @(posedge clk_156m25 or negedge reset_156m25_n) begin
96
 
97
    if (reset_156m25_n == 1'b0) begin
98
 
99
        pkt_rx_avail <= 1'b0;
100
 
101
        pkt_rx_data <= 64'b0;
102
        pkt_rx_sop <= 1'b0;
103 6 antanguay
        pkt_rx_eop <= 1'b0;
104 2 antanguay
        pkt_rx_err <= 1'b0;
105 6 antanguay
        pkt_rx_mod <= 3'b0;
106 2 antanguay
 
107
        pkt_rx_val <= 1'b0;
108
 
109
        end_eop <= 1'b0;
110
 
111
        status_rxdfifo_udflow_tog <= 1'b0;
112
 
113
    end
114
    else begin
115
 
116
        pkt_rx_avail <= !rxdfifo_ralmost_empty;
117
 
118
 
119
 
120
        // If eop shows up at the output of the fifo, we drive eop on
121
        // the bus on the next read. This will be the last read for this
122
        // packet. The fifo is designed to output data early. On last read,
123 6 antanguay
        // data from next packet will appear at the output of fifo. Modulus
124
        // of packet length is in lower bits.
125 12 antanguay
 
126 6 antanguay
        pkt_rx_eop <= rxdfifo_ren && rxdfifo_rstatus[`RXSTATUS_EOP];
127
        pkt_rx_mod <= {3{rxdfifo_ren & rxdfifo_rstatus[`RXSTATUS_EOP]}} & rxdfifo_rstatus[2:0];
128 2 antanguay
 
129
 
130
        pkt_rx_val <= rxdfifo_ren;
131
 
132
        if (rxdfifo_ren) begin
133
 
134 12 antanguay
            `ifdef BIGENDIAN
135
            pkt_rx_data <= {rxdfifo_rdata[7:0],
136
                            rxdfifo_rdata[15:8],
137
                            rxdfifo_rdata[23:16],
138
                            rxdfifo_rdata[31:24],
139
                            rxdfifo_rdata[39:32],
140
                            rxdfifo_rdata[47:40],
141
                            rxdfifo_rdata[55:48],
142
                            rxdfifo_rdata[63:56]};
143
            `else
144 2 antanguay
            pkt_rx_data <= rxdfifo_rdata;
145 12 antanguay
            `endif
146 2 antanguay
 
147
        end
148
 
149
 
150 6 antanguay
        if (rxdfifo_ren && rxdfifo_rstatus[`RXSTATUS_SOP]) begin
151 2 antanguay
 
152
            // SOP indication on first word
153
 
154
            pkt_rx_sop <= 1'b1;
155
            pkt_rx_err <= 1'b0;
156
 
157
        end
158
        else begin
159
 
160
            pkt_rx_sop <= 1'b0;
161
 
162
 
163
            // Give an error if FIFO is to underflow
164
 
165
            if (rxdfifo_rempty && pkt_rx_ren && !end_eop) begin
166
                pkt_rx_val <= 1'b1;
167 6 antanguay
                pkt_rx_eop <= 1'b1;
168 2 antanguay
                pkt_rx_err <= 1'b1;
169
            end
170
 
171
        end
172
 
173
 
174 6 antanguay
        if (rxdfifo_ren && |(rxdfifo_rstatus[`RXSTATUS_ERR])) begin
175 2 antanguay
 
176
            // Status stored in FIFO is propagated to error signal.
177
 
178
            pkt_rx_err <= 1'b1;
179
 
180
        end
181
 
182
 
183
        //---
184
        // EOP indication at the end of the frame. Cleared otherwise.
185 12 antanguay
 
186 6 antanguay
        if (rxdfifo_ren && rxdfifo_rstatus[`RXSTATUS_EOP]) begin
187 2 antanguay
            end_eop <= 1'b1;
188
        end
189
        else if (pkt_rx_ren) begin
190
            end_eop <= 1'b0;
191
        end
192
 
193
 
194
 
195
        //---
196
        // FIFO errors, used to generate interrupts
197 12 antanguay
 
198 2 antanguay
        if (rxdfifo_rempty && pkt_rx_ren && !end_eop) begin
199
            status_rxdfifo_udflow_tog <= ~status_rxdfifo_udflow_tog;
200
        end
201
 
202
    end
203
end
204
 
205
endmodule

powered by: WebSVN 2.1.0

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