Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / niu / rtl / esr_ctl2.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: esr_ctl2.v
4// Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
5// 4150 Network Circle, Santa Clara, California 95054, U.S.A.
6//
7// * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8//
9// This program is free software; you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation; version 2 of the License.
12//
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License
19// along with this program; if not, write to the Free Software
20// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21//
22// For the avoidance of doubt, and except that if any non-GPL license
23// choice is available it will apply instead, Sun elects to use only
24// the General Public License version 2 (GPLv2) at this time for any
25// software where a choice of GPL license versions is made
26// available with the language indicating that GPLv2 or any later version
27// may be used, or where a choice of which version of the GPL is applied is
28// otherwise unspecified.
29//
30// Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
31// CA 95054 USA or visit www.sun.com if you need additional information or
32// have any questions.
33//
34// ========== Copyright Header End ============================================
35/*%W% %G%*/
36
37/*************************************************************************
38 *
39 * File Name : esr_ctl2.v
40 * Author Name : John Lo
41 * Description : ethernet serdes controller.
42 * This module main function is to produce
43 * 1. serdes_rdy
44 * 2. signal_detect
45 *
46 * This module is in sys_clk domain.
47 *
48 * The corresponding data path is in sphy_dpath4.
49 * The corresponding clock path is in phy_clock_2ports.
50 * The muxing on esr_ctl2, sphy_dpath2, and phy_clock_2ports
51 * should be in sync. -> This is very important.
52 *
53 * Parent Module: mac_2ports
54 * Child Module:
55 * Interface Mod:
56 * Date Created : 3/23/04
57 *
58 * Copyright (c) 2020, Sun Microsystems, Inc.
59 * Sun Proprietary and Confidential
60 *
61 * Modification :
62 *
63 * Synthesis Notes:
64 *
65 *************************************************************************/
66
67
68module esr_ctl2 (
69pio_core_reset,
70clk,
71blunt_end_loopback,
72// pio interface
73pio_addr, // pio global signal
74pio_rd, // pio global signal
75pio_wdata, // pio global signal
76sel_esr,
77ack_esr,
78rdata_esr,
79pio_err_esr,
80serdes_reset_0,
81serdes_reset_1,
82// port0 xpcs, pcs signals
83esr_mac_lock_0,
84esr_mac_los_0,
85serdes_rdy0_0,
86signal_detect0_0,
87xserdes_rdy_0,
88xsignal_detect_0,
89// port1 xpcs, pcs signals
90esr_mac_lock_1,
91esr_mac_los_1,
92serdes_rdy0_1,
93signal_detect0_1,
94xserdes_rdy_1,
95xsignal_detect_1,
96/* ----- debug data ----- */
97// ---- port 0 serdes 0
98// tx side signals
99xtx_code_group0,
100tx_code_group0,
101mac_esr_txd0_0,
102mac_esr_txd1_0,
103mac_esr_txd2_0,
104mac_esr_txd3_0,
105// rx side signals
106esr_mac_rxd0_0,
107esr_mac_rxd1_0,
108esr_mac_rxd2_0,
109esr_mac_rxd3_0,
110xrx_code_group0,
111rx_code_group0,
112// ---- port 1 serdes 1
113// tx side signals
114xtx_code_group1,
115tx_code_group1,
116mac_esr_txd0_1,
117mac_esr_txd1_1,
118mac_esr_txd2_1,
119mac_esr_txd3_1,
120// rx side signals
121esr_mac_rxd0_1,
122esr_mac_rxd1_1,
123esr_mac_rxd2_1,
124esr_mac_rxd3_1,
125xrx_code_group1,
126rx_code_group1,
127esrctl_debug
128 );
129
130 // global signals
131 input pio_core_reset;
132 input clk;
133 output blunt_end_loopback;
134 // pio interface
135 input [8:0] pio_addr; // pio global signal
136 input pio_rd; // pio global signal
137 input [31:0] pio_wdata; // pio global signal
138 input sel_esr;
139 output ack_esr;
140 output [31:0] rdata_esr;
141 output pio_err_esr;
142 output serdes_reset_0;
143 output serdes_reset_1;
144 // port0 xpcs, pcs signals
145 input esr_mac_lock_0;
146 input [3:0] esr_mac_los_0;
147 output serdes_rdy0_0;
148 output signal_detect0_0;
149 output xserdes_rdy_0;
150 output [3:0] xsignal_detect_0;
151 // port1 xpcs, pcs signals
152 input esr_mac_lock_1;
153 input [3:0] esr_mac_los_1;
154 output serdes_rdy0_1;
155 output signal_detect0_1;
156 output xserdes_rdy_1;
157 output [3:0] xsignal_detect_1;
158 /* ----- debug data ----- */
159 // ----- port 0 serdes 0
160 // tx side signals
161 input [39:0] xtx_code_group0;
162 input [9:0] tx_code_group0;
163 input [9:0] mac_esr_txd0_0;
164 input [9:0] mac_esr_txd1_0;
165 input [9:0] mac_esr_txd2_0;
166 input [9:0] mac_esr_txd3_0;
167 // rx side signals
168 input [9:0] esr_mac_rxd0_0;
169 input [9:0] esr_mac_rxd1_0;
170 input [9:0] esr_mac_rxd2_0;
171 input [9:0] esr_mac_rxd3_0;
172 input [39:0] xrx_code_group0;
173 input [9:0] rx_code_group0;
174 // ----- port 1 serdes 1
175 // tx side signals
176 input [39:0] xtx_code_group1;
177 input [9:0] tx_code_group1;
178 input [9:0] mac_esr_txd0_1;
179 input [9:0] mac_esr_txd1_1;
180 input [9:0] mac_esr_txd2_1;
181 input [9:0] mac_esr_txd3_1;
182 // rx side signals
183 input [9:0] esr_mac_rxd0_1;
184 input [9:0] esr_mac_rxd1_1;
185 input [9:0] esr_mac_rxd2_1;
186 input [9:0] esr_mac_rxd3_1;
187 input [39:0] xrx_code_group1;
188 input [9:0] rx_code_group1;
189 output [31:0] esrctl_debug;
190
191///////////////////////////////////////////////////////////////
192
193 // serdes0
194 wire esr_mac_lock_0;
195 wire [3:0] esr_mac_los_0;
196 wire serdes_rdy0_0;
197 wire serdes_rdy1_0;
198 wire serdes_rdy2_0;
199 wire serdes_rdy3_0;
200 wire signal_detect0_0;
201 reg xserdes_rdy_0;
202 wire [3:0] xsignal_detect_0;
203 // serdes1
204 wire esr_mac_lock_1;
205 wire [3:0] esr_mac_los_1;
206 wire serdes_rdy0_1;
207 wire serdes_rdy1_1;
208 wire serdes_rdy2_1;
209 wire serdes_rdy3_1;
210 wire signal_detect0_1;
211 reg xserdes_rdy_1;
212 wire [3:0] xsignal_detect_1;
213
214 wire reset;
215 wire pio_core_reset;
216 wire [31:0] rdata_esr;
217 wire [8:0] reg_offset;
218 wire pio_err_esr;
219 reg [31:0] rd_data;
220 reg ld_debug_sel;
221 reg non_qualified_addr_err;
222 reg ld_serdes_reset ;
223 reg ld_configa ;
224 wire force_serdes_rdy ;
225 wire blunt_end_loopback ;
226 wire [1:0] serdes_reset ;
227 wire [1:0] configa ;
228 wire wr_en;
229 wire addr_err;
230 wire lock_0;
231 wire lock_1;
232 wire los0_0;
233 wire los1_0;
234 wire los2_0;
235 wire los3_0;
236 wire los0_1;
237 wire los1_1;
238 wire los2_1;
239 wire los3_1;
240 wire rd_wr;
241 wire core_sel;
242 wire core_sel_lead;
243 // vlint flag_dangling_net_within_module off
244 // vlint flag_net_has_no_load off
245 wire [31:0] wr_data;
246 wire rd_en;
247 wire rac_pls;
248 wire core_sel_trail;
249 // vlint flag_net_has_no_load on
250 // vlint flag_dangling_net_within_module on
251
252 wire [31:0] debug_sel;
253
254// **********************************
255// global logic
256// **********************************
257
258SYNC_CELL lock_0_SYNC_CELL (.D(esr_mac_lock_0),.CP(clk),.Q(lock_0));
259SYNC_CELL lock_1_SYNC_CELL (.D(esr_mac_lock_1),.CP(clk),.Q(lock_1));
260
261// **********************************
262// serdes0 10G/1G PCS
263// **********************************
264
265SYNC_CELL los0_0_SYNC_CELL (.D(esr_mac_los_0[0]),.CP(clk),.Q(los0_0));
266SYNC_CELL los1_0_SYNC_CELL (.D(esr_mac_los_0[1]),.CP(clk),.Q(los1_0));
267SYNC_CELL los2_0_SYNC_CELL (.D(esr_mac_los_0[2]),.CP(clk),.Q(los2_0));
268SYNC_CELL los3_0_SYNC_CELL (.D(esr_mac_los_0[3]),.CP(clk),.Q(los3_0));
269
270 wire set_serdes_rdy0_0 = (lock_0 & ~los0_0) | force_serdes_rdy;
271 wire set_serdes_rdy1_0 = (lock_0 & ~los1_0) | force_serdes_rdy;
272 wire set_serdes_rdy2_0 = (lock_0 & ~los2_0) | force_serdes_rdy;
273 wire set_serdes_rdy3_0 = (lock_0 & ~los3_0) | force_serdes_rdy;
274
275SRFF serdes_rdy0_0_SRFF (.reset(reset),.clk(clk),.iSet(set_serdes_rdy0_0),.iRst(los0_0),.oQ(serdes_rdy0_0));
276SRFF serdes_rdy1_0_SRFF (.reset(reset),.clk(clk),.iSet(set_serdes_rdy1_0),.iRst(los1_0),.oQ(serdes_rdy1_0));
277SRFF serdes_rdy2_0_SRFF (.reset(reset),.clk(clk),.iSet(set_serdes_rdy2_0),.iRst(los2_0),.oQ(serdes_rdy2_0));
278SRFF serdes_rdy3_0_SRFF (.reset(reset),.clk(clk),.iSet(set_serdes_rdy3_0),.iRst(los3_0),.oQ(serdes_rdy3_0));
279
280 assign signal_detect0_0 = ~los0_0;
281
282 always @ (posedge clk)
283 xserdes_rdy_0 <= serdes_rdy0_0 &
284 serdes_rdy1_0 &
285 serdes_rdy2_0 &
286 serdes_rdy3_0 ;
287
288 assign xsignal_detect_0[3:0] = {~los3_0,~los2_0,~los1_0,~los0_0};
289
290
291// **********************************
292// serdes1 10G/1G PCS
293// **********************************
294
295SYNC_CELL los0_1_SYNC_CELL (.D(esr_mac_los_1[0]),.CP(clk),.Q(los0_1));
296SYNC_CELL los1_1_SYNC_CELL (.D(esr_mac_los_1[1]),.CP(clk),.Q(los1_1));
297SYNC_CELL los2_1_SYNC_CELL (.D(esr_mac_los_1[2]),.CP(clk),.Q(los2_1));
298SYNC_CELL los3_1_SYNC_CELL (.D(esr_mac_los_1[3]),.CP(clk),.Q(los3_1));
299
300 wire set_serdes_rdy0_1 = (lock_1 & ~los0_1) | force_serdes_rdy;
301 wire set_serdes_rdy1_1 = (lock_1 & ~los1_1) | force_serdes_rdy;
302 wire set_serdes_rdy2_1 = (lock_1 & ~los2_1) | force_serdes_rdy;
303 wire set_serdes_rdy3_1 = (lock_1 & ~los3_1) | force_serdes_rdy;
304
305SRFF serdes_rdy0_1_SRFF (.reset(reset),.clk(clk),.iSet(set_serdes_rdy0_1),.iRst(los0_1),.oQ(serdes_rdy0_1));
306SRFF serdes_rdy1_1_SRFF (.reset(reset),.clk(clk),.iSet(set_serdes_rdy1_1),.iRst(los1_1),.oQ(serdes_rdy1_1));
307SRFF serdes_rdy2_1_SRFF (.reset(reset),.clk(clk),.iSet(set_serdes_rdy2_1),.iRst(los2_1),.oQ(serdes_rdy2_1));
308SRFF serdes_rdy3_1_SRFF (.reset(reset),.clk(clk),.iSet(set_serdes_rdy3_1),.iRst(los3_1),.oQ(serdes_rdy3_1));
309
310 assign signal_detect0_1 = ~los0_1;
311
312 always @ (posedge clk)
313 xserdes_rdy_1 <= serdes_rdy0_1 &
314 serdes_rdy1_1 &
315 serdes_rdy2_1 &
316 serdes_rdy3_1 ;
317
318 assign xsignal_detect_1[3:0] = {~los3_1,~los2_1,~los1_1,~los0_1};
319
320
321// **********************************
322// PIO Control Logic
323// **********************************
324
325//***** Register the bif interface signals *********************
326// To reduce gate count -> take register away
327// If there is a timing problem then register them again here.
328//**************************************************************
329
330
331 FD1 core_reset_FD1 (.D(pio_core_reset),.CP(clk),.Q(reset));
332 FD1 rd_wr_FD1 (.D(pio_rd), .CP(clk),.Q(rd_wr));
333 FD1 core_sel_FD1 (.D(sel_esr), .CP(clk),.Q(core_sel));
334
335 RegDff #(9) reg_offset_RegDff(.din(pio_addr[8:0]),
336 .clk(clk),
337 .qout(reg_offset[8:0]));
338
339 RegDff #(32) wr_data_RegDff (.din(pio_wdata[31:0]),
340 .clk(clk),
341 .qout(wr_data[31:0]));
342
343 PlsGen2 core_sel_PlsGen2(.sig_in(core_sel),.clk(clk),
344 .lead(core_sel_lead),
345 .trail(core_sel_trail));
346
347 assign rd_en = core_sel & rd_wr;
348 wire rac_ok = core_sel_lead & rd_wr;
349 assign wr_en = core_sel_lead & (~rd_wr);
350
351 RegDff #(32) pio_rd_data_RegDff (.din(rd_data),.clk(clk),
352 .qout(rdata_esr[31:0]));
353
354 FD1 pio_ack_FD1 (.D(core_sel_lead),.CP(clk),.Q(ack_esr));
355 FD1 rac_pls_FD1 (.D(rac_ok),.CP(clk),.Q(rac_pls));
356 assign addr_err = non_qualified_addr_err & core_sel_lead;
357 FD1 pio_err_FD1 (.D(addr_err),.CP(clk),.Q(pio_err_esr));
358
359
360/* ----------- Read and Write Address Decoder -------------------------- */
361always @ (/*AUTOSENSE*/configa or debug_sel or lock_0 or lock_1
362 or los0_0 or los0_1 or los1_0 or los1_1 or los2_0 or los2_1
363 or los3_0 or los3_1 or reg_offset or serdes_rdy0_0
364 or serdes_rdy0_1 or serdes_reset or signal_detect0_0
365 or signal_detect0_1 or wr_en or xserdes_rdy_0
366 or xserdes_rdy_1 or xsignal_detect_0 or xsignal_detect_1)
367 begin
368 ld_serdes_reset = 0;
369 ld_configa = 0; // serdes_0
370 ld_debug_sel = 0;
371 non_qualified_addr_err= 0;
372 case (reg_offset[8:0]) // synopsys parallel_case full_case infer_mux
373 9'h0_00:begin
374 ld_serdes_reset = wr_en;
375 rd_data = {30'b0,serdes_reset[1:0]};
376 end
377 9'h0_01:begin
378 ld_configa = wr_en;
379 rd_data = {30'b0,configa};
380 end
381 9'h1_00:begin
382 rd_data = {lock_0,lock_1,
383 serdes_rdy0_0,signal_detect0_0,
384 serdes_rdy0_1,signal_detect0_1,
385 xserdes_rdy_0,xsignal_detect_0[3:0],
386 xserdes_rdy_1,xsignal_detect_1[3:0],
387 8'b0,
388 los3_1,los2_1,los1_1,los0_1,
389 los3_0,los2_0,los1_0,los0_0};
390 end
391
392 9'h1_01:begin
393 ld_debug_sel = wr_en;
394 rd_data = debug_sel;
395 end
396
397 default:begin
398 rd_data = 32'hdead_beef;
399 non_qualified_addr_err= 1;
400 end
401 endcase // case(reg_offset[8:0])
402 end
403
404/* -------------------- serdes -------------------- */
405xREG2 #(6) debug_sel_xREG2 (.clk(clk),
406 .reset(reset),
407 .reset_value(6'b0),
408 .load(ld_debug_sel),
409 .din(wr_data[5:0]), // Bits[2:0] are ignored.
410 .qout(debug_sel[5:0]));
411
412 assign debug_sel[31:6] = 0;
413
414 reg [31:0] esrctl_debug;
415
416 always @ (/*AUTOSENSE*/debug_sel or esr_mac_rxd0_0
417 or esr_mac_rxd0_1 or esr_mac_rxd1_0 or esr_mac_rxd1_1
418 or esr_mac_rxd2_0 or esr_mac_rxd2_1 or esr_mac_rxd3_0
419 or esr_mac_rxd3_1 or mac_esr_txd0_0 or mac_esr_txd0_1
420 or mac_esr_txd1_0 or mac_esr_txd1_1 or mac_esr_txd2_0
421 or mac_esr_txd2_1 or mac_esr_txd3_0 or mac_esr_txd3_1
422 or rx_code_group0 or rx_code_group1 or tx_code_group0
423 or tx_code_group1 or xrx_code_group0 or xrx_code_group1
424 or xtx_code_group0 or xtx_code_group1)
425 begin
426 case (debug_sel[3:0]) // synopsys parallel_case full_case
427 4'h0 : esrctl_debug = xtx_code_group0[31:0];
428 4'h1 : esrctl_debug = {4'b0,mac_esr_txd0_0[9:0],tx_code_group0[9:0],xtx_code_group0[39:32]};
429 4'h2 : esrctl_debug = {2'b0,mac_esr_txd3_0[9:0],mac_esr_txd2_0[9:0],mac_esr_txd1_0[9:0]};
430 4'h3 : esrctl_debug = xrx_code_group0[31:0];
431 4'h4 : esrctl_debug = {4'b0,esr_mac_rxd0_0[9:0],rx_code_group0[9:0],xrx_code_group0[39:32]};
432 4'h5 : esrctl_debug = {2'b0,esr_mac_rxd3_0[9:0],esr_mac_rxd2_0[9:0],esr_mac_rxd1_0[9:0]};
433
434 4'h6 : esrctl_debug = xtx_code_group1[31:0];
435 4'h7 : esrctl_debug = {4'b0,mac_esr_txd0_1[9:0],tx_code_group1[9:0],xtx_code_group1[39:32]};
436 4'h8 : esrctl_debug = {2'b0,mac_esr_txd3_1[9:0],mac_esr_txd2_1[9:0],mac_esr_txd1_1[9:0]};
437 4'h9 : esrctl_debug = xrx_code_group1[31:0];
438 4'ha : esrctl_debug = {4'b0,esr_mac_rxd0_1[9:0],rx_code_group1[9:0],xrx_code_group1[39:32]};
439 4'hb : esrctl_debug = {2'b0,esr_mac_rxd3_1[9:0],esr_mac_rxd2_1[9:0],esr_mac_rxd1_1[9:0]};
440 default: esrctl_debug = xtx_code_group0[31:0];
441 endcase
442 end // always @ (...
443
444/***************************************************************
445 * register instantiation secton
446 ***************************************************************/
447 /* ------------------------- serdes_reset ------------------------------- */
448 xREG #(2) serdes_reset_xREG(.clk(clk),.reset(reset),.en(ld_serdes_reset),.din(wr_data[1:0]),.qout(serdes_reset[1:0]));
449 wire serdes_reset_0 = serdes_reset[0];
450 wire serdes_reset_1 = serdes_reset[1];
451
452 /* ------------------------------------------------------------------------- */
453
454 /* ------------------------- configa ------------------------------ */
455 // For some reason synopsys does not like "config" as signal name.
456 xREG #(2) configa_xREG(.clk(clk),.reset(reset),.en(ld_configa),.din(wr_data[1:0]),.qout(configa[1:0]));
457 assign force_serdes_rdy = configa[0];
458 assign blunt_end_loopback = configa[1];
459
460 /* ------------------------------------------------------------------------- */
461
462
463endmodule // esr_ctl2
464