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

Subversion Repositories xge_mac

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

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
  pkt_rx_err, pkt_rx_avail, status_rxdfifo_udflow_tog,
45
  // 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
output [7:0]  pkt_rx_eop;
66
output        pkt_rx_err;
67
output        pkt_rx_avail;
68
 
69
output        status_rxdfifo_udflow_tog;
70
 
71
/*AUTOREG*/
72
// Beginning of automatic regs (for this module's undeclared outputs)
73
reg                     pkt_rx_avail;
74
reg [63:0]              pkt_rx_data;
75
reg [7:0]               pkt_rx_eop;
76
reg                     pkt_rx_err;
77
reg                     pkt_rx_sop;
78
reg                     pkt_rx_val;
79
reg                     status_rxdfifo_udflow_tog;
80
// End of automatics
81
 
82
reg           end_eop;
83
 
84
/*AUTOWIRE*/
85
// Beginning of automatic wires (for undeclared instantiated-module outputs)
86
// End of automatics
87
 
88
wire   [7:0]  eop;
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
// EOP position is stored in status portion of rx data fifo.
98
// If we read an EOP indicator, set the corresponding eop line.
99
 
100
assign eop[0] = rxdfifo_rstatus[3:0] == `RXSTATUS_EOP0;
101
assign eop[1] = rxdfifo_rstatus[3:0] == `RXSTATUS_EOP1;
102
assign eop[2] = rxdfifo_rstatus[3:0] == `RXSTATUS_EOP2;
103
assign eop[3] = rxdfifo_rstatus[3:0] == `RXSTATUS_EOP3;
104
assign eop[4] = rxdfifo_rstatus[3:0] == `RXSTATUS_EOP4;
105
assign eop[5] = rxdfifo_rstatus[3:0] == `RXSTATUS_EOP5;
106
assign eop[6] = rxdfifo_rstatus[3:0] == `RXSTATUS_EOP6;
107
assign eop[7] = rxdfifo_rstatus[3:0] == `RXSTATUS_EOP7;
108
 
109
 
110
always @(posedge clk_156m25 or negedge reset_156m25_n) begin
111
 
112
    if (reset_156m25_n == 1'b0) begin
113
 
114
        pkt_rx_avail <= 1'b0;
115
 
116
        pkt_rx_data <= 64'b0;
117
        pkt_rx_sop <= 1'b0;
118
        pkt_rx_eop <= 8'b0;
119
        pkt_rx_err <= 1'b0;
120
 
121
        pkt_rx_val <= 1'b0;
122
 
123
        end_eop <= 1'b0;
124
 
125
        status_rxdfifo_udflow_tog <= 1'b0;
126
 
127
    end
128
    else begin
129
 
130
        pkt_rx_avail <= !rxdfifo_ralmost_empty;
131
 
132
 
133
 
134
        // If eop shows up at the output of the fifo, we drive eop on
135
        // the bus on the next read. This will be the last read for this
136
        // packet. The fifo is designed to output data early. On last read,
137
        // data from next packet will appear at the output of fifo.
138
 
139
        pkt_rx_eop <= {8{rxdfifo_ren}} & eop;
140
 
141
 
142
        pkt_rx_val <= rxdfifo_ren;
143
 
144
        if (rxdfifo_ren) begin
145
 
146
            pkt_rx_data <= rxdfifo_rdata;
147
 
148
        end
149
 
150
 
151
        if (rxdfifo_ren && rxdfifo_rstatus[3:0] == `RXSTATUS_SOP) begin
152
 
153
            // SOP indication on first word
154
 
155
            pkt_rx_sop <= 1'b1;
156
            pkt_rx_err <= 1'b0;
157
 
158
        end
159
        else begin
160
 
161
            pkt_rx_sop <= 1'b0;
162
 
163
 
164
            // Give an error if FIFO is to underflow
165
 
166
            if (rxdfifo_rempty && pkt_rx_ren && !end_eop) begin
167
                pkt_rx_val <= 1'b1;
168
                pkt_rx_eop <= 8'b1;
169
                pkt_rx_err <= 1'b1;
170
            end
171
 
172
        end
173
 
174
 
175
        if (rxdfifo_ren && |(rxdfifo_rstatus[7:4] & `RXSTATUS_ERR)) begin
176
 
177
            // Status stored in FIFO is propagated to error signal.
178
 
179
            pkt_rx_err <= 1'b1;
180
 
181
        end
182
 
183
 
184
        //---
185
        // EOP indication at the end of the frame. Cleared otherwise.
186
 
187
        if (rxdfifo_ren && |eop) begin
188
            end_eop <= 1'b1;
189
        end
190
        else if (pkt_rx_ren) begin
191
            end_eop <= 1'b0;
192
        end
193
 
194
 
195
 
196
        //---
197
        // FIFO errors, used to generate interrupts
198
 
199
        if (rxdfifo_rempty && pkt_rx_ren && !end_eop) begin
200
            status_rxdfifo_udflow_tog <= ~status_rxdfifo_udflow_tog;
201
        end
202
 
203
    end
204
end
205
 
206
endmodule
207
 

powered by: WebSVN 2.1.0

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