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 10

Go to most recent revision | 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
  rxdfifo_ren, pkt_rx_data, pkt_rx_val, pkt_rx_sop, pkt_rx_eop,
44 6 antanguay
  pkt_rx_err, pkt_rx_mod, pkt_rx_avail, status_rxdfifo_udflow_tog,
45 2 antanguay
  // Inputs
46
  clk_156m25, reset_156m25_n, rxdfifo_rdata, rxdfifo_rstatus,
47
  rxdfifo_rempty, rxdfifo_ralmost_empty, pkt_rx_ren
48
  );
49
 
50
input         clk_156m25;
51
input         reset_156m25_n;
52
 
53
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
 
62
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
// Beginning of automatic wires (for undeclared instantiated-module outputs)
88
// End of automatics
89
 
90
 
91
// End eop to force one cycle between packets
92
 
93
assign rxdfifo_ren = !rxdfifo_rempty && pkt_rx_ren && !end_eop;
94
 
95
 
96
 
97
always @(posedge clk_156m25 or negedge reset_156m25_n) begin
98
 
99
    if (reset_156m25_n == 1'b0) begin
100
 
101
        pkt_rx_avail <= 1'b0;
102
 
103
        pkt_rx_data <= 64'b0;
104
        pkt_rx_sop <= 1'b0;
105 6 antanguay
        pkt_rx_eop <= 1'b0;
106 2 antanguay
        pkt_rx_err <= 1'b0;
107 6 antanguay
        pkt_rx_mod <= 3'b0;
108 2 antanguay
 
109
        pkt_rx_val <= 1'b0;
110
 
111
        end_eop <= 1'b0;
112
 
113
        status_rxdfifo_udflow_tog <= 1'b0;
114
 
115
    end
116
    else begin
117
 
118
        pkt_rx_avail <= !rxdfifo_ralmost_empty;
119
 
120
 
121
 
122
        // If eop shows up at the output of the fifo, we drive eop on
123
        // the bus on the next read. This will be the last read for this
124
        // packet. The fifo is designed to output data early. On last read,
125 6 antanguay
        // data from next packet will appear at the output of fifo. Modulus
126
        // of packet length is in lower bits.
127 2 antanguay
 
128 6 antanguay
        pkt_rx_eop <= rxdfifo_ren && rxdfifo_rstatus[`RXSTATUS_EOP];
129
        pkt_rx_mod <= {3{rxdfifo_ren & rxdfifo_rstatus[`RXSTATUS_EOP]}} & rxdfifo_rstatus[2:0];
130 2 antanguay
 
131
 
132
        pkt_rx_val <= rxdfifo_ren;
133
 
134
        if (rxdfifo_ren) begin
135
 
136
            pkt_rx_data <= rxdfifo_rdata;
137
 
138
        end
139
 
140
 
141 6 antanguay
        if (rxdfifo_ren && rxdfifo_rstatus[`RXSTATUS_SOP]) begin
142 2 antanguay
 
143
            // SOP indication on first word
144
 
145
            pkt_rx_sop <= 1'b1;
146
            pkt_rx_err <= 1'b0;
147
 
148
        end
149
        else begin
150
 
151
            pkt_rx_sop <= 1'b0;
152
 
153
 
154
            // Give an error if FIFO is to underflow
155
 
156
            if (rxdfifo_rempty && pkt_rx_ren && !end_eop) begin
157
                pkt_rx_val <= 1'b1;
158 6 antanguay
                pkt_rx_eop <= 1'b1;
159 2 antanguay
                pkt_rx_err <= 1'b1;
160
            end
161
 
162
        end
163
 
164
 
165 6 antanguay
        if (rxdfifo_ren && |(rxdfifo_rstatus[`RXSTATUS_ERR])) begin
166 2 antanguay
 
167
            // Status stored in FIFO is propagated to error signal.
168
 
169
            pkt_rx_err <= 1'b1;
170
 
171
        end
172
 
173
 
174
        //---
175
        // EOP indication at the end of the frame. Cleared otherwise.
176
 
177 6 antanguay
        if (rxdfifo_ren && rxdfifo_rstatus[`RXSTATUS_EOP]) begin
178 2 antanguay
            end_eop <= 1'b1;
179
        end
180
        else if (pkt_rx_ren) begin
181
            end_eop <= 1'b0;
182
        end
183
 
184
 
185
 
186
        //---
187
        // FIFO errors, used to generate interrupts
188
 
189
        if (rxdfifo_rempty && pkt_rx_ren && !end_eop) begin
190
            status_rxdfifo_udflow_tog <= ~status_rxdfifo_udflow_tog;
191
        end
192
 
193
    end
194
end
195
 
196
endmodule
197
 

powered by: WebSVN 2.1.0

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