Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / mcu / rtl / mcu_ibrx_ctl.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: mcu_ibrx_ctl.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`define DRIF_MCU_STATE_00 5'd0
36`define DRIF_MCU_STATE_01 5'd1
37`define DRIF_MCU_STATE_02 5'd2
38`define DRIF_MCU_STATE_03 5'd3
39`define DRIF_MCU_STATE_04 5'd4
40`define DRIF_MCU_STATE_05 5'd5
41`define DRIF_MCU_STATE_06 5'd6
42`define DRIF_MCU_STATE_07 5'd7
43`define DRIF_MCU_STATE_08 5'd8
44`define DRIF_MCU_STATE_09 5'd9
45`define DRIF_MCU_STATE_10 5'd10
46`define DRIF_MCU_STATE_11 5'd11
47`define DRIF_MCU_STATE_12 5'd12
48`define DRIF_MCU_STATE_13 5'd13
49`define DRIF_MCU_STATE_14 5'd14
50`define DRIF_MCU_STATE_15 5'd15
51`define DRIF_MCU_STATE_16 5'd16
52`define DRIF_MCU_STATE_17 5'd17
53`define DRIF_MCU_STATE_18 5'd18
54`define DRIF_MCU_STATE_19 5'd19
55`define DRIF_MCU_STATE_20 5'd20
56`define DRIF_MCU_STATE_21 5'd21
57`define DRIF_MCU_STATE_22 5'd22
58`define DRIF_MCU_STATE_23 5'd23
59`define DRIF_MCU_STATE_24 5'd24
60`define DRIF_MCU_STATE_25 5'd25
61`define DRIF_MCU_STATE_26 5'd26
62
63`define DRIF_MCU_STATE_MAX 4
64`define DRIF_MCU_STATE_WIDTH 5
65
66//
67// UCB Packet Type
68// ===============
69//
70`define UCB_READ_NACK 4'b0000 // ack/nack types
71`define UCB_READ_ACK 4'b0001
72`define UCB_WRITE_ACK 4'b0010
73`define UCB_IFILL_ACK 4'b0011
74`define UCB_IFILL_NACK 4'b0111
75
76`define UCB_READ_REQ 4'b0100 // req types
77`define UCB_WRITE_REQ 4'b0101
78`define UCB_IFILL_REQ 4'b0110
79
80`define UCB_INT 4'b1000 // plain interrupt
81`define UCB_INT_VEC 4'b1100 // interrupt with vector
82`define UCB_RESET_VEC 4'b1101 // reset with vector
83`define UCB_IDLE_VEC 4'b1110 // idle with vector
84`define UCB_RESUME_VEC 4'b1111 // resume with vector
85
86
87//
88// UCB Data Packet Format
89// ======================
90//
91`define UCB_NOPAY_PKT_WIDTH 64 // packet without payload
92`define UCB_64PAY_PKT_WIDTH 128 // packet with 64 bit payload
93`define UCB_128PAY_PKT_WIDTH 192 // packet with 128 bit payload
94
95`define UCB_DATA_EXT_HI 191 // (64) extended data
96`define UCB_DATA_EXT_LO 128
97`define UCB_DATA_HI 127 // (64) data
98`define UCB_DATA_LO 64
99`define UCB_RSV_HI 63 // (9) reserved bits
100`define UCB_RSV_LO 55
101`define UCB_ADDR_HI 54 // (40) bit address
102`define UCB_ADDR_LO 15
103`define UCB_SIZE_HI 14 // (3) request size
104`define UCB_SIZE_LO 12
105`define UCB_BUF_HI 11 // (2) buffer ID
106`define UCB_BUF_LO 10
107`define UCB_THR_HI 9 // (6) cpu/thread ID
108`define UCB_THR_LO 4
109`define UCB_PKT_HI 3 // (4) packet type
110`define UCB_PKT_LO 0
111
112`define UCB_DATA_EXT_WIDTH 64
113`define UCB_DATA_WIDTH 64
114`define UCB_RSV_WIDTH 9
115`define UCB_ADDR_WIDTH 40
116`define UCB_SIZE_WIDTH 3
117`define UCB_BUF_WIDTH 2
118`define UCB_THR_WIDTH 6
119`define UCB_PKT_WIDTH 4
120
121// Size encoding for the UCB_SIZE_HI/LO field
122// 000 - byte
123// 001 - half-word
124// 010 - word
125// 011 - double-word
126`define UCB_SIZE_1B 3'b000
127`define UCB_SIZE_2B 3'b001
128`define UCB_SIZE_4B 3'b010
129`define UCB_SIZE_8B 3'b011
130`define UCB_SIZE_16B 3'b100
131
132
133//
134// UCB Interrupt Packet Format
135// ===========================
136//
137`define UCB_INT_PKT_WIDTH 64
138
139`define UCB_INT_RSV_HI 63 // (7) reserved bits
140`define UCB_INT_RSV_LO 57
141`define UCB_INT_VEC_HI 56 // (6) interrupt vector
142`define UCB_INT_VEC_LO 51
143`define UCB_INT_STAT_HI 50 // (32) interrupt status
144`define UCB_INT_STAT_LO 19
145`define UCB_INT_DEV_HI 18 // (9) device ID
146`define UCB_INT_DEV_LO 10
147//`define UCB_THR_HI 9 // (6) cpu/thread ID shared with
148//`define UCB_THR_LO 4 data packet format
149//`define UCB_PKT_HI 3 // (4) packet type shared with
150//`define UCB_PKT_LO 0 // data packet format
151
152`define UCB_INT_RSV_WIDTH 7
153`define UCB_INT_VEC_WIDTH 6
154`define UCB_INT_STAT_WIDTH 32
155`define UCB_INT_DEV_WIDTH 9
156
157
158`define MCU_CAS_BIT2_SEL_PA10 4'h1
159`define MCU_CAS_BIT2_SEL_PA32 4'h2
160`define MCU_CAS_BIT2_SEL_PA33 4'h4
161`define MCU_CAS_BIT2_SEL_PA34 4'h8
162
163`define MCU_CAS_BIT3_SEL_PA11 4'h1
164`define MCU_CAS_BIT3_SEL_PA33 4'h2
165`define MCU_CAS_BIT3_SEL_PA34 4'h4
166`define MCU_CAS_BIT3_SEL_PA35 4'h8
167
168`define MCU_CAS_BIT4_SEL_PA12 3'h1
169`define MCU_CAS_BIT4_SEL_PA35 3'h2
170`define MCU_CAS_BIT4_SEL_PA36 3'h4
171
172`define MCU_DIMMHI_SEL_ZERO 6'h01
173`define MCU_DIMMHI_SEL_PA32 6'h02
174`define MCU_DIMMHI_SEL_PA33 6'h04
175`define MCU_DIMMHI_SEL_PA34 6'h08
176`define MCU_DIMMHI_SEL_PA35 6'h10
177`define MCU_DIMMHI_SEL_PA36 6'h20
178
179`define MCU_DIMMLO_SEL_ZERO 4'h1
180`define MCU_DIMMLO_SEL_PA10 4'h2
181`define MCU_DIMMLO_SEL_PA11 4'h4
182`define MCU_DIMMLO_SEL_PA12 4'h8
183
184`define MCU_RANK_SEL_ZERO 7'h01
185`define MCU_RANK_SEL_PA32 7'h02
186`define MCU_RANK_SEL_PA33 7'h04
187`define MCU_RANK_SEL_PA34 7'h08
188`define MCU_RANK_SEL_PA35 7'h10
189`define MCU_RANK_SEL_PA10 7'h20
190`define MCU_RANK_SEL_PA11 7'h40
191
192`define MCU_ADDR_ERR_SEL_39_32 6'h01
193`define MCU_ADDR_ERR_SEL_39_33 6'h02
194`define MCU_ADDR_ERR_SEL_39_34 6'h04
195`define MCU_ADDR_ERR_SEL_39_35 6'h08
196`define MCU_ADDR_ERR_SEL_39_36 6'h10
197`define MCU_ADDR_ERR_SEL_39_37 6'h20
198
199`define DRIF_ERR_IDLE 0
200`define DRIF_ERR_IDLE_ST 5'h1
201`define DRIF_ERR_READ0 1
202`define DRIF_ERR_READ0_ST 5'h2
203`define DRIF_ERR_WRITE 2
204`define DRIF_ERR_WRITE_ST 5'h4
205`define DRIF_ERR_READ1 3
206`define DRIF_ERR_READ1_ST 5'h8
207`define DRIF_ERR_CRC_FR 4
208`define DRIF_ERR_CRC_FR_ST 5'h10
209
210`define MCU_WDQ_RF_DATA_WIDTH 72
211`define MCU_WDQ_RF_ADDR_WIDTH 5
212`define MCU_WDQ_RF_DEPTH 32
213
214// FBDIMM header defines
215`define FBD_TS0_HDR 12'hbfe
216`define FBD_TS1_HDR 12'hffe
217`define FBD_TS2_HDR 12'h7fe
218`define FBD_TS3_HDR 12'h3fe
219
220// MCU FBDIMM Channel commands
221`define FBD_DRAM_CMD_NOP 3'h0
222`define FBD_DRAM_CMD_OTHER 3'h1
223`define FBD_DRAM_CMD_RD 3'h2
224`define FBD_DRAM_CMD_WR 3'h3
225`define FBD_DRAM_CMD_ACT 3'h4
226`define FBD_DRAM_CMD_WDATA 3'h5
227
228`define FBD_DRAM_CMD_OTHER_REF 3'h5
229`define FBD_DRAM_CMD_OTHER_SRE 3'h4
230`define FBD_DRAM_CMD_OTHER_PDE 3'h2
231`define FBD_DRAM_CMD_OTHER_SRPDX 3'h3
232
233`define FBD_CHNL_CMD_NOP 2'h0
234`define FBD_CHNL_CMD_SYNC 2'h1
235`define FBD_CHNL_CMD_SCRST 2'h2
236
237`define FBDIC_ERR_IDLE_ST 7'h01
238`define FBDIC_ERR_IDLE 0
239
240`define FBDIC_ERR_STS_ST 7'h02
241`define FBDIC_ERR_STS 1
242
243`define FBDIC_ERR_SCRST_ST 7'h04
244`define FBDIC_ERR_SCRST 2
245
246`define FBDIC_ERR_SCRST_STS_ST 7'h08
247`define FBDIC_ERR_SCRST_STS 3
248
249`define FBDIC_ERR_STS2_ST 7'h10
250`define FBDIC_ERR_STS2 4
251
252`define FBDIC_ERR_FASTRST_ST 7'h20
253`define FBDIC_ERR_FASTRST 5
254
255`define FBDIC_ERR_FASTRST_STS_ST 7'h40
256`define FBDIC_ERR_FASTRST_STS 6
257
258
259// IBIST DEFINITION
260
261`define L_2_0 12'h555
262`define L_2_1 12'h555
263`define L_4_0 12'h333
264`define L_4_1 12'h333
265`define L_6_0 12'h1c7
266`define L_6_1 12'h1c7
267`define L_8_0 12'h0f0
268`define L_8_1 12'hf0f
269`define L_24_0 12'h000
270`define L_24_1 12'hfff
271
272`define idle 4'h0
273
274`define error_0 4'h1
275`define error_1 4'h2
276
277`define start1_0 4'h3
278`define start1_1 4'h4
279`define start2_0 4'h5
280`define start2_1 4'h6
281
282`define pat1_0 4'h7
283`define pat1_1 4'h8
284
285`define clkpat_0 4'h9
286`define clkpat_1 4'ha
287
288`define const_0 4'hb
289`define const_1 4'hc
290
291`define stop1_0 4'h1
292`define stop1_1 4'h2
293
294`define stop2_0 4'hd
295`define stop2_1 4'he
296`define error 4'hf
297
298`define IBTX_STATE_IDLE 0
299`define IBTX_STATE_PATT 1
300`define IBTX_STATE_MODN 2
301`define IBTX_STATE_CONST 3
302
303`define IBRX_STATE_IDLE 0
304`define IBRX_STATE_PATT 1
305`define IBRX_STATE_MODN 2
306`define IBRX_STATE_CONST 3
307
308
309
310module mcu_ibrx_ctl (
311 ibrx_done,
312 ibrx_rxerrstat,
313 ibrx_errcnt,
314 ibrx_errlnnum,
315 ibrx_errstat,
316 fbdic_nbfibportctl,
317 fbdic_nbfibpgctl,
318 fbdic_nbfibpattbuf1,
319 fbdic_nbfibrxmsk,
320 fbdic_nbfibrxshft,
321 fbdic_nbfibrxlnerr,
322 fbdic_nbfibpattbuf2,
323 fbdic_nbfibpatt2en,
324 fbdic_rxstart,
325 fbdic_ibrx_start_ld,
326 fbdic_nbfibportctl_en,
327 fbdic_errcnt_clr,
328 fbdic_errstat_clr,
329 ibist_rxdata,
330 scan_in,
331 tcu_aclk,
332 tcu_bclk,
333 tcu_scan_en,
334 l1clk,
335 scan_out);
336wire siclk;
337wire soclk;
338wire se;
339wire ibrx_autoinvswpen;
340wire ibrx_stoponerr;
341wire ibrx_loopcon;
342wire ibrx_ovrloop_disable;
343wire ibrx_ovrloopcnt_is_zero;
344wire [5:0] ibrx_ovrloopcnt;
345wire ibrx_ovrloopcnt_dec;
346wire [4:0] ibrx_cnstgencnt;
347wire [6:0] ibrx_modloopcnt;
348wire [6:0] ibrx_pattloopcnt;
349wire [5:0] ibrx_ovrloopcnt_in;
350wire [3:0] ibrx_state;
351wire ff_ovrloopcnt_scanin;
352wire ff_ovrloopcnt_scanout;
353wire ibrx_cnstgen_disable;
354wire ibrx_cnstgencnt_dec;
355wire ibrx_lo_bits_sel;
356wire [4:0] ibrx_cnstgencnt_in;
357wire ff_cnstgencnt_scanin;
358wire ff_cnstgencnt_scanout;
359wire ibrx_cnstgenset;
360wire ibrx_modloop_disable;
361wire ibrx_modloopcnt_dec;
362wire [6:0] ibrx_modloopcnt_in;
363wire ff_modloopcnt_scanin;
364wire ff_modloopcnt_scanout;
365wire [2:0] ibrx_modperiod;
366wire ibrx_pattloop_disable;
367wire ibrx_pattloopcnt_dec;
368wire [6:0] ibrx_pattloopcnt_in;
369wire ff_pattloopcnt_scanin;
370wire ff_pattloopcnt_scanout;
371wire [2:0] ibrx_ptgenord;
372wire ibrx_ptgenord_pmc;
373wire ibrx_ptgenord_pcm;
374wire ibrx_ptgenord_mpc;
375wire ibrx_ptgenord_mcp;
376wire ibrx_ptgenord_cpm;
377wire ibrx_ptgenord_cmp;
378wire ibrx_idle_to_patt;
379wire ibrx_idle_to_modn;
380wire ibrx_idle_to_const;
381wire ibrx_idle_to_idle;
382wire ibrx_patt_to_patt;
383wire ibrx_patt_to_modn;
384wire ibrx_patt_to_const;
385wire ibrx_patt_to_idle;
386wire ibrx_modn_to_patt;
387wire ibrx_modn_to_modn;
388wire ibrx_modn_to_const;
389wire ibrx_modn_to_idle;
390wire ibrx_const_to_patt;
391wire ibrx_const_to_modn;
392wire ibrx_const_to_const;
393wire ibrx_const_to_idle;
394wire [13:0] ibrx_rxinvshft_in;
395wire [13:0] ibrx_rxinvshft;
396wire ff_rxinvshft_scanin;
397wire ff_rxinvshft_scanout;
398wire ibrx_lo_bits_sel_in;
399wire ff_hiword_sel_scanin;
400wire ff_hiword_sel_scanout;
401wire ff_state_scanin;
402wire ff_state_scanout;
403wire [3:0] ibrx_state_in;
404wire [3:0] ibrx_state_out;
405wire [11:0] ibrx_modn_data;
406wire [11:0] ibrx_patt1_data;
407wire [11:0] ibrx_data;
408wire [11:0] ibrx_data_l;
409wire [11:0] ibrx_patt2_data;
410wire [167:0] ibrx_rxdata;
411wire ibrx_ibist_mode_in;
412wire ibrx_ibist_mode;
413wire ff_ibist_mode_scanin;
414wire ff_ibist_mode_scanout;
415wire [13:0] ibrx_rxerrstat_in;
416wire ff_rxerrstat_scanin;
417wire ff_rxerrstat_scanout;
418wire [9:0] ibrx_errcnt_in;
419wire ff_errcnt_scanin;
420wire ff_errcnt_scanout;
421wire [3:0] ibrx_first_err_lane;
422wire [3:0] ibrx_errlnnum_in;
423wire ff_errlnnum_scanin;
424wire ff_errlnnum_scanout;
425wire [1:0] ibrx_errstat_in;
426wire ff_errstat_scanin;
427wire ff_errstat_scanout;
428
429
430output ibrx_done;
431output [13:0] ibrx_rxerrstat;
432output [9:0] ibrx_errcnt;
433output [3:0] ibrx_errlnnum;
434output [1:0] ibrx_errstat;
435
436input [23:0] fbdic_nbfibportctl;
437input [31:0] fbdic_nbfibpgctl;
438input [23:0] fbdic_nbfibpattbuf1;
439input [13:0] fbdic_nbfibrxmsk;
440input [13:0] fbdic_nbfibrxshft;
441input [13:0] fbdic_nbfibrxlnerr;
442input [23:0] fbdic_nbfibpattbuf2;
443input [13:0] fbdic_nbfibpatt2en;
444input fbdic_rxstart;
445
446input fbdic_ibrx_start_ld;
447input fbdic_nbfibportctl_en;
448input [9:0] fbdic_errcnt_clr;
449input [1:0] fbdic_errstat_clr;
450
451input [167:0] ibist_rxdata;
452
453input scan_in ;
454input tcu_aclk ;
455input tcu_bclk ;
456input tcu_scan_en ;
457
458input l1clk ;
459
460output scan_out ;
461
462assign siclk = tcu_aclk;
463assign soclk = tcu_bclk;
464assign se = tcu_scan_en;
465
466wire [13:0] ibrx_lane_error;
467
468// Port control register signals
469assign ibrx_autoinvswpen = fbdic_nbfibportctl[5];
470assign ibrx_stoponerr = fbdic_nbfibportctl[4];
471assign ibrx_loopcon = fbdic_nbfibportctl[3];
472
473// Pattern generation counters
474assign ibrx_ovrloop_disable = fbdic_nbfibpgctl[31:26] == 6'h0;
475assign ibrx_ovrloopcnt_is_zero = ibrx_ovrloopcnt[5:0] == 6'h0 & ~ibrx_loopcon;
476assign ibrx_ovrloopcnt_dec = ibrx_cnstgencnt[4:0] == 5'h0 & ibrx_modloopcnt[6:0] == 7'h0 &
477 ibrx_pattloopcnt[6:0] == 7'h0 & (ibrx_ovrloopcnt[5:0] != 6'h0 | ibrx_loopcon);
478assign ibrx_ovrloopcnt_in[5:0] = fbdic_rxstart | ibrx_cnstgencnt[4:0] == 5'h0 &
479 ibrx_modloopcnt[6:0] == 7'h0 &
480 ibrx_pattloopcnt[6:0] == 7'h0 &
481 ibrx_ovrloopcnt[5:0] == 6'h0 & ~ibrx_state[`IBRX_STATE_IDLE] &
482 ibrx_loopcon ? fbdic_nbfibpgctl[31:26] - 6'h1 :
483 ibrx_ovrloopcnt_dec ? ibrx_ovrloopcnt[5:0] - 6'h1 : ibrx_ovrloopcnt[5:0];
484mcu_ibrx_ctl_msff_ctl_macro__width_6 ff_ovrloopcnt (
485 .scan_in(ff_ovrloopcnt_scanin),
486 .scan_out(ff_ovrloopcnt_scanout),
487 .din(ibrx_ovrloopcnt_in[5:0]),
488 .dout(ibrx_ovrloopcnt[5:0]),
489 .l1clk(l1clk),
490 .siclk(siclk),
491 .soclk(soclk));
492
493// Constant generation
494assign ibrx_cnstgen_disable = fbdic_nbfibpgctl[25:21] == 5'h0;
495assign ibrx_cnstgencnt_dec = ibrx_state[`IBRX_STATE_CONST] & ibrx_lo_bits_sel;
496assign ibrx_cnstgencnt_in[4:0] = fbdic_rxstart | ibrx_ovrloopcnt_dec ? fbdic_nbfibpgctl[25:21] :
497 ibrx_cnstgencnt_dec ? ibrx_cnstgencnt[4:0] - 5'h1 : ibrx_cnstgencnt[4:0];
498mcu_ibrx_ctl_msff_ctl_macro__width_5 ff_cnstgencnt (
499 .scan_in(ff_cnstgencnt_scanin),
500 .scan_out(ff_cnstgencnt_scanout),
501 .din(ibrx_cnstgencnt_in[4:0]),
502 .dout(ibrx_cnstgencnt[4:0]),
503 .l1clk(l1clk),
504 .siclk(siclk),
505 .soclk(soclk));
506
507assign ibrx_cnstgenset = fbdic_nbfibpgctl[20];
508
509// Mod-N pattern
510assign ibrx_modloop_disable = fbdic_nbfibpgctl[19:13] == 7'h0;
511assign ibrx_modloopcnt_dec = ibrx_state[`IBRX_STATE_MODN] & ibrx_lo_bits_sel;
512assign ibrx_modloopcnt_in[6:0] = fbdic_rxstart | ibrx_ovrloopcnt_dec ? fbdic_nbfibpgctl[19:13] :
513 ibrx_modloopcnt_dec ? ibrx_modloopcnt[6:0] - 7'h1 : ibrx_modloopcnt[6:0];
514mcu_ibrx_ctl_msff_ctl_macro__width_7 ff_modloopcnt (
515 .scan_in(ff_modloopcnt_scanin),
516 .scan_out(ff_modloopcnt_scanout),
517 .din(ibrx_modloopcnt_in[6:0]),
518 .dout(ibrx_modloopcnt[6:0]),
519 .l1clk(l1clk),
520 .siclk(siclk),
521 .soclk(soclk));
522
523assign ibrx_modperiod[2:0] = fbdic_nbfibpgctl[12:10];
524
525// Pattern Register 1
526assign ibrx_pattloop_disable = fbdic_nbfibpgctl[9:3] == 7'h0;
527assign ibrx_pattloopcnt_dec = ibrx_state[`IBRX_STATE_PATT] & ibrx_lo_bits_sel;
528assign ibrx_pattloopcnt_in[6:0] = fbdic_rxstart | ibrx_ovrloopcnt_dec ? fbdic_nbfibpgctl[9:3] :
529 ibrx_pattloopcnt_dec ? ibrx_pattloopcnt[6:0] - 7'h1 : ibrx_pattloopcnt[6:0];
530mcu_ibrx_ctl_msff_ctl_macro__width_7 ff_pattloopcnt (
531 .scan_in(ff_pattloopcnt_scanin),
532 .scan_out(ff_pattloopcnt_scanout),
533 .din(ibrx_pattloopcnt_in[6:0]),
534 .dout(ibrx_pattloopcnt[6:0]),
535 .l1clk(l1clk),
536 .siclk(siclk),
537 .soclk(soclk));
538
539//
540assign ibrx_ptgenord[2:0] = fbdic_nbfibpgctl[2:0];
541assign ibrx_ptgenord_pmc = ibrx_ptgenord[2:0] == 3'h0;
542assign ibrx_ptgenord_pcm = ibrx_ptgenord[2:0] == 3'h1;
543assign ibrx_ptgenord_mpc = ibrx_ptgenord[2:0] == 3'h2;
544assign ibrx_ptgenord_mcp = ibrx_ptgenord[2:0] == 3'h3;
545assign ibrx_ptgenord_cpm = ibrx_ptgenord[2:0] == 3'h4;
546assign ibrx_ptgenord_cmp = ibrx_ptgenord[2:0] == 3'h5;
547
548// State machine arcs
549// Idle/Start state
550assign ibrx_idle_to_patt = ~ibrx_pattloop_disable &
551 (ibrx_ptgenord_pmc | ibrx_ptgenord_pcm |
552 ibrx_ptgenord_mpc & ibrx_modloop_disable |
553 ibrx_ptgenord_mcp & ibrx_cnstgen_disable & ibrx_modloop_disable |
554 ibrx_ptgenord_cpm & ibrx_cnstgen_disable |
555 ibrx_ptgenord_cmp & ibrx_cnstgen_disable & ibrx_modloop_disable);
556assign ibrx_idle_to_modn = ~ibrx_modloop_disable &
557 (ibrx_ptgenord_mpc | ibrx_ptgenord_mcp |
558 ibrx_ptgenord_pmc & ibrx_pattloop_disable |
559 ibrx_ptgenord_pcm & ibrx_pattloop_disable & ibrx_cnstgen_disable |
560 ibrx_ptgenord_cpm & ibrx_pattloop_disable & ibrx_cnstgen_disable |
561 ibrx_ptgenord_cmp & ibrx_cnstgen_disable);
562assign ibrx_idle_to_const = ~ibrx_cnstgen_disable &
563 (ibrx_ptgenord_cpm | ibrx_ptgenord_cmp |
564 ibrx_ptgenord_pmc & ibrx_pattloop_disable & ibrx_modloop_disable |
565 ibrx_ptgenord_pcm & ibrx_pattloop_disable |
566 ibrx_ptgenord_mpc & ibrx_modloop_disable & ibrx_pattloop_disable |
567 ibrx_ptgenord_mcp & ibrx_modloop_disable);
568assign ibrx_idle_to_idle = ibrx_pattloop_disable & ibrx_modloop_disable & ibrx_cnstgen_disable | ibrx_ovrloop_disable;
569
570// Pattern state
571assign ibrx_patt_to_patt = ibrx_modloop_disable & ibrx_cnstgen_disable & ~ibrx_ovrloopcnt_is_zero;
572assign ibrx_patt_to_modn = ~ibrx_modloop_disable &
573 (ibrx_ptgenord_pmc | ibrx_ptgenord_cpm |
574 ibrx_ptgenord_pcm & ibrx_cnstgen_disable |
575 ibrx_ptgenord_mpc & ibrx_cnstgen_disable & ~ibrx_ovrloopcnt_is_zero |
576 ibrx_ptgenord_mcp & ~ibrx_ovrloopcnt_is_zero |
577 ibrx_ptgenord_cmp & ibrx_cnstgen_disable & ~ibrx_ovrloopcnt_is_zero);
578assign ibrx_patt_to_const = ~ibrx_cnstgen_disable &
579 (ibrx_ptgenord_pmc & ibrx_modloop_disable |
580 ibrx_ptgenord_cpm & ibrx_modloop_disable & ~ibrx_ovrloopcnt_is_zero |
581 ibrx_ptgenord_pcm |
582 ibrx_ptgenord_mpc |
583 ibrx_ptgenord_mcp & ibrx_modloop_disable & ~ibrx_ovrloopcnt_is_zero |
584 ibrx_ptgenord_cmp & ~ibrx_ovrloopcnt_is_zero);
585assign ibrx_patt_to_idle = ibrx_ovrloopcnt_is_zero &
586 (ibrx_ptgenord_pmc & ibrx_cnstgen_disable & ibrx_modloop_disable |
587 ibrx_ptgenord_cpm & ibrx_modloop_disable |
588 ibrx_ptgenord_pcm & ibrx_cnstgen_disable & ibrx_modloop_disable |
589 ibrx_ptgenord_mpc & ibrx_cnstgen_disable |
590 ibrx_ptgenord_mcp |
591 ibrx_ptgenord_cmp);
592
593// MOD-N state
594assign ibrx_modn_to_patt = ~ibrx_pattloop_disable &
595 (ibrx_ptgenord_pmc & ibrx_cnstgen_disable & ~ibrx_ovrloopcnt_is_zero |
596 ibrx_ptgenord_cpm & ibrx_cnstgen_disable & ~ibrx_ovrloopcnt_is_zero |
597 ibrx_ptgenord_pcm & ~ibrx_ovrloopcnt_is_zero |
598 ibrx_ptgenord_mpc |
599 ibrx_ptgenord_mcp & ibrx_cnstgen_disable |
600 ibrx_ptgenord_cmp);
601assign ibrx_modn_to_modn = ~ibrx_modloop_disable & ibrx_cnstgen_disable & ibrx_pattloop_disable;
602assign ibrx_modn_to_const = ~ibrx_cnstgen_disable &
603 (ibrx_ptgenord_pmc |
604 ibrx_ptgenord_mcp |
605 ibrx_ptgenord_cpm & ~ibrx_ovrloopcnt_is_zero |
606 ibrx_ptgenord_pcm & ~ibrx_ovrloopcnt_is_zero & ibrx_pattloop_disable |
607 ibrx_ptgenord_mpc & ibrx_pattloop_disable|
608 ibrx_ptgenord_cmp & ~ibrx_ovrloopcnt_is_zero & ibrx_pattloop_disable);
609assign ibrx_modn_to_idle = ibrx_ovrloopcnt_is_zero &
610 (ibrx_ptgenord_pmc & ibrx_cnstgen_disable |
611 ibrx_ptgenord_cpm |
612 ibrx_ptgenord_pcm |
613 ibrx_ptgenord_mpc & ibrx_cnstgen_disable & ibrx_pattloop_disable |
614 ibrx_ptgenord_mcp & ibrx_cnstgen_disable & ibrx_pattloop_disable |
615 ibrx_ptgenord_cmp & ibrx_pattloop_disable);
616
617// Constant state
618assign ibrx_const_to_patt = ~ibrx_pattloop_disable &
619 (ibrx_ptgenord_pmc & ~ibrx_ovrloopcnt_is_zero |
620 ibrx_ptgenord_cpm |
621 ibrx_ptgenord_pcm & ~ibrx_ovrloopcnt_is_zero & ibrx_modloop_disable |
622 ibrx_ptgenord_mpc & ~ibrx_ovrloopcnt_is_zero & ibrx_modloop_disable |
623 ibrx_ptgenord_mcp |
624 ibrx_ptgenord_cmp & ibrx_modloop_disable);
625assign ibrx_const_to_modn = ~ibrx_modloop_disable &
626 (ibrx_ptgenord_pmc & ~ibrx_ovrloopcnt_is_zero & ibrx_pattloop_disable |
627 ibrx_ptgenord_cpm & ibrx_pattloop_disable |
628 ibrx_ptgenord_pcm |
629 ibrx_ptgenord_mpc & ~ibrx_ovrloopcnt_is_zero |
630 ibrx_ptgenord_mcp & ~ibrx_ovrloopcnt_is_zero & ibrx_pattloop_disable |
631 ibrx_ptgenord_cmp);
632assign ibrx_const_to_const = ~ibrx_ovrloopcnt_is_zero & ibrx_modloop_disable & ibrx_pattloop_disable;
633assign ibrx_const_to_idle = ibrx_ovrloopcnt_is_zero &
634 (ibrx_ptgenord_pmc |
635 ibrx_ptgenord_cpm & ibrx_modloop_disable & ibrx_pattloop_disable |
636 ibrx_ptgenord_pcm & ibrx_modloop_disable |
637 ibrx_ptgenord_mpc |
638 ibrx_ptgenord_mcp & ibrx_pattloop_disable |
639 ibrx_ptgenord_cmp & ibrx_modloop_disable & ibrx_pattloop_disable);
640
641// inversion shift register
642assign ibrx_rxinvshft_in[13:0] = fbdic_rxstart ? fbdic_nbfibrxshft[13:0] :
643 ibrx_ovrloopcnt_dec & ibrx_autoinvswpen ?
644 {ibrx_rxinvshft[12:0],ibrx_rxinvshft[13]} : ibrx_rxinvshft[13:0];
645mcu_ibrx_ctl_msff_ctl_macro__width_14 ff_rxinvshft (
646 .scan_in(ff_rxinvshft_scanin),
647 .scan_out(ff_rxinvshft_scanout),
648 .din(ibrx_rxinvshft_in[13:0]),
649 .dout(ibrx_rxinvshft[13:0]),
650 .l1clk(l1clk),
651 .siclk(siclk),
652 .soclk(soclk));
653
654// Bit to select between high and low 12 bits of pattern data
655assign ibrx_lo_bits_sel_in = ~ibrx_state[`IBRX_STATE_IDLE] & ~ibrx_lo_bits_sel;
656mcu_ibrx_ctl_msff_ctl_macro ff_hiword_sel (
657 .scan_in(ff_hiword_sel_scanin),
658 .scan_out(ff_hiword_sel_scanout),
659 .din(ibrx_lo_bits_sel_in),
660 .dout(ibrx_lo_bits_sel),
661 .l1clk(l1clk),
662 .siclk(siclk),
663 .soclk(soclk));
664
665// state machine
666reg [3:0] ibrx_state_next;
667
668// 0in one_hot -var ibrx_state[3:0]
669mcu_ibrx_ctl_msff_ctl_macro__width_4 ff_state (
670 .scan_in(ff_state_scanin),
671 .scan_out(ff_state_scanout),
672 .din(ibrx_state_in[3:0]),
673 .dout(ibrx_state_out[3:0]),
674 .l1clk(l1clk),
675 .siclk(siclk),
676 .soclk(soclk));
677
678assign ibrx_state_in[3:0] = ibrx_state_next[3:0] ^ 4'h1;
679assign ibrx_state[3:0] = ibrx_state_out[3:0] ^ 4'h1;
680
681always @(ibrx_state or ibrx_idle_to_const or ibrx_idle_to_modn or ibrx_idle_to_patt or ibrx_idle_to_idle
682 or ibrx_patt_to_const or ibrx_patt_to_modn or ibrx_patt_to_patt or ibrx_patt_to_idle
683 or ibrx_const_to_const or ibrx_const_to_modn or ibrx_const_to_patt or ibrx_const_to_idle
684 or ibrx_modn_to_const or ibrx_modn_to_modn or ibrx_modn_to_patt or ibrx_modn_to_idle
685 or ibrx_cnstgencnt or ibrx_modloopcnt or ibrx_pattloopcnt or ibrx_lo_bits_sel or fbdic_rxstart
686 or ibrx_lane_error or ibrx_stoponerr)
687begin
688
689 ibrx_state_next[3:0] = 4'h0;
690
691 case (1'b1)
692 ibrx_state[`IBRX_STATE_IDLE]: begin
693 if (fbdic_rxstart) begin
694 ibrx_state_next[3:0] = {ibrx_idle_to_const, ibrx_idle_to_modn,
695 ibrx_idle_to_patt, ibrx_idle_to_idle};
696 end
697 else begin
698 ibrx_state_next[`IBRX_STATE_IDLE] = 1'b1;
699 end
700 end
701 ibrx_state[`IBRX_STATE_CONST]: begin
702 if (|ibrx_lane_error[13:0] & ibrx_stoponerr) begin
703 ibrx_state_next[`IBRX_STATE_IDLE] = 1'b1;
704 end
705 else if (ibrx_cnstgencnt[4:0] == 5'h1 & ibrx_lo_bits_sel) begin
706 ibrx_state_next[3:0] = {ibrx_const_to_const, ibrx_const_to_modn,
707 ibrx_const_to_patt, ibrx_const_to_idle};
708 end
709 else begin
710 ibrx_state_next[`IBRX_STATE_CONST] = 1'b1;
711 end
712 end
713 ibrx_state[`IBRX_STATE_MODN]: begin
714 if (|ibrx_lane_error[13:0] & ibrx_stoponerr) begin
715 ibrx_state_next[`IBRX_STATE_IDLE] = 1'b1;
716 end
717 else if (ibrx_modloopcnt[6:0] == 7'h1 & ibrx_lo_bits_sel) begin
718 ibrx_state_next[3:0] = {ibrx_modn_to_const, ibrx_modn_to_modn,
719 ibrx_modn_to_patt, ibrx_modn_to_idle};
720 end
721 else begin
722 ibrx_state_next[`IBRX_STATE_MODN] = 1'b1;
723 end
724 end
725 ibrx_state[`IBRX_STATE_PATT]: begin
726 if (|ibrx_lane_error[13:0] & ibrx_stoponerr) begin
727 ibrx_state_next[`IBRX_STATE_IDLE] = 1'b1;
728 end
729 else if (ibrx_pattloopcnt[6:0] == 7'h1 & ibrx_lo_bits_sel) begin
730 ibrx_state_next[3:0] = {ibrx_patt_to_const, ibrx_patt_to_modn,
731 ibrx_patt_to_patt, ibrx_patt_to_idle};
732 end
733 else begin
734 ibrx_state_next[`IBRX_STATE_PATT] = 1'b1;
735 end
736 end
737 default: ;
738 endcase
739end
740
741assign ibrx_done = ~ibrx_state[0] & ibrx_state_next[0];
742
743assign ibrx_modn_data[11:0] = {12{ibrx_modperiod[2:0] == 3'h1}} & 12'h555 |
744 {12{ibrx_modperiod[2:0] == 3'h2}} & 12'h333 |
745 {12{ibrx_modperiod[2:0] == 3'h3}} & 12'h1c7 |
746 {12{ibrx_modperiod[2:0] == 3'h4}} & (ibrx_lo_bits_sel ? 12'hf0f : 12'h0f0) |
747 {12{ibrx_modperiod[2:0] == 3'h6}} & (ibrx_lo_bits_sel ? 12'hfff : 12'h000);
748
749assign ibrx_patt1_data[11:0] = ibrx_lo_bits_sel ? fbdic_nbfibpattbuf1[11:0] : fbdic_nbfibpattbuf1[23:12];
750
751assign ibrx_data[11:0] = {12{ibrx_state[`IBRX_STATE_CONST]}} & {12{ibrx_cnstgenset}} |
752 {12{ibrx_state[`IBRX_STATE_PATT]}} & ibrx_patt1_data[11:0] |
753 {12{ibrx_state[`IBRX_STATE_MODN]}} & ibrx_modn_data[11:0];
754assign ibrx_data_l[11:0] = ~ibrx_data[11:0];
755
756assign ibrx_patt2_data[11:0] = ibrx_lo_bits_sel ? fbdic_nbfibpattbuf2[11:0] : fbdic_nbfibpattbuf2[23:12];
757
758// Expected receive data
759assign ibrx_rxdata[167:156] = {12{fbdic_nbfibrxmsk[13]}} & (fbdic_nbfibpatt2en[13] ? ibrx_patt2_data[11:0] :
760 ibrx_rxinvshft[13] ? ibrx_data_l[11:0] : ibrx_data[11:0]);
761assign ibrx_rxdata[155:144] = {12{fbdic_nbfibrxmsk[12]}} & (fbdic_nbfibpatt2en[12] ? ibrx_patt2_data[11:0] :
762 ibrx_rxinvshft[12] ? ibrx_data_l[11:0] : ibrx_data[11:0]);
763assign ibrx_rxdata[143:132] = {12{fbdic_nbfibrxmsk[11]}} & (fbdic_nbfibpatt2en[11] ? ibrx_patt2_data[11:0] :
764 ibrx_rxinvshft[11] ? ibrx_data_l[11:0] : ibrx_data[11:0]);
765assign ibrx_rxdata[131:120] = {12{fbdic_nbfibrxmsk[10]}} & (fbdic_nbfibpatt2en[10] ? ibrx_patt2_data[11:0] :
766 ibrx_rxinvshft[10] ? ibrx_data_l[11:0] : ibrx_data[11:0]);
767assign ibrx_rxdata[119:108] = {12{fbdic_nbfibrxmsk[9]}} & (fbdic_nbfibpatt2en[9] ? ibrx_patt2_data[11:0] :
768 ibrx_rxinvshft[9] ? ibrx_data_l[11:0] : ibrx_data[11:0]);
769assign ibrx_rxdata[107:96] = {12{fbdic_nbfibrxmsk[8]}} & (fbdic_nbfibpatt2en[8] ? ibrx_patt2_data[11:0] :
770 ibrx_rxinvshft[8] ? ibrx_data_l[11:0] : ibrx_data[11:0]);
771assign ibrx_rxdata[95:84] = {12{fbdic_nbfibrxmsk[7]}} & (fbdic_nbfibpatt2en[7] ? ibrx_patt2_data[11:0] :
772 ibrx_rxinvshft[7] ? ibrx_data_l[11:0] : ibrx_data[11:0]);
773assign ibrx_rxdata[83:72] = {12{fbdic_nbfibrxmsk[6]}} & (fbdic_nbfibpatt2en[6] ? ibrx_patt2_data[11:0] :
774 ibrx_rxinvshft[6] ? ibrx_data_l[11:0] : ibrx_data[11:0]);
775assign ibrx_rxdata[71:60] = {12{fbdic_nbfibrxmsk[5]}} & (fbdic_nbfibpatt2en[5] ? ibrx_patt2_data[11:0] :
776 ibrx_rxinvshft[5] ? ibrx_data_l[11:0] : ibrx_data[11:0]);
777assign ibrx_rxdata[59:48] = {12{fbdic_nbfibrxmsk[4]}} & (fbdic_nbfibpatt2en[4] ? ibrx_patt2_data[11:0] :
778 ibrx_rxinvshft[4] ? ibrx_data_l[11:0] : ibrx_data[11:0]);
779assign ibrx_rxdata[47:36] = {12{fbdic_nbfibrxmsk[3]}} & (fbdic_nbfibpatt2en[3] ? ibrx_patt2_data[11:0] :
780 ibrx_rxinvshft[3] ? ibrx_data_l[11:0] : ibrx_data[11:0]);
781assign ibrx_rxdata[35:24] = {12{fbdic_nbfibrxmsk[2]}} & (fbdic_nbfibpatt2en[2] ? ibrx_patt2_data[11:0] :
782 ibrx_rxinvshft[2] ? ibrx_data_l[11:0] : ibrx_data[11:0]);
783assign ibrx_rxdata[23:12] = {12{fbdic_nbfibrxmsk[1]}} & (fbdic_nbfibpatt2en[1] ? ibrx_patt2_data[11:0] :
784 ibrx_rxinvshft[1] ? ibrx_data_l[11:0] : ibrx_data[11:0]);
785assign ibrx_rxdata[11:0] = {12{fbdic_nbfibrxmsk[0]}} & (fbdic_nbfibpatt2en[0] ? ibrx_patt2_data[11:0] :
786 ibrx_rxinvshft[0] ? ibrx_data_l[11:0] : ibrx_data[11:0]);
787
788assign ibrx_ibist_mode_in = fbdic_rxstart ? 1'b1 : ibrx_done ? 1'b0 : ibrx_ibist_mode;
789
790mcu_ibrx_ctl_msff_ctl_macro ff_ibist_mode (
791 .scan_in(ff_ibist_mode_scanin),
792 .scan_out(ff_ibist_mode_scanout),
793 .din(ibrx_ibist_mode_in),
794 .dout(ibrx_ibist_mode),
795 .l1clk(l1clk),
796 .siclk(siclk),
797 .soclk(soclk));
798
799// Compare expected receive data against actual receive data
800assign ibrx_lane_error[13] = ibist_rxdata[167:156] != ibrx_rxdata[167:156] & ibrx_ibist_mode & fbdic_nbfibrxmsk[13];
801assign ibrx_lane_error[12] = ibist_rxdata[155:144] != ibrx_rxdata[155:144] & ibrx_ibist_mode & fbdic_nbfibrxmsk[12];
802assign ibrx_lane_error[11] = ibist_rxdata[143:132] != ibrx_rxdata[143:132] & ibrx_ibist_mode & fbdic_nbfibrxmsk[11];
803assign ibrx_lane_error[10] = ibist_rxdata[131:120] != ibrx_rxdata[131:120] & ibrx_ibist_mode & fbdic_nbfibrxmsk[10];
804assign ibrx_lane_error[9] = ibist_rxdata[119:108] != ibrx_rxdata[119:108] & ibrx_ibist_mode & fbdic_nbfibrxmsk[9];
805assign ibrx_lane_error[8] = ibist_rxdata[107:96] != ibrx_rxdata[107:96] & ibrx_ibist_mode & fbdic_nbfibrxmsk[8];
806assign ibrx_lane_error[7] = ibist_rxdata[95:84] != ibrx_rxdata[95:84] & ibrx_ibist_mode & fbdic_nbfibrxmsk[7];
807assign ibrx_lane_error[6] = ibist_rxdata[83:72] != ibrx_rxdata[83:72] & ibrx_ibist_mode & fbdic_nbfibrxmsk[6];
808assign ibrx_lane_error[5] = ibist_rxdata[71:60] != ibrx_rxdata[71:60] & ibrx_ibist_mode & fbdic_nbfibrxmsk[5];
809assign ibrx_lane_error[4] = ibist_rxdata[59:48] != ibrx_rxdata[59:48] & ibrx_ibist_mode & fbdic_nbfibrxmsk[4];
810assign ibrx_lane_error[3] = ibist_rxdata[47:36] != ibrx_rxdata[47:36] & ibrx_ibist_mode & fbdic_nbfibrxmsk[3];
811assign ibrx_lane_error[2] = ibist_rxdata[35:24] != ibrx_rxdata[35:24] & ibrx_ibist_mode & fbdic_nbfibrxmsk[2];
812assign ibrx_lane_error[1] = ibist_rxdata[23:12] != ibrx_rxdata[23:12] & ibrx_ibist_mode & fbdic_nbfibrxmsk[1];
813assign ibrx_lane_error[0] = ibist_rxdata[11:0] != ibrx_rxdata[11:0] & ibrx_ibist_mode & fbdic_nbfibrxmsk[0];
814
815assign ibrx_rxerrstat_in[13:0] = fbdic_ibrx_start_ld ? 14'h0 : ibrx_lane_error[13:0] | ibrx_rxerrstat[13:0];
816
817mcu_ibrx_ctl_msff_ctl_macro__width_14 ff_rxerrstat (
818 .scan_in(ff_rxerrstat_scanin),
819 .scan_out(ff_rxerrstat_scanout),
820 .din(ibrx_rxerrstat_in[13:0]),
821 .dout(ibrx_rxerrstat[13:0]),
822 .l1clk(l1clk),
823 .siclk(siclk),
824 .soclk(soclk));
825
826// Total number of errors on channel
827assign ibrx_errcnt_in[9:0] = fbdic_ibrx_start_ld ? 10'h0 :
828 ibrx_ibist_mode ? ibrx_errcnt[9:0] + {9'h0,ibrx_lane_error[0]}
829 + {9'h0,ibrx_lane_error[1]}
830 + {9'h0,ibrx_lane_error[2]}
831 + {9'h0,ibrx_lane_error[3]}
832 + {9'h0,ibrx_lane_error[4]}
833 + {9'h0,ibrx_lane_error[5]}
834 + {9'h0,ibrx_lane_error[6]}
835 + {9'h0,ibrx_lane_error[7]}
836 + {9'h0,ibrx_lane_error[8]}
837 + {9'h0,ibrx_lane_error[9]}
838 + {9'h0,ibrx_lane_error[10]}
839 + {9'h0,ibrx_lane_error[11]}
840 + {9'h0,ibrx_lane_error[12]}
841 + {9'h0,ibrx_lane_error[13]} :
842 fbdic_nbfibportctl_en ? ibrx_errcnt[9:0] & ~fbdic_errcnt_clr[9:0] : ibrx_errcnt[9:0];
843
844mcu_ibrx_ctl_msff_ctl_macro__width_10 ff_errcnt (
845 .scan_in(ff_errcnt_scanin),
846 .scan_out(ff_errcnt_scanout),
847 .din(ibrx_errcnt_in[9:0]),
848 .dout(ibrx_errcnt[9:0]),
849 .l1clk(l1clk),
850 .siclk(siclk),
851 .soclk(soclk));
852
853// First lane to have an error
854assign ibrx_first_err_lane[3:0] = ibrx_lane_error[13] ? 4'hd :
855 ibrx_lane_error[12] ? 4'hc :
856 ibrx_lane_error[11] ? 4'hb :
857 ibrx_lane_error[10] ? 4'ha :
858 ibrx_lane_error[9] ? 4'h9 :
859 ibrx_lane_error[8] ? 4'h8 :
860 ibrx_lane_error[7] ? 4'h7 :
861 ibrx_lane_error[6] ? 4'h6 :
862 ibrx_lane_error[5] ? 4'h5 :
863 ibrx_lane_error[4] ? 4'h4 :
864 ibrx_lane_error[3] ? 4'h3 :
865 ibrx_lane_error[2] ? 4'h2 :
866 ibrx_lane_error[1] ? 4'h1 : 4'h0;
867
868assign ibrx_errlnnum_in[3:0] = fbdic_ibrx_start_ld ? 4'h0 :
869 ibrx_ibist_mode & ibrx_rxerrstat[13:0] == 14'h0 ? ibrx_first_err_lane[3:0] :
870 ibrx_errlnnum[3:0];
871mcu_ibrx_ctl_msff_ctl_macro__width_4 ff_errlnnum (
872 .scan_in(ff_errlnnum_scanin),
873 .scan_out(ff_errlnnum_scanout),
874 .din(ibrx_errlnnum_in[3:0]),
875 .dout(ibrx_errlnnum[3:0]),
876 .l1clk(l1clk),
877 .siclk(siclk),
878 .soclk(soclk));
879
880// Error state:
881// 00: No error
882// 01: Did not receive first start delimiter
883// 10: Transmition error
884// 11: reserved
885assign ibrx_errstat_in[1:0] = fbdic_ibrx_start_ld ? 2'h1 :
886 fbdic_rxstart ? 2'h0 :
887 |ibrx_lane_error[13:0] ? 2'h2 :
888 fbdic_nbfibportctl_en ? ibrx_errstat[1:0] & ~fbdic_errstat_clr[1:0] : ibrx_errstat[1:0];
889
890mcu_ibrx_ctl_msff_ctl_macro__width_2 ff_errstat (
891 .scan_in(ff_errstat_scanin),
892 .scan_out(ff_errstat_scanout),
893 .din(ibrx_errstat_in[1:0]),
894 .dout(ibrx_errstat[1:0]),
895 .l1clk(l1clk),
896 .siclk(siclk),
897 .soclk(soclk));
898
899// fixscan start:
900assign ff_ovrloopcnt_scanin = scan_in ;
901assign ff_cnstgencnt_scanin = ff_ovrloopcnt_scanout ;
902assign ff_modloopcnt_scanin = ff_cnstgencnt_scanout ;
903assign ff_pattloopcnt_scanin = ff_modloopcnt_scanout ;
904assign ff_rxinvshft_scanin = ff_pattloopcnt_scanout ;
905assign ff_hiword_sel_scanin = ff_rxinvshft_scanout ;
906assign ff_state_scanin = ff_hiword_sel_scanout ;
907assign ff_ibist_mode_scanin = ff_state_scanout ;
908assign ff_rxerrstat_scanin = ff_ibist_mode_scanout ;
909assign ff_errcnt_scanin = ff_rxerrstat_scanout ;
910assign ff_errlnnum_scanin = ff_errcnt_scanout ;
911assign ff_errstat_scanin = ff_errlnnum_scanout ;
912assign scan_out = ff_errstat_scanout ;
913// fixscan end:
914endmodule
915
916
917
918
919
920
921// any PARAMS parms go into naming of macro
922
923module mcu_ibrx_ctl_msff_ctl_macro__width_6 (
924 din,
925 l1clk,
926 scan_in,
927 siclk,
928 soclk,
929 dout,
930 scan_out);
931wire [5:0] fdin;
932wire [4:0] so;
933
934 input [5:0] din;
935 input l1clk;
936 input scan_in;
937
938
939 input siclk;
940 input soclk;
941
942 output [5:0] dout;
943 output scan_out;
944assign fdin[5:0] = din[5:0];
945
946
947
948
949
950
951dff #(6) d0_0 (
952.l1clk(l1clk),
953.siclk(siclk),
954.soclk(soclk),
955.d(fdin[5:0]),
956.si({scan_in,so[4:0]}),
957.so({so[4:0],scan_out}),
958.q(dout[5:0])
959);
960
961
962
963
964
965
966
967
968
969
970
971
972endmodule
973
974
975
976
977
978
979
980
981
982
983
984
985
986// any PARAMS parms go into naming of macro
987
988module mcu_ibrx_ctl_msff_ctl_macro__width_5 (
989 din,
990 l1clk,
991 scan_in,
992 siclk,
993 soclk,
994 dout,
995 scan_out);
996wire [4:0] fdin;
997wire [3:0] so;
998
999 input [4:0] din;
1000 input l1clk;
1001 input scan_in;
1002
1003
1004 input siclk;
1005 input soclk;
1006
1007 output [4:0] dout;
1008 output scan_out;
1009assign fdin[4:0] = din[4:0];
1010
1011
1012
1013
1014
1015
1016dff #(5) d0_0 (
1017.l1clk(l1clk),
1018.siclk(siclk),
1019.soclk(soclk),
1020.d(fdin[4:0]),
1021.si({scan_in,so[3:0]}),
1022.so({so[3:0],scan_out}),
1023.q(dout[4:0])
1024);
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037endmodule
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051// any PARAMS parms go into naming of macro
1052
1053module mcu_ibrx_ctl_msff_ctl_macro__width_7 (
1054 din,
1055 l1clk,
1056 scan_in,
1057 siclk,
1058 soclk,
1059 dout,
1060 scan_out);
1061wire [6:0] fdin;
1062wire [5:0] so;
1063
1064 input [6:0] din;
1065 input l1clk;
1066 input scan_in;
1067
1068
1069 input siclk;
1070 input soclk;
1071
1072 output [6:0] dout;
1073 output scan_out;
1074assign fdin[6:0] = din[6:0];
1075
1076
1077
1078
1079
1080
1081dff #(7) d0_0 (
1082.l1clk(l1clk),
1083.siclk(siclk),
1084.soclk(soclk),
1085.d(fdin[6:0]),
1086.si({scan_in,so[5:0]}),
1087.so({so[5:0],scan_out}),
1088.q(dout[6:0])
1089);
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102endmodule
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116// any PARAMS parms go into naming of macro
1117
1118module mcu_ibrx_ctl_msff_ctl_macro__width_14 (
1119 din,
1120 l1clk,
1121 scan_in,
1122 siclk,
1123 soclk,
1124 dout,
1125 scan_out);
1126wire [13:0] fdin;
1127wire [12:0] so;
1128
1129 input [13:0] din;
1130 input l1clk;
1131 input scan_in;
1132
1133
1134 input siclk;
1135 input soclk;
1136
1137 output [13:0] dout;
1138 output scan_out;
1139assign fdin[13:0] = din[13:0];
1140
1141
1142
1143
1144
1145
1146dff #(14) d0_0 (
1147.l1clk(l1clk),
1148.siclk(siclk),
1149.soclk(soclk),
1150.d(fdin[13:0]),
1151.si({scan_in,so[12:0]}),
1152.so({so[12:0],scan_out}),
1153.q(dout[13:0])
1154);
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167endmodule
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181// any PARAMS parms go into naming of macro
1182
1183module mcu_ibrx_ctl_msff_ctl_macro (
1184 din,
1185 l1clk,
1186 scan_in,
1187 siclk,
1188 soclk,
1189 dout,
1190 scan_out);
1191wire [0:0] fdin;
1192
1193 input [0:0] din;
1194 input l1clk;
1195 input scan_in;
1196
1197
1198 input siclk;
1199 input soclk;
1200
1201 output [0:0] dout;
1202 output scan_out;
1203assign fdin[0:0] = din[0:0];
1204
1205
1206
1207
1208
1209
1210dff #(1) d0_0 (
1211.l1clk(l1clk),
1212.siclk(siclk),
1213.soclk(soclk),
1214.d(fdin[0:0]),
1215.si(scan_in),
1216.so(scan_out),
1217.q(dout[0:0])
1218);
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231endmodule
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245// any PARAMS parms go into naming of macro
1246
1247module mcu_ibrx_ctl_msff_ctl_macro__width_4 (
1248 din,
1249 l1clk,
1250 scan_in,
1251 siclk,
1252 soclk,
1253 dout,
1254 scan_out);
1255wire [3:0] fdin;
1256wire [2:0] so;
1257
1258 input [3:0] din;
1259 input l1clk;
1260 input scan_in;
1261
1262
1263 input siclk;
1264 input soclk;
1265
1266 output [3:0] dout;
1267 output scan_out;
1268assign fdin[3:0] = din[3:0];
1269
1270
1271
1272
1273
1274
1275dff #(4) d0_0 (
1276.l1clk(l1clk),
1277.siclk(siclk),
1278.soclk(soclk),
1279.d(fdin[3:0]),
1280.si({scan_in,so[2:0]}),
1281.so({so[2:0],scan_out}),
1282.q(dout[3:0])
1283);
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296endmodule
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310// any PARAMS parms go into naming of macro
1311
1312module mcu_ibrx_ctl_msff_ctl_macro__width_10 (
1313 din,
1314 l1clk,
1315 scan_in,
1316 siclk,
1317 soclk,
1318 dout,
1319 scan_out);
1320wire [9:0] fdin;
1321wire [8:0] so;
1322
1323 input [9:0] din;
1324 input l1clk;
1325 input scan_in;
1326
1327
1328 input siclk;
1329 input soclk;
1330
1331 output [9:0] dout;
1332 output scan_out;
1333assign fdin[9:0] = din[9:0];
1334
1335
1336
1337
1338
1339
1340dff #(10) d0_0 (
1341.l1clk(l1clk),
1342.siclk(siclk),
1343.soclk(soclk),
1344.d(fdin[9:0]),
1345.si({scan_in,so[8:0]}),
1346.so({so[8:0],scan_out}),
1347.q(dout[9:0])
1348);
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361endmodule
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375// any PARAMS parms go into naming of macro
1376
1377module mcu_ibrx_ctl_msff_ctl_macro__width_2 (
1378 din,
1379 l1clk,
1380 scan_in,
1381 siclk,
1382 soclk,
1383 dout,
1384 scan_out);
1385wire [1:0] fdin;
1386wire [0:0] so;
1387
1388 input [1:0] din;
1389 input l1clk;
1390 input scan_in;
1391
1392
1393 input siclk;
1394 input soclk;
1395
1396 output [1:0] dout;
1397 output scan_out;
1398assign fdin[1:0] = din[1:0];
1399
1400
1401
1402
1403
1404
1405dff #(2) d0_0 (
1406.l1clk(l1clk),
1407.siclk(siclk),
1408.soclk(soclk),
1409.d(fdin[1:0]),
1410.si({scan_in,so[0:0]}),
1411.so({so[0:0],scan_out}),
1412.q(dout[1:0])
1413);
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426endmodule
1427
1428
1429
1430
1431
1432
1433
1434