1 |
3 |
dwp |
//////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// File name "ge_1000baseX_tx.v" ////
|
4 |
|
|
//// ////
|
5 |
|
|
//// This file is part of the : ////
|
6 |
|
|
//// ////
|
7 |
|
|
//// "1000BASE-X IEEE 802.3-2008 Clause 36 - PCS project" ////
|
8 |
|
|
//// ////
|
9 |
|
|
//// http://opencores.org/project,1000base-x ////
|
10 |
|
|
//// ////
|
11 |
|
|
//// Author(s): ////
|
12 |
|
|
//// - D.W.Pegler Cambridge Broadband Networks Ltd ////
|
13 |
|
|
//// ////
|
14 |
|
|
//// { peglerd@gmail.com, dwp@cambridgebroadand.com } ////
|
15 |
|
|
//// ////
|
16 |
|
|
//////////////////////////////////////////////////////////////////////
|
17 |
|
|
//// ////
|
18 |
|
|
//// Copyright (C) 2009 AUTHORS. All rights reserved. ////
|
19 |
|
|
//// ////
|
20 |
|
|
//// This source file may be used and distributed without ////
|
21 |
|
|
//// restriction provided that this copyright statement is not ////
|
22 |
|
|
//// removed from the file and that any derivative work contains ////
|
23 |
|
|
//// the original copyright notice and the associated disclaimer. ////
|
24 |
|
|
//// ////
|
25 |
|
|
//// This source file is free software; you can redistribute it ////
|
26 |
|
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
27 |
|
|
//// Public License as published by the Free Software Foundation; ////
|
28 |
|
|
//// either version 2.1 of the License, or (at your option) any ////
|
29 |
|
|
//// later version. ////
|
30 |
|
|
//// ////
|
31 |
|
|
//// This source is distributed in the hope that it will be ////
|
32 |
|
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
33 |
|
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
34 |
|
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
35 |
|
|
//// details. ////
|
36 |
|
|
//// ////
|
37 |
|
|
//// You should have received a copy of the GNU Lesser General ////
|
38 |
|
|
//// Public License along with this source; if not, download it ////
|
39 |
|
|
//// from http://www.opencores.org/lgpl.shtml ////
|
40 |
|
|
//// ////
|
41 |
|
|
//////////////////////////////////////////////////////////////////////
|
42 |
|
|
//// ////
|
43 |
|
|
//// This module is based on the coding method described in ////
|
44 |
|
|
//// IEEE Std 802.3-2008 Clause 36 "Physical Coding Sublayer(PCS) ////
|
45 |
|
|
//// and Physical Medium Attachment (PMA) sublayer, type ////
|
46 |
|
|
//// 1000BASE-X"; see : ////
|
47 |
|
|
//// ////
|
48 |
|
|
//// http://standards.ieee.org/about/get/802/802.3.html ////
|
49 |
|
|
//// and ////
|
50 |
|
|
//// doc/802.3-2008_section3.pdf, Clause/Section 36. ////
|
51 |
|
|
//// ////
|
52 |
|
|
//////////////////////////////////////////////////////////////////////
|
53 |
|
|
|
54 |
|
|
`include "ge_1000baseX_constants.v"
|
55 |
|
|
`include "ge_1000baseX_regs.v"
|
56 |
|
|
|
57 |
|
|
module ge_1000baseX_tx (
|
58 |
|
|
|
59 |
|
|
// transmit clock and reset
|
60 |
|
|
input ck,
|
61 |
|
|
input reset,
|
62 |
|
|
|
63 |
|
|
// SERDES transmit 10B bus
|
64 |
|
|
output [9:0] tbi_txd,
|
65 |
|
|
|
66 |
|
|
// Transmit GMII bus
|
67 |
|
|
input gmii_tx_en_in,
|
68 |
|
|
input gmii_tx_er_in,
|
69 |
|
|
input [7:0] gmii_txd_in,
|
70 |
|
|
|
71 |
|
|
output reg gmii_col,
|
72 |
|
|
|
73 |
|
|
input receiving,
|
74 |
|
|
output reg transmitting,
|
75 |
|
|
|
76 |
|
|
input signal_detect,
|
77 |
|
|
|
78 |
|
|
// Frame transmit pulse
|
79 |
|
|
output tx_frame_pulse,
|
80 |
|
|
|
81 |
|
|
// Auto-negotiation ctrl
|
82 |
|
|
input [2:0] xmit,
|
83 |
|
|
input [15:0] tx_config,
|
84 |
|
|
input mr_main_reset
|
85 |
|
|
|
86 |
|
|
);
|
87 |
|
|
|
88 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
89 |
|
|
// Diagnostics registers
|
90 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
91 |
|
|
|
92 |
|
|
`define TX_FRAME_CNT 16'h0000
|
93 |
|
|
`define TX_DATA_CNT 16'h0001
|
94 |
|
|
`define TX_ERROR_CNT 16'h0002
|
95 |
|
|
`define END_OF_PACKET_NOEXT_CNT 16'h0003
|
96 |
|
|
`define END_OF_PACKET_EXT_CNT 16'h0004
|
97 |
|
|
`define EXTEND_BY_1_CNT 16'h0005
|
98 |
|
|
`define CARRIER_EXTEND_CNT 16'h0006
|
99 |
|
|
`define EPD2_NOEXT_CNT 16'h0007
|
100 |
|
|
`define EPD3_CNT 16'h0008
|
101 |
|
|
`define RESET 16'hffff
|
102 |
|
|
|
103 |
|
|
reg [8:0] ge_x_pcs_tx_stats_inc;
|
104 |
|
|
|
105 |
|
|
reg [15:0] tx_frame_cnt;
|
106 |
|
|
reg [15:0] tx_error_cnt;
|
107 |
|
|
reg [15:0] tx_data_cnt;
|
108 |
|
|
reg [15:0] end_of_packet_noext_cnt;
|
109 |
|
|
reg [15:0] end_of_packet_ext_cnt;
|
110 |
|
|
reg [15:0] extend_by_1_cnt;
|
111 |
|
|
reg [15:0] carrier_extend_cnt;
|
112 |
|
|
reg [15:0] epd2_noext_cnt;
|
113 |
|
|
reg [15:0] epd3_cnt;
|
114 |
|
|
|
115 |
|
|
always @(posedge ck, posedge reset)
|
116 |
|
|
|
117 |
|
|
if (reset)
|
118 |
|
|
begin
|
119 |
|
|
tx_frame_cnt <= 'd0; tx_data_cnt <= 'd0;
|
120 |
|
|
tx_error_cnt <= 'd0; end_of_packet_noext_cnt <= 'd0;
|
121 |
|
|
end_of_packet_ext_cnt <= 'd0; extend_by_1_cnt <= 'd0;
|
122 |
|
|
carrier_extend_cnt <= 'd0; epd2_noext_cnt <= 'd0;
|
123 |
|
|
epd3_cnt <= 'd0;
|
124 |
|
|
end
|
125 |
|
|
else
|
126 |
|
|
begin
|
127 |
|
|
if (ge_x_pcs_tx_stats_inc[0]) tx_frame_cnt <= tx_frame_cnt + 1;
|
128 |
|
|
else if (ge_x_pcs_tx_stats_inc[1]) tx_data_cnt <= tx_data_cnt + 1;
|
129 |
|
|
else if (ge_x_pcs_tx_stats_inc[2]) tx_error_cnt <= tx_error_cnt + 1;
|
130 |
|
|
else if (ge_x_pcs_tx_stats_inc[3]) end_of_packet_noext_cnt <= end_of_packet_noext_cnt + 1;
|
131 |
|
|
else if (ge_x_pcs_tx_stats_inc[4]) end_of_packet_ext_cnt <= end_of_packet_ext_cnt + 1;
|
132 |
|
|
else if (ge_x_pcs_tx_stats_inc[5]) extend_by_1_cnt <= extend_by_1_cnt + 1;
|
133 |
|
|
else if (ge_x_pcs_tx_stats_inc[6]) carrier_extend_cnt <= carrier_extend_cnt + 1;
|
134 |
|
|
else if (ge_x_pcs_tx_stats_inc[7]) epd2_noext_cnt <= epd2_noext_cnt + 1;
|
135 |
|
|
else if (ge_x_pcs_tx_stats_inc[8]) epd3_cnt <= epd3_cnt + 1;
|
136 |
|
|
end
|
137 |
|
|
|
138 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
139 |
|
|
//
|
140 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
141 |
|
|
|
142 |
|
|
assign tx_frame_pulse = ge_x_pcs_tx_stats_inc[0];
|
143 |
|
|
|
144 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
145 |
|
|
// Soft reset
|
146 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
147 |
|
|
reg soft_reset;
|
148 |
|
|
|
149 |
|
|
always @(posedge ck, posedge reset)
|
150 |
|
|
if (reset)
|
151 |
|
|
soft_reset <= 0;
|
152 |
|
|
else
|
153 |
|
|
soft_reset <= mr_main_reset;
|
154 |
|
|
|
155 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
156 |
|
|
// Running disparity
|
157 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
158 |
|
|
|
159 |
|
|
wire encoder_disparity; // 0 - Negative Running Disparity, 1 - Positive Running Disparity
|
160 |
|
|
|
161 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
162 |
|
|
//
|
163 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
164 |
|
|
|
165 |
|
|
reg gmii_tx_en_pipe, gmii_tx_er_pipe; reg [7:0] gmii_txd_pipe;
|
166 |
|
|
|
167 |
|
|
reg gmii_d1, gmii_d1_m_set, gmii_d1_m_clr;
|
168 |
|
|
|
169 |
|
|
always @(posedge ck, posedge reset)
|
170 |
|
|
if (reset)
|
171 |
|
|
begin
|
172 |
|
|
gmii_d1 <= 0;
|
173 |
|
|
gmii_tx_en_pipe <= 0; gmii_tx_er_pipe <= 0; gmii_txd_pipe <= 0;
|
174 |
|
|
end
|
175 |
|
|
else
|
176 |
|
|
begin
|
177 |
|
|
gmii_tx_en_pipe <= gmii_tx_en_in;
|
178 |
|
|
gmii_tx_er_pipe <= gmii_tx_er_in;
|
179 |
|
|
gmii_txd_pipe <= gmii_txd_in;
|
180 |
|
|
|
181 |
|
|
if (gmii_d1_m_set) gmii_d1 <= 1;
|
182 |
|
|
else if (gmii_d1_m_clr) gmii_d1 <= 0;
|
183 |
|
|
|
184 |
|
|
end
|
185 |
|
|
|
186 |
|
|
wire gmii_tx_en = (gmii_d1) ? gmii_tx_en_pipe : gmii_tx_en_in;
|
187 |
|
|
wire gmii_tx_er = (gmii_d1) ? gmii_tx_er_pipe : gmii_tx_er_in;
|
188 |
|
|
wire [7:0] gmii_txd = (gmii_d1) ? gmii_txd_pipe : gmii_txd_in;
|
189 |
|
|
|
190 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
191 |
|
|
// gmii_col
|
192 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
193 |
|
|
|
194 |
|
|
reg gmii_col_m_set, gmii_col_m_clr;
|
195 |
|
|
|
196 |
|
|
|
197 |
|
|
always @(posedge ck, posedge reset)
|
198 |
|
|
if (reset)
|
199 |
|
|
begin
|
200 |
|
|
gmii_col <= 0;
|
201 |
|
|
end
|
202 |
|
|
else
|
203 |
|
|
begin
|
204 |
|
|
if (gmii_col_m_set) begin gmii_col <= 1; end
|
205 |
|
|
else if (gmii_col_m_clr) begin gmii_col <= 0; end
|
206 |
|
|
end
|
207 |
|
|
|
208 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
209 |
|
|
// Current transmit state
|
210 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
211 |
|
|
|
212 |
|
|
reg transmitting_m_set, transmitting_m_clr;
|
213 |
|
|
|
214 |
|
|
always @(posedge ck, posedge reset)
|
215 |
|
|
if (reset)
|
216 |
|
|
begin
|
217 |
|
|
transmitting <= 0;
|
218 |
|
|
end
|
219 |
|
|
else
|
220 |
|
|
begin
|
221 |
|
|
if (transmitting_m_set) begin transmitting <= 1; end
|
222 |
|
|
else if (transmitting_m_clr) begin transmitting <= 0; end
|
223 |
|
|
end
|
224 |
|
|
|
225 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
226 |
|
|
// Configuration Counter and decode logic
|
227 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
228 |
|
|
|
229 |
|
|
reg [3:0] config_cnt;
|
230 |
|
|
|
231 |
|
|
reg config_cnt_clr, config_cnt_inc;
|
232 |
|
|
|
233 |
|
|
always @(posedge ck, posedge reset)
|
234 |
|
|
if (reset)
|
235 |
|
|
config_cnt <= 0;
|
236 |
|
|
else
|
237 |
|
|
begin
|
238 |
|
|
if (config_cnt_clr) config_cnt <= 0;
|
239 |
|
|
else if (config_cnt_inc) config_cnt <= config_cnt + 1;
|
240 |
|
|
end
|
241 |
|
|
|
242 |
|
|
assign config_C1_done = (config_cnt == 3);
|
243 |
|
|
assign config_C2_done = (config_cnt == 7);
|
244 |
|
|
|
245 |
|
|
assign config_cnt_K28_5 = (config_cnt == 0 | config_cnt == 4);
|
246 |
|
|
assign config_cnt_D21_5 = (config_cnt == 1);
|
247 |
|
|
assign config_cnt_D2_2 = (config_cnt == 5);
|
248 |
|
|
assign config_cnt_config_lo = (config_cnt == 2 | config_cnt == 6);
|
249 |
|
|
assign config_cnt_config_hi = (config_cnt == 3 | config_cnt == 7);
|
250 |
|
|
|
251 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
252 |
|
|
// Idle counter and decode logic
|
253 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
254 |
|
|
|
255 |
|
|
reg idle_cnt;
|
256 |
|
|
|
257 |
|
|
reg idle_cnt_m_clr, idle_cnt_m_inc;
|
258 |
|
|
|
259 |
|
|
always @(posedge ck, posedge reset)
|
260 |
|
|
if (reset)
|
261 |
|
|
idle_cnt <= 0;
|
262 |
|
|
else
|
263 |
|
|
begin
|
264 |
|
|
if (idle_cnt_m_clr) idle_cnt <= 0;
|
265 |
|
|
else if (idle_cnt_m_inc) idle_cnt <= idle_cnt + 1;
|
266 |
|
|
|
267 |
|
|
end
|
268 |
|
|
|
269 |
|
|
wire idle_cnt_done, idle_cnt_is_clr, idle_cnt_is_set;
|
270 |
|
|
|
271 |
|
|
assign idle_cnt_done = idle_cnt;
|
272 |
|
|
assign idle_cnt_is_clr = ~idle_cnt;
|
273 |
|
|
assign idle_cnt_is_set = idle_cnt;
|
274 |
|
|
|
275 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
276 |
|
|
// PCS Transmit - IEEE 802.3-2005 Clause 36, Figure 36-6 page 58
|
277 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
278 |
|
|
//
|
279 |
|
|
reg [7:0] encoder_8b_rxd;
|
280 |
|
|
|
281 |
|
|
reg encoder_K;
|
282 |
|
|
|
283 |
|
|
reg encoder_8b_rxd_gmii_txd_m_set, encoder_8b_rxd_config_lo_m_set, encoder_8b_rxd_config_hi_m_set;
|
284 |
|
|
|
285 |
|
|
reg encoder_8b_rxd_K30_7_m_set, encoder_8b_rxd_K29_7_m_set, encoder_8b_rxd_K28_1_m_set, encoder_8b_rxd_K28_5_m_set, encoder_8b_rxd_K27_7_m_set, encoder_8b_rxd_K23_7_m_set;
|
286 |
|
|
|
287 |
|
|
reg encoder_8b_rxd_D21_5_m_set, encoder_8b_rxd_D2_2_m_set, encoder_8b_rxd_D5_6_m_set, encoder_8b_rxd_D16_2_m_set;
|
288 |
|
|
|
289 |
|
|
reg encoder_tx_even;
|
290 |
|
|
|
291 |
|
|
wire encoder_tx_even_set = (encoder_8b_rxd_K28_5_m_set| encoder_8b_rxd_config_lo_m_set);
|
292 |
|
|
|
293 |
|
|
wire encoder_tx_even_clr = (encoder_8b_rxd_D21_5_m_set|encoder_8b_rxd_D21_5_m_set|encoder_8b_rxd_D5_6_m_set|encoder_8b_rxd_D16_2_m_set|encoder_8b_rxd_config_hi_m_set);
|
294 |
|
|
|
295 |
|
|
wire encoder_tx_even_toggle = (encoder_8b_rxd_gmii_txd_m_set|encoder_8b_rxd_K30_7_m_set|encoder_8b_rxd_K27_7_m_set|encoder_8b_rxd_K29_7_m_set|encoder_8b_rxd_K23_7_m_set);
|
296 |
|
|
|
297 |
|
|
always @(posedge ck, posedge reset)
|
298 |
|
|
if (reset)
|
299 |
|
|
begin
|
300 |
|
|
encoder_K <= 0; encoder_8b_rxd <= 0; encoder_tx_even <= 0;
|
301 |
|
|
end
|
302 |
|
|
else
|
303 |
|
|
begin
|
304 |
|
|
// Input 8b10b encode K ctrl strobe
|
305 |
|
|
encoder_K <= encoder_8b_rxd_K30_7_m_set|encoder_8b_rxd_K29_7_m_set|encoder_8b_rxd_K28_5_m_set|encoder_8b_rxd_K27_7_m_set|encoder_8b_rxd_K23_7_m_set;
|
306 |
|
|
|
307 |
|
|
// Input to 8b10b encode EBI (Eight Bit Interface) bus.
|
308 |
|
|
encoder_8b_rxd <=
|
309 |
|
|
// Drive special K codes onto 8b10_enc encoder_8b_rxd - K strobe high
|
310 |
|
|
encoder_8b_rxd_K30_7_m_set ? `K30_7_symbol :
|
311 |
|
|
encoder_8b_rxd_K29_7_m_set ? `K29_7_symbol :
|
312 |
|
|
encoder_8b_rxd_K28_5_m_set ? `K28_5_symbol :
|
313 |
|
|
encoder_8b_rxd_K28_1_m_set ? `K28_1_symbol :
|
314 |
|
|
encoder_8b_rxd_K27_7_m_set ? `K27_7_symbol :
|
315 |
|
|
encoder_8b_rxd_K23_7_m_set ? `K23_7_symbol :
|
316 |
|
|
// Drive Special Data Codes onto 8b10 enc encoder_8b_rxd - K strobe low
|
317 |
|
|
encoder_8b_rxd_D21_5_m_set ? `D21_5_symbol :
|
318 |
|
|
encoder_8b_rxd_D2_2_m_set ? `D2_2_symbol :
|
319 |
|
|
encoder_8b_rxd_D5_6_m_set ? `D5_6_symbol :
|
320 |
|
|
encoder_8b_rxd_D16_2_m_set ? `D16_2_symbol :
|
321 |
|
|
// Drive Tx Config register onto 8b10 enc encoder_8b_rxd - K strobe low
|
322 |
|
|
encoder_8b_rxd_config_lo_m_set ? tx_config[7:0] :
|
323 |
|
|
encoder_8b_rxd_config_hi_m_set ? tx_config[15:8] :
|
324 |
|
|
|
325 |
|
|
// Drive GMII txd onto 8b10 enc encoder_8b_rxd - K strobe low
|
326 |
|
|
encoder_8b_rxd_gmii_txd_m_set ? gmii_txd : 0;
|
327 |
|
|
|
328 |
|
|
// Keep track of even/odd TX status
|
329 |
|
|
encoder_tx_even <= encoder_tx_even_set ? 1 :
|
330 |
|
|
encoder_tx_even_clr ? 0 :
|
331 |
|
|
encoder_tx_even_toggle ? ~encoder_tx_even : encoder_tx_even;
|
332 |
|
|
end
|
333 |
|
|
|
334 |
|
|
|
335 |
|
|
|
336 |
|
|
|
337 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
338 |
|
|
// VOID - see IEEE 802.3-2005 Section 36 (PCS) page 55
|
339 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
340 |
|
|
|
341 |
|
|
assign VOID = (~gmii_tx_en & gmii_tx_er & gmii_txd != 8'b00001111) | (gmii_tx_en & gmii_tx_er);
|
342 |
|
|
|
343 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
344 |
|
|
// Instantiate 8b10 Encode module
|
345 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
346 |
|
|
//
|
347 |
|
|
encoder_8b10b encoder_8b10bi(
|
348 |
|
|
|
349 |
|
|
// Clocks
|
350 |
|
|
.SBYTECLK(ck),
|
351 |
|
|
|
352 |
|
|
// Reset
|
353 |
|
|
.reset(reset),
|
354 |
|
|
|
355 |
|
|
// eight bit interface (ebi) input
|
356 |
|
|
.ebi(encoder_8b_rxd),
|
357 |
|
|
|
358 |
|
|
// ten bit interface (tbi) output to TBI bus
|
359 |
|
|
.tbi(tbi_txd),
|
360 |
|
|
|
361 |
|
|
// Data/special code-group ctrl
|
362 |
|
|
.K(encoder_K),
|
363 |
|
|
|
364 |
|
|
// Running Disparity
|
365 |
|
|
.disparity(encoder_disparity)
|
366 |
|
|
);
|
367 |
|
|
|
368 |
|
|
|
369 |
|
|
`ifdef MODEL_TECH
|
370 |
|
|
|
371 |
|
|
wire [4:0] encoder_8b_X; wire [2:0] encoder_8b_Y;
|
372 |
|
|
|
373 |
|
|
assign encoder_8b_X = encoder_8b_rxd[4:0];
|
374 |
|
|
assign encoder_8b_Y = encoder_8b_rxd[7:5];
|
375 |
|
|
`endif
|
376 |
|
|
|
377 |
|
|
`ifdef MODEL_TECH
|
378 |
|
|
enum logic [4:0] {
|
379 |
|
|
`else
|
380 |
|
|
localparam
|
381 |
|
|
`endif
|
382 |
|
|
S_PCS_TX_TEST_XMIT = 0,
|
383 |
|
|
S_PCS_TX_XMIT_DATA = 1,
|
384 |
|
|
S_PCS_TX_ALIGN_ERR_START = 2,
|
385 |
|
|
S_PCS_TX_START_ERROR = 3,
|
386 |
|
|
S_PCS_TX_DATA_ERROR = 4,
|
387 |
|
|
S_PCS_TX_START_OF_PACKET = 5,
|
388 |
|
|
S_PCS_TX_PACKET = 6,
|
389 |
|
|
S_PCS_TX_END_OF_PACKET_NOEXT = 7,
|
390 |
|
|
S_PCS_TX_END_OF_PACKET_EXT = 8,
|
391 |
|
|
S_PCS_TX_EXTEND_BY_1 = 9,
|
392 |
|
|
S_PCS_TX_CARRIER_EXTEND = 10,
|
393 |
|
|
S_PCS_TX_EPD2_NOEXT = 11,
|
394 |
|
|
S_PCS_TX_EPD3 = 12,
|
395 |
|
|
S_PCS_TX_CONFIGURATION = 13,
|
396 |
|
|
S_PCS_TX_IDLE = 14
|
397 |
|
|
`ifdef MODEL_TECH
|
398 |
|
|
} pcs_tx_present, pcs_tx_next;
|
399 |
|
|
`else
|
400 |
|
|
; reg [4:0] pcs_tx_present, pcs_tx_next;
|
401 |
|
|
`endif
|
402 |
|
|
|
403 |
|
|
|
404 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
405 |
|
|
// xmit ctrl
|
406 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
407 |
|
|
|
408 |
|
|
wire xmit_idle, xmit_configuration, xmit_data;
|
409 |
|
|
|
410 |
|
|
assign xmit_configuration = (xmit == `XMIT_CONFIGURATION);
|
411 |
|
|
|
412 |
|
|
assign xmit_idle = (xmit == `XMIT_IDLE) | (xmit == `XMIT_DATA & (gmii_tx_en | gmii_tx_er));
|
413 |
|
|
|
414 |
|
|
assign xmit_data = (xmit == `XMIT_DATA & ~gmii_tx_en & ~gmii_tx_er);
|
415 |
|
|
|
416 |
|
|
reg [2:0] xmit_saved; wire xmitCHANGE;
|
417 |
|
|
|
418 |
|
|
always @(posedge ck, posedge reset)
|
419 |
|
|
|
420 |
|
|
xmit_saved <= (reset) ? `XMIT_IDLE : xmit;
|
421 |
|
|
|
422 |
|
|
assign xmitCHANGE = (xmit != xmit_saved);
|
423 |
|
|
|
424 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
425 |
|
|
// transmit state machine registered part.
|
426 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
427 |
|
|
|
428 |
|
|
always @(posedge ck, posedge reset)
|
429 |
|
|
|
430 |
|
|
pcs_tx_present <= (reset) ? S_PCS_TX_TEST_XMIT : pcs_tx_next;
|
431 |
|
|
|
432 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
433 |
|
|
// transmit state machine - IEEE 802.3-2008 Clause 36
|
434 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
435 |
|
|
|
436 |
|
|
always @*
|
437 |
|
|
begin
|
438 |
|
|
pcs_tx_next = pcs_tx_present;
|
439 |
|
|
|
440 |
|
|
encoder_8b_rxd_gmii_txd_m_set = 0;
|
441 |
|
|
|
442 |
|
|
encoder_8b_rxd_K30_7_m_set = 0;
|
443 |
|
|
encoder_8b_rxd_K29_7_m_set = 0;
|
444 |
|
|
encoder_8b_rxd_K28_5_m_set = 0;
|
445 |
|
|
encoder_8b_rxd_K28_1_m_set = 0;
|
446 |
|
|
encoder_8b_rxd_K27_7_m_set = 0;
|
447 |
|
|
encoder_8b_rxd_K23_7_m_set = 0;
|
448 |
|
|
|
449 |
|
|
encoder_8b_rxd_D21_5_m_set = 0;
|
450 |
|
|
encoder_8b_rxd_D2_2_m_set = 0;
|
451 |
|
|
encoder_8b_rxd_D5_6_m_set = 0;
|
452 |
|
|
encoder_8b_rxd_D16_2_m_set = 0;
|
453 |
|
|
|
454 |
|
|
encoder_8b_rxd_config_lo_m_set = 0;
|
455 |
|
|
encoder_8b_rxd_config_hi_m_set = 0;
|
456 |
|
|
|
457 |
|
|
transmitting_m_set = 0; transmitting_m_clr = 0;
|
458 |
|
|
|
459 |
|
|
gmii_col_m_set = 0; gmii_col_m_clr = 0;
|
460 |
|
|
|
461 |
|
|
config_cnt_clr = 0; config_cnt_inc = 0;
|
462 |
|
|
|
463 |
|
|
idle_cnt_m_clr = 0; idle_cnt_m_inc = 0;
|
464 |
|
|
|
465 |
|
|
gmii_d1_m_set = 0; gmii_d1_m_clr = 0;
|
466 |
|
|
|
467 |
|
|
ge_x_pcs_tx_stats_inc = 'd0;
|
468 |
|
|
|
469 |
|
|
case (pcs_tx_present)
|
470 |
|
|
|
471 |
|
|
S_PCS_TX_TEST_XMIT:
|
472 |
|
|
begin
|
473 |
|
|
transmitting_m_clr = 1; gmii_col_m_clr = 1; gmii_d1_m_clr = 1;
|
474 |
|
|
|
475 |
|
|
pcs_tx_next = xmit_configuration ? S_PCS_TX_CONFIGURATION :
|
476 |
|
|
xmit_idle ? S_PCS_TX_IDLE :
|
477 |
|
|
xmit_data ? S_PCS_TX_XMIT_DATA : S_PCS_TX_TEST_XMIT;
|
478 |
|
|
|
479 |
|
|
idle_cnt_m_clr = xmit_idle; config_cnt_clr = xmit_configuration;
|
480 |
|
|
end
|
481 |
|
|
|
482 |
|
|
S_PCS_TX_XMIT_DATA:
|
483 |
|
|
begin
|
484 |
|
|
|
485 |
|
|
idle_cnt_m_inc = idle_cnt_is_clr; idle_cnt_m_clr = ~idle_cnt_is_clr;
|
486 |
|
|
|
487 |
|
|
encoder_8b_rxd_D5_6_m_set = (~idle_cnt_is_clr & encoder_disparity);
|
488 |
|
|
encoder_8b_rxd_D16_2_m_set = (~idle_cnt_is_clr & ~encoder_disparity);
|
489 |
|
|
encoder_8b_rxd_K28_5_m_set = (idle_cnt_is_clr & ~gmii_tx_en);
|
490 |
|
|
|
491 |
|
|
encoder_8b_rxd_K27_7_m_set = (idle_cnt_is_clr & gmii_tx_en);
|
492 |
|
|
|
493 |
|
|
gmii_d1_m_set = ~idle_cnt_is_clr & gmii_tx_en ;
|
494 |
|
|
|
495 |
|
|
transmitting_m_set = (idle_cnt_is_clr & gmii_tx_en);
|
496 |
|
|
|
497 |
|
|
if (idle_cnt_is_clr & gmii_tx_en & receiving) gmii_col_m_set = 1; else gmii_col_m_clr = 1;
|
498 |
|
|
|
499 |
|
|
if (idle_cnt_is_clr)
|
500 |
|
|
begin
|
501 |
|
|
pcs_tx_next = (xmit != `XMIT_DATA) ? S_PCS_TX_TEST_XMIT :
|
502 |
|
|
(~gmii_tx_en) ? S_PCS_TX_XMIT_DATA :
|
503 |
|
|
(gmii_tx_er) ? S_PCS_TX_DATA_ERROR : S_PCS_TX_PACKET;
|
504 |
|
|
|
505 |
|
|
// Keep count of good frames
|
506 |
|
|
ge_x_pcs_tx_stats_inc[0] = gmii_tx_en & ~gmii_tx_er;
|
507 |
|
|
|
508 |
|
|
// Keep count of errored frames
|
509 |
|
|
ge_x_pcs_tx_stats_inc[2] = gmii_tx_en & gmii_tx_er;
|
510 |
|
|
|
511 |
|
|
end
|
512 |
|
|
end
|
513 |
|
|
|
514 |
|
|
|
515 |
|
|
S_PCS_TX_START_ERROR:
|
516 |
|
|
begin
|
517 |
|
|
transmitting_m_set = 1;
|
518 |
|
|
|
519 |
|
|
if (receiving) gmii_col_m_set = 1; else gmii_col_m_clr = 1;
|
520 |
|
|
|
521 |
|
|
encoder_8b_rxd_K27_7_m_set = 1;
|
522 |
|
|
|
523 |
|
|
pcs_tx_next = S_PCS_TX_DATA_ERROR;
|
524 |
|
|
end
|
525 |
|
|
|
526 |
|
|
|
527 |
|
|
S_PCS_TX_DATA_ERROR:
|
528 |
|
|
begin
|
529 |
|
|
if (receiving) gmii_col_m_set = 1; else gmii_col_m_clr = 1;
|
530 |
|
|
|
531 |
|
|
encoder_8b_rxd_K30_7_m_set = 1;
|
532 |
|
|
|
533 |
|
|
pcs_tx_next = S_PCS_TX_PACKET;
|
534 |
|
|
end
|
535 |
|
|
|
536 |
|
|
|
537 |
|
|
S_PCS_TX_START_OF_PACKET:
|
538 |
|
|
begin
|
539 |
|
|
transmitting_m_set = 1; encoder_8b_rxd_K27_7_m_set = 1;
|
540 |
|
|
|
541 |
|
|
if (receiving) gmii_col_m_set = 1; else gmii_col_m_clr = 1;
|
542 |
|
|
|
543 |
|
|
pcs_tx_next = S_PCS_TX_PACKET;
|
544 |
|
|
end
|
545 |
|
|
|
546 |
|
|
S_PCS_TX_PACKET:
|
547 |
|
|
begin
|
548 |
|
|
idle_cnt_m_clr = 1;
|
549 |
|
|
|
550 |
|
|
// END_OF_PACKET_NOEXT
|
551 |
|
|
if (~gmii_tx_en & ~gmii_tx_er)
|
552 |
|
|
begin
|
553 |
|
|
if (~encoder_tx_even) transmitting_m_clr = 1;
|
554 |
|
|
|
555 |
|
|
gmii_col_m_clr = 1; encoder_8b_rxd_K29_7_m_set = 1;
|
556 |
|
|
|
557 |
|
|
pcs_tx_next = S_PCS_TX_EPD2_NOEXT;
|
558 |
|
|
end
|
559 |
|
|
|
560 |
|
|
// END_OF_PACKET_EXT
|
561 |
|
|
else if (~gmii_tx_en & gmii_tx_er)
|
562 |
|
|
begin
|
563 |
|
|
if (receiving) gmii_col_m_set = 1; else gmii_col_m_clr = 1;
|
564 |
|
|
|
565 |
|
|
if (VOID) encoder_8b_rxd_K30_7_m_set = 1; else encoder_8b_rxd_K29_7_m_set = 1;
|
566 |
|
|
|
567 |
|
|
pcs_tx_next = (gmii_tx_er) ? S_PCS_TX_CARRIER_EXTEND : S_PCS_TX_EXTEND_BY_1;
|
568 |
|
|
end
|
569 |
|
|
|
570 |
|
|
else // TX_DATA
|
571 |
|
|
begin
|
572 |
|
|
// Keep count of number of TX bytes
|
573 |
|
|
ge_x_pcs_tx_stats_inc[1] = 1;
|
574 |
|
|
|
575 |
|
|
if (receiving) gmii_col_m_set = 1; else gmii_col_m_clr = 1;
|
576 |
|
|
|
577 |
|
|
if (VOID) encoder_8b_rxd_K30_7_m_set = 1; else encoder_8b_rxd_gmii_txd_m_set = 1;
|
578 |
|
|
end
|
579 |
|
|
end
|
580 |
|
|
|
581 |
|
|
S_PCS_TX_END_OF_PACKET_NOEXT:
|
582 |
|
|
begin
|
583 |
|
|
|
584 |
|
|
ge_x_pcs_tx_stats_inc[3] = 1;
|
585 |
|
|
|
586 |
|
|
if (~encoder_tx_even) transmitting_m_clr = 1;
|
587 |
|
|
|
588 |
|
|
gmii_col_m_clr = 1; encoder_8b_rxd_K29_7_m_set = 1;
|
589 |
|
|
|
590 |
|
|
pcs_tx_next = S_PCS_TX_EPD2_NOEXT;
|
591 |
|
|
end
|
592 |
|
|
|
593 |
|
|
|
594 |
|
|
S_PCS_TX_END_OF_PACKET_EXT:
|
595 |
|
|
begin
|
596 |
|
|
|
597 |
|
|
ge_x_pcs_tx_stats_inc[4] = 1;
|
598 |
|
|
|
599 |
|
|
if (receiving) gmii_col_m_set = 1; else gmii_col_m_clr = 1;
|
600 |
|
|
|
601 |
|
|
if (VOID) encoder_8b_rxd_K30_7_m_set = 1; else encoder_8b_rxd_K29_7_m_set = 1;
|
602 |
|
|
|
603 |
|
|
pcs_tx_next = (gmii_tx_er) ? S_PCS_TX_CARRIER_EXTEND : S_PCS_TX_EXTEND_BY_1;
|
604 |
|
|
end
|
605 |
|
|
|
606 |
|
|
S_PCS_TX_EXTEND_BY_1:
|
607 |
|
|
begin
|
608 |
|
|
ge_x_pcs_tx_stats_inc[5] = 1;
|
609 |
|
|
|
610 |
|
|
if (~encoder_tx_even) transmitting_m_clr = 1;
|
611 |
|
|
|
612 |
|
|
gmii_col_m_clr = 1; encoder_8b_rxd_K23_7_m_set = 1;
|
613 |
|
|
|
614 |
|
|
pcs_tx_next = S_PCS_TX_EPD2_NOEXT;
|
615 |
|
|
end
|
616 |
|
|
|
617 |
|
|
|
618 |
|
|
S_PCS_TX_CARRIER_EXTEND:
|
619 |
|
|
begin
|
620 |
|
|
|
621 |
|
|
ge_x_pcs_tx_stats_inc[6] = 1;
|
622 |
|
|
|
623 |
|
|
if (receiving) gmii_col_m_set = 1; else gmii_col_m_clr = 1;
|
624 |
|
|
|
625 |
|
|
if (VOID) encoder_8b_rxd_K30_7_m_set = 1; else encoder_8b_rxd_K23_7_m_set = 1;
|
626 |
|
|
|
627 |
|
|
pcs_tx_next = (~gmii_tx_en & ~gmii_tx_er) ? S_PCS_TX_EXTEND_BY_1 :
|
628 |
|
|
(gmii_tx_en & gmii_tx_er) ? S_PCS_TX_START_ERROR :
|
629 |
|
|
(gmii_tx_en & ~gmii_tx_er) ? S_PCS_TX_START_OF_PACKET :
|
630 |
|
|
S_PCS_TX_CARRIER_EXTEND;
|
631 |
|
|
end
|
632 |
|
|
|
633 |
|
|
S_PCS_TX_EPD2_NOEXT:
|
634 |
|
|
begin
|
635 |
|
|
|
636 |
|
|
ge_x_pcs_tx_stats_inc[7] = 1;
|
637 |
|
|
|
638 |
|
|
gmii_d1_m_clr = 1; transmitting_m_clr = 1; encoder_8b_rxd_K23_7_m_set = 1;
|
639 |
|
|
|
640 |
|
|
pcs_tx_next = (encoder_tx_even) ? S_PCS_TX_XMIT_DATA : S_PCS_TX_EPD3;
|
641 |
|
|
end
|
642 |
|
|
|
643 |
|
|
|
644 |
|
|
S_PCS_TX_EPD3:
|
645 |
|
|
begin
|
646 |
|
|
ge_x_pcs_tx_stats_inc[8] = 1;
|
647 |
|
|
|
648 |
|
|
encoder_8b_rxd_K23_7_m_set = 1;
|
649 |
|
|
|
650 |
|
|
pcs_tx_next = S_PCS_TX_XMIT_DATA;
|
651 |
|
|
end
|
652 |
|
|
|
653 |
|
|
//////////////////////////////////////////////////////////////////////////////
|
654 |
|
|
// IEEE 802.3-2005 Clause 36 Figure 36-6
|
655 |
|
|
|
656 |
|
|
S_PCS_TX_CONFIGURATION:
|
657 |
|
|
begin
|
658 |
|
|
encoder_8b_rxd_K28_5_m_set = config_cnt_K28_5;
|
659 |
|
|
encoder_8b_rxd_D21_5_m_set = config_cnt_D21_5;
|
660 |
|
|
encoder_8b_rxd_D2_2_m_set = config_cnt_D2_2;
|
661 |
|
|
encoder_8b_rxd_config_lo_m_set = config_cnt_config_lo;
|
662 |
|
|
|
663 |
|
|
encoder_8b_rxd_config_hi_m_set = config_cnt_config_hi;
|
664 |
|
|
|
665 |
|
|
if ((config_C1_done | config_C2_done))
|
666 |
|
|
begin
|
667 |
|
|
pcs_tx_next = (xmit_idle) ? S_PCS_TX_IDLE :
|
668 |
|
|
(xmit_data) ? S_PCS_TX_XMIT_DATA : S_PCS_TX_CONFIGURATION;
|
669 |
|
|
|
670 |
|
|
idle_cnt_m_clr = xmit_idle;
|
671 |
|
|
end
|
672 |
|
|
|
673 |
|
|
if (config_C2_done | (config_C1_done & (xmit != `XMIT_CONFIGURATION))) config_cnt_clr = 1;
|
674 |
|
|
else config_cnt_inc = 1;
|
675 |
|
|
end
|
676 |
|
|
|
677 |
|
|
|
678 |
|
|
S_PCS_TX_IDLE:
|
679 |
|
|
begin
|
680 |
|
|
encoder_8b_rxd_K28_5_m_set = idle_cnt_is_clr;
|
681 |
|
|
encoder_8b_rxd_D5_6_m_set = (idle_cnt_is_set & encoder_disparity);
|
682 |
|
|
encoder_8b_rxd_D16_2_m_set = (idle_cnt_is_set & ~encoder_disparity);
|
683 |
|
|
|
684 |
|
|
pcs_tx_next = (idle_cnt_done & xmit_data) ? S_PCS_TX_XMIT_DATA :
|
685 |
|
|
(idle_cnt_done & xmit_configuration) ? S_PCS_TX_CONFIGURATION : S_PCS_TX_IDLE;
|
686 |
|
|
|
687 |
|
|
idle_cnt_m_clr = idle_cnt_done; idle_cnt_m_inc = ~idle_cnt_done;
|
688 |
|
|
|
689 |
|
|
config_cnt_clr = (idle_cnt_done & xmit_configuration);
|
690 |
|
|
end
|
691 |
|
|
endcase
|
692 |
|
|
|
693 |
|
|
if (mr_main_reset) pcs_tx_next = S_PCS_TX_TEST_XMIT;
|
694 |
|
|
|
695 |
|
|
end
|
696 |
|
|
|
697 |
|
|
|
698 |
|
|
endmodule
|