// ========== Copyright Header Begin ==========================================
// OpenSPARC T2 Processor File: amb_init.v
// Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
// 4150 Network Circle, Santa Clara, California 95054, U.S.A.
// * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 2 of the License.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// For the avoidance of doubt, and except that if any non-GPL license
// choice is available it will apply instead, Sun elects to use only
// the General Public License version 2 (GPLv2) at this time for any
// software where a choice of GPL license versions is made
// available with the language indicating that GPLv2 or any later version
// may be used, or where a choice of which version of the GPL is applied is
// otherwise unspecified.
// Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
// CA 95054 USA or visit www.sun.com if you need additional information or
// ========== Copyright Header End ============================================
module amb_init(init, // init singal going to other modules
drc, // drc register value
pn, // primary northbound
ps_bar, // primary soutbound complement
ps0_in, // primary southbound link0
ps0_in_bar, // primary southbound link0 complement
ps1_in, // primary southbound link1
ps1_in_bar, // primary southbound link1
ps2_in, // primary southbound link2
ps2_in_bar, // primary southbound link2
ps3_in, // primary southbound link3
ps4_in, // primary southbound link4
ps5_in, // primary southbound link5
ps6_in, // primary southbound link6
ps7_in, // primary southbound link7
ps8_in, // primary southbound link8
ps9_in, // primary southbound link9
ps10_in, // primary southbound link10
ps11_in, // primary southbound link11
pn0_out, // primary northbound link0
pn1_out, // primary northbound link1
pn2_out, // primary northbound link2
pn3_out, // primary northbound link3
pn4_out, // primary northbound link4
pn5_out, // primary northbound link5
pn6_out, // primary northbound link6
pn7_out, // primary northbound link7
pn8_out, // primary northbound link8
pn9_out, // primary northbound link9
pn10_out, // primary northbound link10
pn11_out, // primary northbound link11
pn12_out, // primary northbound link11
pn13_out, // primary northbound link11
enter_recalibrate,// enter recalibrate state signal
enter_los, // enter L0S state signal
clk_int, // internal clock
frm_begin, // signal that is asserted twice in a frame
frm_begin_dtm, // signal that is asserted twice in a frame
frm_boundary, // marking of frame boundaries
frm_boundary_fast, // marking of frame boundaries
frm_boundary_dtm, // marking of frame boundaries
sb_config, // soutbound configuration
nb_config, // northbound configuration
input [SB_LINK-1:0] ps,ps_bar;
output [NB_LINK-1:0] pn,pn_bar;
input [SB_LINK-1:0] ps0_in,ps1_in,ps2_in,ps3_in,ps4_in,ps5_in;
input [SB_LINK-1:0] ps6_in,ps7_in,ps8_in,ps9_in,ps10_in,ps11_in;
output [NB_LINK-1:0] pn0_out,pn1_out,pn2_out,pn3_out,pn4_out,pn5_out;
output [NB_LINK-1:0] pn6_out,pn7_out,pn8_out,pn9_out,pn10_out,pn11_out,pn12_out,pn13_out;
input [SB_LINK-1:0] ps0_in_bar,ps1_in_bar,ps2_in_bar;
input [31:0] drc,l0sdur_reg,recalibdur_reg;
output [3:0] sb_config,nb_config;
input link_clk,sclk,clk_int,dram_clk;
output frm_begin,frm_begin_dtm;
output frm_boundary,frm_boundary_dtm;
input enter_recalibrate, enter_los;
reg [143:0] ts0_reg0,ts0_reg1,ts0_reg2,ts0_reg3,ts0_reg4,ts0_reg5,ts0_reg6;
reg [143:0] ts0_reg7,ts0_reg8,ts0_reg9;
reg [11:0] ts0_clk_training;
reg [10:0] test_header_reg;
reg [13:0] ts2_start_reg,ts2_end_reg;
reg [13:0] ts3_start_reg,ts3_end_reg;
reg [10:0] calibrate_state_counter;
reg [13:0] ts1_start_reg,ts1_end_reg;
reg [7:0] fsm_added_delay_reg;
reg [8:0] LOs_Timer,Recalibrate_Timer;
reg [3:0] fsr_counter,lock_counter,prev_counter;
reg [3:0] fsr_counter2,lock_counter2,prev_counter2;
reg [3:0] fsr_counter_dtm,lock_counter_dtm,prev_counter_dtm;
reg [3:0] fsr_counter2_dtm,lock_counter2_dtm,prev_counter2_dtm;
reg [4:0] training_counter;
reg [4:0] nb_width_capability;
reg header_detected,enable_fsm,header_detected_dtm;
reg training_sequence_start_reg;
reg enter_calibrate_state;
reg testing_delimeter_end_detected;
wire [NB_LINK-1:0] pn0_out_tmp,pn1_out_tmp,pn2_out_tmp,pn3_out_tmp,pn4_out_tmp,pn5_out_tmp;
wire [NB_LINK-1:0] pn6_out_tmp,pn7_out_tmp,pn8_out_tmp,pn9_out_tmp,pn10_out_tmp,pn11_out_tmp,pn12_out_tmp,pn13_out_tmp;
wire [SB_LINK-1:0] ps_in;
wire [SB_LINK-1:0] ps_in_bar;
wire [NB_LINK-1:0] pn_reg;
wire [NB_LINK-1:0] pn_sb2nbmap;
wire [NB_LINK-1:0] pn_init;
wire [13:0] tr_amb_id_ok,ts_amb_id_ok,cf_amb_id_ok,po_amb_id_ok;
wire [13:0] frm_align,ts1_start,ts1_end,ts2_start,ts2_end,ts3_start,ts3_end;
wire [3:0] amb_id0,amb_id1,amb_id2,amb_id3;
wire [3:0] amb_id4,amb_id5,amb_id6,amb_id7;
wire [3:0] amb_id8,amb_id9,amb_id10,amb_id11;
wire [3:0] amb_id12,amb_id13;
wire [2:0] dummy_sb2nbmap;
wire training_sequence_start;
wire link_clk_int,dtm_link_clk_int;
wire ts1_complete,ts2_complete,ts3_complete;
wire detect_test_hdr_2of3;
wire detect_cfg_hdr_2of3;
wire detect_poll_hdr_2of3;
assign delay_reg =(drc[7:4]+drc[3:0])+fsm_added_delay_reg[7:0];
`ifdef AXIS_FBDIMM_NO_FSR
assign link_clk_int = link_clk & link_clk_en;
assign dtm_link_clk_int = link_clk & nb_tr_en;
assign link_clk_en = (ps_in === ps_in_bar ) | ( fsm_reenable ) ? 1'b1 : ( ~init_reg ) ? 1'b0 : 1'b1;
assign nb_tr_en = (ps_in === ps_in_bar ) | ( fsm_reenable ) ? 1'b1 : ( ~nb_tr_reg ) ? 1'b0: 1'b1;
assign put_ts0_data = init_reg & ( ( tr_amb_id_ok == 14'h3fff ) | ( ts_amb_id_ok == 14'h3fff ) | ( cf_amb_id_ok == 14'h3fff ) | ( po_amb_id_ok == 14'h3fff ));
assign mcu_sb_dummy = ps;
assign training_sequence_start = training_sequence_start_reg;
assign ts2_start = ts2_start_reg;
assign ts3_start = ts3_start_reg;
assign ts1_start = ts1_start_reg[11:0];
assign init = bypass_init ? rst : init_reg;
assign sb_config = sb_config_reg;
assign nb_config = nb_config_reg;
assign disable_state = ( curr_state == `AMB_INIT_DISABLE );
assign ch_state = curr_state;
reg [7:0] fbd_poll_add_latency;
curr_state = `AMB_INIT_DISABLE;
fsm_added_delay_reg = 8'h0;
calibrate_state_counter = 0;
`ifdef AXIS_FBDIMM_NO_FSR
fbd_poll_add_latency = 8'h4;
if ( !$value$plusargs("fbd_poll_add_latency=%h", fbd_poll_add_latency))
fbd_poll_add_latency = 8'h4;
if ($test$plusargs("1_FBDIMM")) LastAMB_ID=0;
else if ($test$plusargs("2_FBDIMMS")) LastAMB_ID=1;
else if ($test$plusargs("3_FBDIMMS")) LastAMB_ID=2;
else if ($test$plusargs("4_FBDIMMS")) LastAMB_ID=3;
else if ($test$plusargs("5_FBDIMMS")) LastAMB_ID=4;
else if ($test$plusargs("6_FBDIMMS")) LastAMB_ID=5;
else if ($test$plusargs("7_FBDIMMS")) LastAMB_ID=6;
else if ($test$plusargs("8_FBDIMMS")) LastAMB_ID=7;
if ($test$plusargs("DTM_ENABLED")) dtm_enabled=1;
if ( $test$plusargs("bypass_init")) begin
nb_width_capability=5'h1f;
dummy=$value$plusargs("fbdimm_nb_witdh_capability=%h",nb_width_capability);
if ( $test$plusargs("fbdimm_dbg")) $ch_dispmon("amb_init",`DBG_0,1);
if ( $test$plusargs("fbdimm_dbg_1")) $ch_dispmon("amb_init",`DBG_1,1);
if ( $test$plusargs("fbdimm_dbg_2")) $ch_dispmon("amb_init",`DBG_2,1);
if ( $test$plusargs("fbdimm_dbg_3")) $ch_dispmon("amb_init",`DBG_3,1);
if ( $test$plusargs("fbdimm_dbg_4")) $ch_dispmon("amb_init",`DBG_4,1);
if ( $test$plusargs("mapout_sb9")) sb_config_reg = 4'b1001;
if ( $test$plusargs("mapout_sb8")) sb_config_reg = 4'b1000;
if ( $test$plusargs("mapout_sb7")) sb_config_reg = 4'b0111;
if ( $test$plusargs("mapout_sb6")) sb_config_reg = 4'b0110;
if ( $test$plusargs("mapout_sb5")) sb_config_reg = 4'b0101;
if ( $test$plusargs("mapout_sb4")) sb_config_reg = 4'b0100;
if ( $test$plusargs("mapout_sb3")) sb_config_reg = 4'b0011;
if ( $test$plusargs("mapout_sb2")) sb_config_reg = 4'b0010;
if ( $test$plusargs("mapout_sb1")) sb_config_reg = 4'b0001;
if ( $test$plusargs("mapout_sb0")) sb_config_reg = 4'b0000;
if ( $test$plusargs("mapout_nb13")) nb_config_reg = 4'b1101;
if ( $test$plusargs("mapout_nb12")) nb_config_reg = 4'b1100;
if ( $test$plusargs("mapout_nb11")) nb_config_reg = 4'b1011;
if ( $test$plusargs("mapout_nb10")) nb_config_reg = 4'b1010;
if ( $test$plusargs("mapout_nb9")) nb_config_reg = 4'b1001;
if ( $test$plusargs("mapout_nb8")) nb_config_reg = 4'b1000;
if ( $test$plusargs("mapout_nb7")) nb_config_reg = 4'b0111;
if ( $test$plusargs("mapout_nb6")) nb_config_reg = 4'b0110;
if ( $test$plusargs("mapout_nb5")) nb_config_reg = 4'b0101;
if ( $test$plusargs("mapout_nb4")) nb_config_reg = 4'b0100;
if ( $test$plusargs("mapout_nb3")) nb_config_reg = 4'b0011;
if ( $test$plusargs("mapout_nb2")) nb_config_reg = 4'b0010;
if ( $test$plusargs("mapout_nb1")) nb_config_reg = 4'b0001;
if ( $test$plusargs("mapout_nb0")) nb_config_reg = 4'b0000;
always@(posedge link_clk)
dtm_enabled <= tb_top.start_mcu_dtm_training;
if ( !enter_calibrate_state )
if (( ps0_in[1] !== ps0_in[0] ) && ( ps0_in[1] == ps0_in[2]) ||
( ps1_in[1] !== ps1_in[0] ) && ( ps1_in[1] == ps1_in[2]) ||
( ps2_in[1] !== ps2_in[0] ) && ( ps2_in[1] == ps2_in[2]) ||
( ps3_in[1] !== ps3_in[0] ) && ( ps3_in[1] == ps3_in[2]) ||
( ps4_in[1] !== ps4_in[0] ) && ( ps4_in[1] == ps4_in[2]) ||
( ps5_in[1] !== ps5_in[0] ) && ( ps5_in[1] == ps5_in[2]) ||
( ps6_in[1] !== ps6_in[0] ) && ( ps6_in[1] == ps6_in[2]) ||
( ps7_in[1] !== ps7_in[0] ) && ( ps7_in[1] == ps7_in[2]) ||
( ps8_in[1] !== ps8_in[0] ) && ( ps8_in[1] == ps8_in[2]) ||
( ps9_in[1] !== ps9_in[0] ) && ( ps9_in[1] == ps9_in[2]) ||
( ps10_in[1] !== ps10_in[0] ) && ( ps10_in[1] == ps10_in[2]) ||
( ps11_in[1] !== ps11_in[0] ) && ( ps11_in[1] == ps11_in[2])
if ( {ps0_in[1],ps1_in[1],ps2_in[1],ps3_in[1],ps4_in[1],ps5_in[1],ps6_in[1],ps7_in[1],ps8_in[1],ps9_in[1]} == 10'h3ff )
calibrate_state_counter <= calibrate_state_counter +1 ;
calibrate_state_counter <= 0;
if ( {ps0_in[0],ps1_in[0],ps2_in[0],ps3_in[0],ps4_in[0],ps5_in[0],ps6_in[0],ps7_in[0],ps8_in[0],ps9_in[0]} == 10'h3ff )
calibrate_state_counter <= calibrate_state_counter +1 ;
calibrate_state_counter <= 0;
calibrate_state_counter <= calibrate_state_counter +1 ;
if ( (calibrate_state_counter > (`tClkTrain * 2 * 3 )) && (( curr_state == `AMB_INIT_TRAIN) || ( curr_state == `AMB_INIT_CALIB) ) )
enter_calibrate_state <= 1;
enter_calibrate_state <= 0;
enter_calibrate_state <= 0;
if ( enter_los | enter_recalibrate )
else if ( curr_state == `AMB_INIT_LO )
reg [2:0] testing_delimeter_end_detect_state;
testing_delimeter_end_detect_state=0;
always@(negedge frm_boundary)
case ( testing_delimeter_end_detect_state)
testing_delimeter_end_detected<=0;
// if (( ps0_in[1] !== ps0_in[0] ) && ( ps0_in[1] == ps0_in[2]) ) // failed lane is 0
if (( ps0_in[1] !== ps0_in[0] ) && ( ps0_in[1] == ps0_in[2]) ||
( ps1_in[1] !== ps1_in[0] ) && ( ps1_in[1] == ps1_in[2]) ||
( ps2_in[1] !== ps2_in[0] ) && ( ps2_in[1] == ps2_in[2]) ||
( ps3_in[1] !== ps3_in[0] ) && ( ps3_in[1] == ps3_in[2]) ||
( ps4_in[1] !== ps4_in[0] ) && ( ps4_in[1] == ps4_in[2]) ||
( ps5_in[1] !== ps5_in[0] ) && ( ps5_in[1] == ps5_in[2]) ||
( ps6_in[1] !== ps6_in[0] ) && ( ps6_in[1] == ps6_in[2]) ||
( ps7_in[1] !== ps7_in[0] ) && ( ps7_in[1] == ps7_in[2]) ||
( ps8_in[1] !== ps8_in[0] ) && ( ps8_in[1] == ps8_in[2]) ||
( ps9_in[1] !== ps9_in[0] ) && ( ps9_in[1] == ps9_in[2]) ||
( ps10_in[1] !== ps10_in[0] ) && ( ps10_in[1] == ps10_in[2]) ||
( ps11_in[1] !== ps11_in[0] ) && ( ps11_in[1] == ps11_in[2])
if ( ({ps11_in[1],ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1]} == 12'hffe) )
if ( ({ps11_in[0],ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0]} == 12'hffe) )
if (( ps0_in[1] !== ps0_in[0] ) && ( ps0_in[1] == ps0_in[2]) ||
( ps1_in[1] !== ps1_in[0] ) && ( ps1_in[1] == ps1_in[2]) ||
( ps2_in[1] !== ps2_in[0] ) && ( ps2_in[1] == ps2_in[2]) ||
( ps3_in[1] !== ps3_in[0] ) && ( ps3_in[1] == ps3_in[2]) ||
( ps4_in[1] !== ps4_in[0] ) && ( ps4_in[1] == ps4_in[2]) ||
( ps5_in[1] !== ps5_in[0] ) && ( ps5_in[1] == ps5_in[2]) ||
( ps6_in[1] !== ps6_in[0] ) && ( ps6_in[1] == ps6_in[2]) ||
( ps7_in[1] !== ps7_in[0] ) && ( ps7_in[1] == ps7_in[2]) ||
( ps8_in[1] !== ps8_in[0] ) && ( ps8_in[1] == ps8_in[2]) ||
( ps9_in[1] !== ps9_in[0] ) && ( ps9_in[1] == ps9_in[2]) ||
( ps10_in[1] !== ps10_in[0] ) && ( ps10_in[1] == ps10_in[2]) ||
( ps11_in[1] !== ps11_in[0] ) && ( ps11_in[1] == ps11_in[2])
// if (( ps0_in[1] !== ps0_in[0] ) && ( ps0_in[1] == ps0_in[2]) ) // failed lane is 0
if ( ({ps11_in[1],ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1]} == 12'h678) )
testing_delimeter_end_detect_state <= 3'h1;
if ( ({ps11_in[0],ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0]} == 12'h678) )
testing_delimeter_end_detect_state <= 3'h1;
if (( ps0_in[1] !== ps0_in[0] ) && ( ps0_in[1] == ps0_in[2]) ||
( ps1_in[1] !== ps1_in[0] ) && ( ps1_in[1] == ps1_in[2]) ||
( ps2_in[1] !== ps2_in[0] ) && ( ps2_in[1] == ps2_in[2]) ||
( ps3_in[1] !== ps3_in[0] ) && ( ps3_in[1] == ps3_in[2]) ||
( ps4_in[1] !== ps4_in[0] ) && ( ps4_in[1] == ps4_in[2]) ||
( ps5_in[1] !== ps5_in[0] ) && ( ps5_in[1] == ps5_in[2]) ||
( ps6_in[1] !== ps6_in[0] ) && ( ps6_in[1] == ps6_in[2]) ||
( ps7_in[1] !== ps7_in[0] ) && ( ps7_in[1] == ps7_in[2]) ||
( ps8_in[1] !== ps8_in[0] ) && ( ps8_in[1] == ps8_in[2]) ||
( ps9_in[1] !== ps9_in[0] ) && ( ps9_in[1] == ps9_in[2]) ||
( ps10_in[1] !== ps10_in[0] ) && ( ps10_in[1] == ps10_in[2]) ||
( ps11_in[1] !== ps11_in[0] ) && ( ps11_in[1] == ps11_in[2])
//if (( ps0_in[1] !== ps0_in[0] ) && ( ps0_in[1] == ps0_in[2]) ) // failed lane is 0
if ( ({ps11_in[1],ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1]} == 12'h345) )
testing_delimeter_end_detect_state <= 3'h2;
else if ( ({ps11_in[1],ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1]} !== 12'h678) )
testing_delimeter_end_detect_state <= 3'h0;
if ( ({ps11_in[0],ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0]} == 12'h345) )
testing_delimeter_end_detect_state <= 3'h2;
else if ( ({ps11_in[0],ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0]} !== 12'h678) )
testing_delimeter_end_detect_state <= 3'h0;
//if (( ps0_in[1] !== ps0_in[0] ) && ( ps0_in[1] == ps0_in[2]) ) // failed lane is 0
if (( ps0_in[1] !== ps0_in[0] ) && ( ps0_in[1] == ps0_in[2]) ||
( ps1_in[1] !== ps1_in[0] ) && ( ps1_in[1] == ps1_in[2]) ||
( ps2_in[1] !== ps2_in[0] ) && ( ps2_in[1] == ps2_in[2]) ||
( ps3_in[1] !== ps3_in[0] ) && ( ps3_in[1] == ps3_in[2]) ||
( ps4_in[1] !== ps4_in[0] ) && ( ps4_in[1] == ps4_in[2]) ||
( ps5_in[1] !== ps5_in[0] ) && ( ps5_in[1] == ps5_in[2]) ||
( ps6_in[1] !== ps6_in[0] ) && ( ps6_in[1] == ps6_in[2]) ||
( ps7_in[1] !== ps7_in[0] ) && ( ps7_in[1] == ps7_in[2]) ||
( ps8_in[1] !== ps8_in[0] ) && ( ps8_in[1] == ps8_in[2]) ||
( ps9_in[1] !== ps9_in[0] ) && ( ps9_in[1] == ps9_in[2]) ||
( ps10_in[1] !== ps10_in[0] ) && ( ps10_in[1] == ps10_in[2]) ||
( ps11_in[1] !== ps11_in[0] ) && ( ps11_in[1] == ps11_in[2])
if ( ({ps11_in[1],ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1]} == 12'h678) )
testing_delimeter_end_detect_state <= 3'h3;
testing_delimeter_end_detect_state <= 3'h0;
if ( ({ps11_in[0],ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0]} == 12'h678) )
testing_delimeter_end_detect_state <= 3'h3;
testing_delimeter_end_detect_state <= 3'h0;
//if (( ps0_in[1] !== ps0_in[0] ) && ( ps0_in[1] == ps0_in[2]) ) // failed lane is 0
if (( ps0_in[1] !== ps0_in[0] ) && ( ps0_in[1] == ps0_in[2]) ||
( ps1_in[1] !== ps1_in[0] ) && ( ps1_in[1] == ps1_in[2]) ||
( ps2_in[1] !== ps2_in[0] ) && ( ps2_in[1] == ps2_in[2]) ||
( ps3_in[1] !== ps3_in[0] ) && ( ps3_in[1] == ps3_in[2]) ||
( ps4_in[1] !== ps4_in[0] ) && ( ps4_in[1] == ps4_in[2]) ||
( ps5_in[1] !== ps5_in[0] ) && ( ps5_in[1] == ps5_in[2]) ||
( ps6_in[1] !== ps6_in[0] ) && ( ps6_in[1] == ps6_in[2]) ||
( ps7_in[1] !== ps7_in[0] ) && ( ps7_in[1] == ps7_in[2]) ||
( ps8_in[1] !== ps8_in[0] ) && ( ps8_in[1] == ps8_in[2]) ||
( ps9_in[1] !== ps9_in[0] ) && ( ps9_in[1] == ps9_in[2]) ||
( ps10_in[1] !== ps10_in[0] ) && ( ps10_in[1] == ps10_in[2]) ||
( ps11_in[1] !== ps11_in[0] ) && ( ps11_in[1] == ps11_in[2])
if ( ({ps11_in[1],ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1]} == 12'h345) )
testing_delimeter_end_detected<=1;
testing_delimeter_end_detect_state <= 3'h0;
if ( ({ps11_in[0],ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0]} == 12'h345) )
testing_delimeter_end_detected<=1;
testing_delimeter_end_detect_state <= 3'h0;
testing_delimeter_end_detect_state <= 3'h0;
wire detected_2of3_exit_ei;
wire detected_2of3_enter_ei;
voting_logic test_exit_disable (.a ( ps0_in[0] != ps0_in_bar[0] ),
.b ( ps0_in[1] != ps0_in_bar[1] ),
.c ( ps0_in[2] != ps0_in_bar[2] ),
.out (detected_2of3_exit_ei ));
voting_logic test_enter_disable (.a ( ps0_in[0] == ps0_in_bar[0] ),
.b ( ps0_in[1] == ps0_in_bar[1] ),
.c ( ps0_in[2] == ps0_in_bar[2] ),
.out (detected_2of3_enter_ei ));
wire detected_2of3_ts2_hdr;
voting_logic test_ts2_header(.a (({ps11_in[0],ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0]} == 12'hffe)),
.b (({ps11_in[1],ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1]} == 12'hffe)),
.c (({ps11_in[2],ps10_in[2],ps9_in[2],ps8_in[2],ps7_in[2],ps6_in[2],ps5_in[2],ps4_in[2],ps3_in[2],ps2_in[2],ps1_in[2],ps0_in[2]} == 12'hffe)),
.out ( detected_2of3_ts2_hdr ));
always@(negedge clk_int) if ( ~bypass_init) begin
curr_state = `AMB_INIT_DISABLE;
if ( detected_2of3_exit_ei )
curr_state=`AMB_INIT_TRAIN;
training_sequence_start_reg=1;
training_sequence_start_reg=0;
if ( enter_calibrate_state ) begin
training_sequence_start_reg=0;
curr_state=`AMB_INIT_CALIB;
if ( detected_2of3_enter_ei ) begin
training_sequence_start_reg=0;
curr_state=`AMB_INIT_DISABLE;
if ( (detected_2of3_ts2_hdr && dtm_enabled == 0 )
(dtm_tr_complete && dtm_enabled == 1))
training_counter = training_counter + 1;
training_sequence_start_reg=0;
curr_state = `AMB_INIT_LO;
else if(dtm_enabled == 0)
curr_state=`AMB_INIT_TEST;
ts0_reg0[143:0] = {ts0_reg0[142:0],ps_in[0]};
ts0_reg1[143:0] = {ts0_reg1[142:0],ps_in[1]};
ts0_reg2[143:0] = {ts0_reg2[142:0],ps_in[2]};
ts0_reg3[143:0] = {ts0_reg3[142:0],ps_in[3]};
ts0_reg4[143:0] = {ts0_reg4[142:0],ps_in[4]};
ts0_reg5[143:0] = {ts0_reg5[142:0],ps_in[5]};
ts0_reg6[143:0] = {ts0_reg6[142:0],ps_in[6]};
ts0_reg7[143:0] = {ts0_reg7[142:0],ps_in[7]};
ts0_reg8[143:0] = {ts0_reg8[142:0],ps_in[8]};
ts0_reg9[143:0] = {ts0_reg9[142:0],ps_in[9]};
if ( detected_2of3_enter_ei )
curr_state=`AMB_INIT_DISABLE;
ts1_start_reg[11:0]=12'hfff; // start testing sequence
test_header_reg[10:0] = {ps_in[0], test_header_reg[10:1]};
//if (( ps0_in[1] !== ps0_in[0] ) && ( ps0_in[1] == ps0_in[2]) ) // failed lane is 0
if (( ps0_in[1] !== ps0_in[0] ) && ( ps0_in[1] == ps0_in[2]) ||
( ps1_in[1] !== ps1_in[0] ) && ( ps1_in[1] == ps1_in[2]) ||
( ps2_in[1] !== ps2_in[0] ) && ( ps2_in[1] == ps2_in[2]) ||
( ps3_in[1] !== ps3_in[0] ) && ( ps3_in[1] == ps3_in[2]) ||
( ps4_in[1] !== ps4_in[0] ) && ( ps4_in[1] == ps4_in[2]) ||
( ps5_in[1] !== ps5_in[0] ) && ( ps5_in[1] == ps5_in[2]) ||
( ps6_in[1] !== ps6_in[0] ) && ( ps6_in[1] == ps6_in[2]) ||
( ps7_in[1] !== ps7_in[0] ) && ( ps7_in[1] == ps7_in[2]) ||
( ps8_in[1] !== ps8_in[0] ) && ( ps8_in[1] == ps8_in[2]) ||
( ps9_in[1] !== ps9_in[0] ) && ( ps9_in[1] == ps9_in[2]) ||
( ps10_in[1] !== ps10_in[0] ) && ( ps10_in[1] == ps10_in[2]) ||
( ps11_in[1] !== ps11_in[0] ) && ( ps11_in[1] == ps11_in[2])
if ( ({ps11_in[1],ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1]} == 12'h7fe) & !ts1_in_progress ) begin
curr_state=`AMB_INIT_POLL;
ts1_start_reg[11:0]=12'h0;
if ( ({ps11_in[0],ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0]} == 12'h7fe) & !ts1_in_progress ) begin
curr_state=`AMB_INIT_POLL;
ts1_start_reg[11:0]=12'h0;
if ( ps_in == ps_in_bar )
curr_state=`AMB_INIT_DISABLE;
if ( detected_2of3_enter_ei )
curr_state=`AMB_INIT_DISABLE;
ts2_start_reg=12'hfff; // start testing sequence
fsm_added_delay_reg= fbd_poll_add_latency; //8'h4; // add 6.5 dram cycles workth of delay
fsm_added_delay_reg= fbd_poll_add_latency; // add 6.5 dram cycles workth of delay
fsm_added_delay_reg=8'h2; // add 6.5 dram cycles workth of delay
//if (( ps0_in[1] !== ps0_in[0] ) && ( ps0_in[1] == ps0_in[2]) ) // failed lane is 0
if (( ps0_in[1] !== ps0_in[0] ) && ( ps0_in[1] == ps0_in[2]) ||
( ps1_in[1] !== ps1_in[0] ) && ( ps1_in[1] == ps1_in[2]) ||
( ps2_in[1] !== ps2_in[0] ) && ( ps2_in[1] == ps2_in[2]) ||
( ps3_in[1] !== ps3_in[0] ) && ( ps3_in[1] == ps3_in[2]) ||
( ps4_in[1] !== ps4_in[0] ) && ( ps4_in[1] == ps4_in[2]) ||
( ps5_in[1] !== ps5_in[0] ) && ( ps5_in[1] == ps5_in[2]) ||
( ps6_in[1] !== ps6_in[0] ) && ( ps6_in[1] == ps6_in[2]) ||
( ps7_in[1] !== ps7_in[0] ) && ( ps7_in[1] == ps7_in[2]) ||
( ps8_in[1] !== ps8_in[0] ) && ( ps8_in[1] == ps8_in[2]) ||
( ps9_in[1] !== ps9_in[0] ) && ( ps9_in[1] == ps9_in[2]) ||
( ps10_in[1] !== ps10_in[0] ) && ( ps10_in[1] == ps10_in[2]) ||
( ps11_in[1] !== ps11_in[0] ) && ( ps11_in[1] == ps11_in[2])
if ( ({ps11_in[1],ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1]} == 12'h3fe) )
curr_state=`AMB_INIT_CONFIG;
if ( ({ps11_in[0],ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0]} == 12'h3fe) )
curr_state=`AMB_INIT_CONFIG;
if ( detected_2of3_enter_ei )
curr_state=`AMB_INIT_DISABLE;
ts3_start_reg=12'hfff; // start testing sequence
if ( ps0_in | ps1_in | ps2_in | ps3_in | ps4_in | ps5_in | ps6_in | ps7_in | ps8_in | ps9_in | ps10_in | ps11_in )
if ( detected_2of3_enter_ei )
curr_state=`AMB_INIT_DISABLE;
if ( enter_recalibrate ) begin
curr_state=`AMB_INIT_RECALIB;
Recalibrate_Timer = 9'h0;
curr_state=`AMB_INIT_LOS;
fsm_added_delay_reg=8'h0 ;
if ( detected_2of3_enter_ei )
curr_state=`AMB_INIT_DISABLE;
`PR_ALWAYS ("amb_init",`DBG_0,"Entering AMB Recalibrate State!");
if ( Recalibrate_Timer == (recalibdur_reg[6:1]*12) ) // 32 frames
Recalibrate_Timer= Recalibrate_Timer + 9'h1;
if ( detected_2of3_enter_ei )
curr_state=`AMB_INIT_DISABLE;
`PR_ALWAYS ("amb_init",`DBG_0,"Entering AMB LOs State!");
if ( LOs_Timer == (l0sdur_reg[6:1]*12) ) // 32 frames
LOs_Timer= LOs_Timer + 9'h1;
assign pn_sb2nbmap = ( sb2nbmap_reg == 3'h0 ) ? {ps_in[3:0],ps_in[4:0],ps_in[4:0]} :
( sb2nbmap_reg == 3'h1 ) ? {ps_in[8:5],ps_in[9:5],ps_in[9:5]} : ps_in ;
`ifdef AXIS_FBDIMM_NO_FSR
// Need to leave this one on so that frm_boundary could be sent to other blocks
always@(posedge link_clk)
if ( fsr_counter == 4'h1 )
fsr_counter = fsr_counter - 1;
if ( fsr_counter2 == 4'h1 )
fsr_counter2 = fsr_counter2 - 1;
if ( fsr_counter_dtm == 4'h1 )
fsr_counter_dtm = fsr_counter_dtm - 1;
if ( fsr_counter2_dtm == 4'h1 )
fsr_counter2_dtm = fsr_counter2_dtm - 1;
assign frm_begin = (dtm_enabled && entered_LO ) ? frm_begin_dtm : ( fsr_counter == lock_counter ) ? 1'b1 : 1'b0 ;
assign frm_boundary = (bypass_init) ? ((fsr_counter2) == (lock_counter+6)) : (fsr_counter2 == lock_counter2) ;
assign frm_begin_dtm = (fsr_counter_dtm == lock_counter_dtm ) ? 1'b1: 1'b0;
assign frm_boundary_dtm = (bypass_init) ? ((fsr_counter2_dtm) == (lock_counter_dtm+6)) : (fsr_counter2_dtm == lock_counter2_dtm) ;
`ifdef AXIS_FBDIMM_NO_FSR
always@(negedge clk_int) if ( ~bypass_init )
always@(negedge link_clk_int) if ( ~bypass_init )
`endif // AXIS_FBDIMM_NO_FSR
lock_counter <= prev_counter;
lock_counter2 <= prev_counter2;
prev_counter <= fsr_counter;
prev_counter2 <= fsr_counter2;
always@(negedge dtm_link_clk_int) if ( ~bypass_init )
if ( rst || ( dtm_enabled && dtm_rst))
if (header_detected_dtm )
lock_counter_dtm <= prev_counter_dtm;
lock_counter2_dtm <= prev_counter2_dtm;
prev_counter_dtm <= fsr_counter_dtm;
prev_counter2_dtm <= fsr_counter2_dtm;
`ifdef AXIS_FBDIMM_NO_FSR
always@(negedge clk_int) if ( ~bypass_init && ( curr_state == `AMB_INIT_TRAIN ))
always@(posedge link_clk_int) if ( ~bypass_init && ( curr_state == `AMB_INIT_TRAIN ))
if ( ireg_l0[47:36] == 12'hbfe )
always@(posedge dtm_link_clk_int) if ( ~bypass_init)
if ( ireg_l0[47:36] == 12'hbfe )
always@(posedge dram_clk)
reg [2:0] ts3_pattern_state;
always@(negedge frm_boundary_fast )
if ( init_seq_started ) begin //init_seq_started ) begin
if ( ( curr_state == `AMB_INIT_TRAIN ))
if (( ps0_in[1] !== ps0_in[0] ) && ( ps0_in[1] == ps0_in[2]) ||
( ps1_in[1] !== ps1_in[0] ) && ( ps1_in[1] == ps1_in[2]) ||
( ps2_in[1] !== ps2_in[0] ) && ( ps2_in[1] == ps2_in[2]) ||
( ps3_in[1] !== ps3_in[0] ) && ( ps3_in[1] == ps3_in[2]) ||
( ps4_in[1] !== ps4_in[0] ) && ( ps4_in[1] == ps4_in[2]) ||
( ps5_in[1] !== ps5_in[0] ) && ( ps5_in[1] == ps5_in[2]) ||
( ps6_in[1] !== ps6_in[0] ) && ( ps6_in[1] == ps6_in[2]) ||
( ps7_in[1] !== ps7_in[0] ) && ( ps7_in[1] == ps7_in[2]) ||
( ps8_in[1] !== ps8_in[0] ) && ( ps8_in[1] == ps8_in[2]) ||
( ps9_in[1] !== ps9_in[0] ) && ( ps9_in[1] == ps9_in[2]) ||
( ps10_in[1] !== ps10_in[0] ) && ( ps10_in[1] == ps10_in[2]) ||
( ps11_in[1] !== ps11_in[0] ) && ( ps11_in[1] == ps11_in[2])
if ( ireg_l1[47:0] == 48'h345678345678 )
if ( ireg_l0[47:0] == 48'h345678345678 )
if ( ( detect_test_hdr_2of3 ) && ( curr_state == `AMB_INIT_TEST ) && !ts1_ow_en ) begin
//if (( ps0_in[0] !== ps0_in[1] ) && ( ps0_in[1] == ps0_in[2]) ) // failed lane is 0
if (( ps0_in[1] !== ps0_in[0] ) && ( ps0_in[1] == ps0_in[2]) ||
( ps1_in[1] !== ps1_in[0] ) && ( ps1_in[1] == ps1_in[2]) ||
( ps2_in[1] !== ps2_in[0] ) && ( ps2_in[1] == ps2_in[2]) ||
( ps3_in[1] !== ps3_in[0] ) && ( ps3_in[1] == ps3_in[2]) ||
( ps4_in[1] !== ps4_in[0] ) && ( ps4_in[1] == ps4_in[2]) ||
( ps5_in[1] !== ps5_in[0] ) && ( ps5_in[1] == ps5_in[2]) ||
( ps6_in[1] !== ps6_in[0] ) && ( ps6_in[1] == ps6_in[2]) ||
( ps7_in[1] !== ps7_in[0] ) && ( ps7_in[1] == ps7_in[2]) ||
( ps8_in[1] !== ps8_in[0] ) && ( ps8_in[1] == ps8_in[2]) ||
( ps9_in[1] !== ps9_in[0] ) && ( ps9_in[1] == ps9_in[2]) ||
( ps10_in[1] !== ps10_in[0] ) && ( ps10_in[1] == ps10_in[2]) ||
( ps11_in[1] !== ps11_in[0] ) && ( ps11_in[1] == ps11_in[2])
sb2nbmap_reg = ireg_l1[31:28];
sb2nbmap_reg = ireg_l0[31:28];
ireg_l0[47:0] <= { ps11_in[0], ps10_in[0], ps9_in[0], ps8_in[0], ps7_in[0], ps6_in[0],ps5_in[0],ps4_in[0], ps3_in[0], ps2_in[0], ps1_in[0], ps0_in[0], ireg_l0[47:28],LastAMB_ID,ireg_l0[23:12]};
ireg_l1[47:0] <= { ps11_in[1], ps10_in[1], ps9_in[1], ps8_in[1], ps7_in[1], ps6_in[1], ps5_in[1], ps4_in[1], ps3_in[1], ps2_in[1], ps1_in[1], ps0_in[1], ireg_l1[47:28],LastAMB_ID,ireg_l1[23:12]};
ireg_l2[47:0] <= { ps11_in[2], ps10_in[2], ps9_in[2], ps8_in[2], ps7_in[2], ps6_in[2], ps5_in[2], ps4_in[2], ps3_in[2], ps2_in[2], ps1_in[2], ps0_in[2], ireg_l2[47:28],LastAMB_ID,ireg_l2[23:12]};
ireg_l3[47:0] <= { ps11_in[3], ps10_in[3], ps9_in[3], ps8_in[3], ps7_in[3], ps6_in[3], ps5_in[3], ps4_in[3], ps3_in[3], ps2_in[3], ps1_in[3], ps0_in[3], ireg_l3[47:28],LastAMB_ID,ireg_l3[23:12]};
ireg_l4[47:0] <= { ps11_in[4], ps10_in[4], ps9_in[4], ps8_in[4], ps7_in[4], ps6_in[4], ps5_in[4], ps4_in[4], ps3_in[4], ps2_in[4], ps1_in[4], ps0_in[4], ireg_l4[47:28],LastAMB_ID,ireg_l4[23:12]};
ireg_l5[47:0] <= { ps11_in[5], ps10_in[5], ps9_in[5], ps8_in[5], ps7_in[5], ps6_in[5], ps5_in[5], ps4_in[5], ps3_in[5], ps2_in[5], ps1_in[5], ps0_in[5], ireg_l5[47:28],LastAMB_ID,ireg_l5[23:12]};
ireg_l6[47:0] <= { ps11_in[6], ps10_in[6], ps9_in[6], ps8_in[6], ps7_in[6], ps6_in[6], ps5_in[6], ps4_in[6], ps3_in[6], ps2_in[6], ps1_in[6], ps0_in[6], ireg_l6[47:28],LastAMB_ID,ireg_l6[23:12]};
ireg_l7[47:0] <= { ps11_in[7], ps10_in[7], ps9_in[7], ps8_in[7], ps7_in[7], ps6_in[7], ps5_in[7], ps4_in[7], ps3_in[7], ps2_in[7], ps1_in[7], ps0_in[7], ireg_l7[47:28],LastAMB_ID,ireg_l7[23:12]};
ireg_l8[47:0] <= { ps11_in[8], ps10_in[8], ps9_in[8], ps8_in[8], ps7_in[8], ps6_in[8], ps5_in[8], ps4_in[8], ps3_in[8], ps2_in[8], ps1_in[8], ps0_in[8], ireg_l8[47:28],LastAMB_ID,ireg_l8[23:12]};
ireg_l9[47:0] <= { ps11_in[9], ps10_in[9], ps9_in[9], ps8_in[9], ps7_in[9], ps6_in[9], ps5_in[9], ps4_in[9], ps3_in[9], ps2_in[9], ps1_in[9], ps0_in[9], ireg_l9[47:28],LastAMB_ID,ireg_l9[23:12]};
else if (( detect_cfg_hdr_2of3 & ~frm_boundary_fast) && ( curr_state == `AMB_INIT_CONFIG ) ) begin
// if (( ps0_in[1] !== ps0_in[0] ) && ( ps0_in[1] == ps0_in[2]) ) // failed lane is 0
if (( ps0_in[1] !== ps0_in[0] ) && ( ps0_in[1] == ps0_in[2]) ||
( ps1_in[1] !== ps1_in[0] ) && ( ps1_in[1] == ps1_in[2]) ||
( ps2_in[1] !== ps2_in[0] ) && ( ps2_in[1] == ps2_in[2]) ||
( ps3_in[1] !== ps3_in[0] ) && ( ps3_in[1] == ps3_in[2]) ||
( ps4_in[1] !== ps4_in[0] ) && ( ps4_in[1] == ps4_in[2]) ||
( ps5_in[1] !== ps5_in[0] ) && ( ps5_in[1] == ps5_in[2]) ||
( ps6_in[1] !== ps6_in[0] ) && ( ps6_in[1] == ps6_in[2]) ||
( ps7_in[1] !== ps7_in[0] ) && ( ps7_in[1] == ps7_in[2]) ||
( ps8_in[1] !== ps8_in[0] ) && ( ps8_in[1] == ps8_in[2]) ||
( ps9_in[1] !== ps9_in[0] ) && ( ps9_in[1] == ps9_in[2]) ||
( ps10_in[1] !== ps10_in[0] ) && ( ps10_in[1] == ps10_in[2]) ||
( ps11_in[1] !== ps11_in[0] ) && ( ps11_in[1] == ps11_in[2])
nb_config_reg <= ireg_l1[45:42];
sb_config_reg <= ireg_l1[39:36];
ireg_l0[47:0] <= { ps11_in[1], ps10_in[1], ps9_in[1], ps8_in[1], ps7_in[1], ps6_in[1],ps5_in[1],ps4_in[1], ps3_in[1], ps2_in[1], ps1_in[1], ps0_in[1], ireg_l0[47:36],8'h0,LastAMB_ID, ireg_l0[23:12]};
ireg_l1[47:0] <= { ps11_in[1], ps10_in[1], ps9_in[1], ps8_in[1], ps7_in[1], ps6_in[1],ps5_in[1],ps4_in[1], ps3_in[1], ps2_in[1], ps1_in[1], ps0_in[1], ireg_l1[47:36],8'h0,LastAMB_ID, ireg_l1[23:12]};
ireg_l2[47:0] <= { ps11_in[1], ps10_in[1], ps9_in[1], ps8_in[1], ps7_in[1], ps6_in[1],ps5_in[1],ps4_in[1], ps3_in[1], ps2_in[1], ps1_in[1], ps0_in[1], ireg_l2[47:36],8'h0,LastAMB_ID, ireg_l2[23:12]};
ireg_l3[47:0] <= { ps11_in[1], ps10_in[1], ps9_in[1], ps8_in[1], ps7_in[1], ps6_in[1],ps5_in[1],ps4_in[1], ps3_in[1], ps2_in[1], ps1_in[1], ps0_in[1], ireg_l3[47:36],8'h0,LastAMB_ID, ireg_l3[23:12]};
ireg_l4[47:0] <= { ps11_in[1], ps10_in[1], ps9_in[1], ps8_in[1], ps7_in[1], ps6_in[1],ps5_in[1],ps4_in[1], ps3_in[1], ps2_in[1], ps1_in[1], ps0_in[1], ireg_l4[47:36],8'h0,LastAMB_ID, ireg_l4[23:12]};
ireg_l5[47:0] <= { ps11_in[1], ps10_in[1], ps9_in[1], ps8_in[1], ps7_in[1], ps6_in[1],ps5_in[1],ps4_in[1], ps3_in[1], ps2_in[1], ps1_in[1], ps0_in[1], ireg_l5[47:36],8'h0,LastAMB_ID, ireg_l5[23:12]};
ireg_l6[47:0] <= { ps11_in[1], ps10_in[1], ps9_in[1], ps8_in[1], ps7_in[1], ps6_in[1],ps5_in[1],ps4_in[1], ps3_in[1], ps2_in[1], ps1_in[1], ps0_in[1], ireg_l6[47:36],8'h0,LastAMB_ID, ireg_l6[23:12]};
ireg_l7[47:0] <= { ps11_in[1], ps10_in[1], ps9_in[1], ps8_in[1], ps7_in[1], ps6_in[1],ps5_in[1],ps4_in[1], ps3_in[1], ps2_in[1], ps1_in[1], ps0_in[1], ireg_l7[47:36],8'h0,LastAMB_ID, ireg_l7[23:12]};
ireg_l8[47:0] <= { ps11_in[1], ps10_in[1], ps9_in[1], ps8_in[1], ps7_in[1], ps6_in[1],ps5_in[1],ps4_in[1], ps3_in[1], ps2_in[1], ps1_in[1], ps0_in[1], ireg_l8[47:36],8'h0,LastAMB_ID, ireg_l8[23:12]};
ireg_l9[47:0] <= { ps11_in[1], ps10_in[1], ps9_in[1], ps8_in[1], ps7_in[1], ps6_in[1],ps5_in[1],ps4_in[1], ps3_in[1], ps2_in[1], ps1_in[1], ps0_in[1], ireg_l9[47:36],8'h0,LastAMB_ID,ireg_l9[23:12]};
nb_config_reg <= ireg_l0[45:42];
sb_config_reg <= ireg_l0[39:36];
ireg_l0[47:0] <= { ps11_in[0], ps10_in[0], ps9_in[0], ps8_in[0], ps7_in[0], ps6_in[0],ps5_in[0],ps4_in[0], ps3_in[0], ps2_in[0], ps1_in[0], ps0_in[0], ireg_l0[47:36],8'h0,LastAMB_ID, ireg_l0[23:12]};
ireg_l1[47:0] <= { ps11_in[0], ps10_in[0], ps9_in[0], ps8_in[0], ps7_in[0], ps6_in[0],ps5_in[0],ps4_in[0], ps3_in[0], ps2_in[0], ps1_in[0], ps0_in[0], ireg_l1[47:36],8'h0,LastAMB_ID, ireg_l1[23:12]};
ireg_l2[47:0] <= { ps11_in[0], ps10_in[0], ps9_in[0], ps8_in[0], ps7_in[0], ps6_in[0],ps5_in[0],ps4_in[0], ps3_in[0], ps2_in[0], ps1_in[0], ps0_in[0], ireg_l2[47:36],8'h0,LastAMB_ID, ireg_l2[23:12]};
ireg_l3[47:0] <= { ps11_in[0], ps10_in[0], ps9_in[0], ps8_in[0], ps7_in[0], ps6_in[0],ps5_in[0],ps4_in[0], ps3_in[0], ps2_in[0], ps1_in[0], ps0_in[0], ireg_l3[47:36],8'h0,LastAMB_ID, ireg_l3[23:12]};
ireg_l4[47:0] <= { ps11_in[0], ps10_in[0], ps9_in[0], ps8_in[0], ps7_in[0], ps6_in[0],ps5_in[0],ps4_in[0], ps3_in[0], ps2_in[0], ps1_in[0], ps0_in[0], ireg_l4[47:36],8'h0,LastAMB_ID, ireg_l4[23:12]};
ireg_l5[47:0] <= { ps11_in[0], ps10_in[0], ps9_in[0], ps8_in[0], ps7_in[0], ps6_in[0],ps5_in[0],ps4_in[0], ps3_in[0], ps2_in[0], ps1_in[0], ps0_in[0], ireg_l5[47:36],8'h0,LastAMB_ID, ireg_l5[23:12]};
ireg_l6[47:0] <= { ps11_in[0], ps10_in[0], ps9_in[0], ps8_in[0], ps7_in[0], ps6_in[0],ps5_in[0],ps4_in[0], ps3_in[0], ps2_in[0], ps1_in[0], ps0_in[0], ireg_l6[47:36],8'h0,LastAMB_ID, ireg_l6[23:12]};
ireg_l7[47:0] <= { ps11_in[0], ps10_in[0], ps9_in[0], ps8_in[0], ps7_in[0], ps6_in[0],ps5_in[0],ps4_in[0], ps3_in[0], ps2_in[0], ps1_in[0], ps0_in[0], ireg_l7[47:36],8'h0,LastAMB_ID, ireg_l7[23:12]};
ireg_l8[47:0] <= { ps11_in[0], ps10_in[0], ps9_in[0], ps8_in[0], ps7_in[0], ps6_in[0],ps5_in[0],ps4_in[0], ps3_in[0], ps2_in[0], ps1_in[0], ps0_in[0], ireg_l8[47:36],8'h0,LastAMB_ID, ireg_l8[23:12]};
ireg_l9[47:0] <= { ps11_in[0], ps10_in[0], ps9_in[0], ps8_in[0], ps7_in[0], ps6_in[0],ps5_in[0],ps4_in[0], ps3_in[0], ps2_in[0], ps1_in[0], ps0_in[0], ireg_l9[47:36],8'h0,LastAMB_ID,ireg_l9[23:12]};
else if ( ( detect_poll_hdr_2of3) && ( curr_state == `AMB_INIT_POLL ) ) begin
// if (( ps0_in[1] !== ps0_in[0] ) && ( ps0_in[1] == ps0_in[2]) ) // failed lane is 0
if (( ps0_in[1] !== ps0_in[0] ) && ( ps0_in[1] == ps0_in[2]) ||
( ps1_in[1] !== ps1_in[0] ) && ( ps1_in[1] == ps1_in[2]) ||
( ps2_in[1] !== ps2_in[0] ) && ( ps2_in[1] == ps2_in[2]) ||
( ps3_in[1] !== ps3_in[0] ) && ( ps3_in[1] == ps3_in[2]) ||
( ps4_in[1] !== ps4_in[0] ) && ( ps4_in[1] == ps4_in[2]) ||
( ps5_in[1] !== ps5_in[0] ) && ( ps5_in[1] == ps5_in[2]) ||
( ps6_in[1] !== ps6_in[0] ) && ( ps6_in[1] == ps6_in[2]) ||
( ps7_in[1] !== ps7_in[0] ) && ( ps7_in[1] == ps7_in[2]) ||
( ps8_in[1] !== ps8_in[0] ) && ( ps8_in[1] == ps8_in[2]) ||
( ps9_in[1] !== ps9_in[0] ) && ( ps9_in[1] == ps9_in[2]) ||
( ps10_in[1] !== ps10_in[0] ) && ( ps10_in[1] == ps10_in[2]) ||
( ps11_in[1] !== ps11_in[0] ) && ( ps11_in[1] == ps11_in[2])
ireg_l0[47:0] <= { ps11_in[1], ps10_in[1], ps9_in[1], ps8_in[1], ps7_in[1], ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1], 2'h0, nb_width_capability,1'h0,tsid, ireg_l0[35:12]};
ireg_l1[47:0] <= { ps11_in[1], ps10_in[1], ps9_in[1], ps8_in[1], ps7_in[1], ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1], 2'h0, nb_width_capability,1'h0,tsid ,ireg_l1[35:12]};
ireg_l2[47:0] <= { ps11_in[1], ps10_in[1], ps9_in[1], ps8_in[1], ps7_in[1], ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1], 2'h0, nb_width_capability,1'h0,tsid, ireg_l2[35:12]};
ireg_l3[47:0] <= { ps11_in[1], ps10_in[1], ps9_in[1], ps8_in[1], ps7_in[1], ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1], 2'h0, nb_width_capability,1'h0,tsid, ireg_l3[35:12]};
ireg_l4[47:0] <= { ps11_in[1], ps10_in[1], ps9_in[1], ps8_in[1], ps7_in[1], ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1], 2'h0, nb_width_capability,1'h0,tsid, ireg_l4[35:12]};
ireg_l5[47:0] <= { ps11_in[1], ps10_in[1], ps9_in[1], ps8_in[1], ps7_in[1], ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1], 2'h0, nb_width_capability,1'h0 ,tsid, ireg_l5[35:12]};
ireg_l6[47:0] <= { ps11_in[1], ps10_in[1], ps9_in[1], ps8_in[1], ps7_in[1], ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1], 2'h0, nb_width_capability,1'h0,tsid, ireg_l6[35:12]};
ireg_l7[47:0] <= { ps11_in[1], ps10_in[1], ps9_in[1], ps8_in[1], ps7_in[1], ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1], 2'h0, nb_width_capability,1'h0 ,tsid, ireg_l7[35:12]};
ireg_l8[47:0] <= { ps11_in[1], ps10_in[1], ps9_in[1], ps8_in[1], ps7_in[1], ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1], 2'h0, nb_width_capability,1'h0,tsid, ireg_l8[35:12]};
ireg_l9[47:0] <= { ps11_in[1], ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[9],2'h0, nb_width_capability,1'h0 ,tsid, ireg_l9[35:12]};
ireg_l0[47:0] <= { ps11_in[0], ps10_in[0], ps9_in[0], ps8_in[0], ps7_in[0], ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0], 2'h0, nb_width_capability,1'h0,tsid, ireg_l0[35:12]};
ireg_l1[47:0] <= { ps11_in[0], ps10_in[0], ps9_in[0], ps8_in[0], ps7_in[0], ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0], 2'h0, nb_width_capability,1'h0,tsid ,ireg_l1[35:12]};
ireg_l2[47:0] <= { ps11_in[0], ps10_in[0], ps9_in[0], ps8_in[0], ps7_in[0], ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0], 2'h0, nb_width_capability,1'h0,tsid, ireg_l2[35:12]};
ireg_l3[47:0] <= { ps11_in[0], ps10_in[0], ps9_in[0], ps8_in[0], ps7_in[0], ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0], 2'h0, nb_width_capability,1'h0,tsid, ireg_l3[35:12]};
ireg_l4[47:0] <= { ps11_in[0], ps10_in[0], ps9_in[0], ps8_in[0], ps7_in[0], ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0], 2'h0, nb_width_capability,1'h0,tsid, ireg_l4[35:12]};
ireg_l5[47:0] <= { ps11_in[0], ps10_in[0], ps9_in[0], ps8_in[0], ps7_in[0], ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0], 2'h0, nb_width_capability,1'h0 ,tsid, ireg_l5[35:12]};
ireg_l6[47:0] <= { ps11_in[0], ps10_in[0], ps9_in[0], ps8_in[0], ps7_in[0], ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0], 2'h0, nb_width_capability,1'h0,tsid, ireg_l6[35:12]};
ireg_l7[47:0] <= { ps11_in[0], ps10_in[0], ps9_in[0], ps8_in[0], ps7_in[0], ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0], 2'h0, nb_width_capability,1'h0 ,tsid, ireg_l7[35:12]};
ireg_l8[47:0] <= { ps11_in[0], ps10_in[0], ps9_in[0], ps8_in[0], ps7_in[0], ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0], 2'h0, nb_width_capability,1'h0,tsid, ireg_l8[35:12]};
ireg_l9[47:0] <= { ps11_in[0], ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[9],2'h0, nb_width_capability,1'h0 ,tsid, ireg_l9[35:12]};
else if ( curr_state == `AMB_INIT_CONFIG )
// if (( ps0_in[1] !== ps0_in[0] ) && ( ps0_in[1] == ps0_in[2]) ) // failed lane is 0
if (( ps0_in[1] !== ps0_in[0] ) && ( ps0_in[1] == ps0_in[2]) ||
( ps1_in[1] !== ps1_in[0] ) && ( ps1_in[1] == ps1_in[2]) ||
( ps2_in[1] !== ps2_in[0] ) && ( ps2_in[1] == ps2_in[2]) ||
( ps3_in[1] !== ps3_in[0] ) && ( ps3_in[1] == ps3_in[2]) ||
( ps4_in[1] !== ps4_in[0] ) && ( ps4_in[1] == ps4_in[2]) ||
( ps5_in[1] !== ps5_in[0] ) && ( ps5_in[1] == ps5_in[2]) ||
( ps6_in[1] !== ps6_in[0] ) && ( ps6_in[1] == ps6_in[2]) ||
( ps7_in[1] !== ps7_in[0] ) && ( ps7_in[1] == ps7_in[2]) ||
( ps8_in[1] !== ps8_in[0] ) && ( ps8_in[1] == ps8_in[2]) ||
( ps9_in[1] !== ps9_in[0] ) && ( ps9_in[1] == ps9_in[2]) ||
( ps10_in[1] !== ps10_in[0] ) && ( ps10_in[1] == ps10_in[2]) ||
( ps11_in[1] !== ps11_in[0] ) && ( ps11_in[1] == ps11_in[2])
ireg_l0[47:0] <= { ps11_in[1],ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1],ireg_l0[47:12]};
ireg_l1[47:0] <= { ps11_in[1],ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1],ireg_l1[47:12]};
ireg_l2[47:0] <= { ps11_in[1],ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1],ireg_l2[47:12]};
ireg_l3[47:0] <= { ps11_in[1],ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1],ireg_l3[47:12]};
ireg_l4[47:0] <= { ps11_in[1],ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1],ireg_l4[47:12]};
ireg_l5[47:0] <= { ps11_in[1],ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1],ireg_l5[47:12]};
ireg_l6[47:0] <= { ps11_in[1],ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1],ireg_l6[47:12]};
ireg_l7[47:0] <= { ps11_in[1],ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1],ireg_l7[47:12]};
ireg_l8[47:0] <= { ps11_in[1],ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1],ireg_l8[47:12]};
ireg_l9[47:0] <= { ps11_in[1],ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1],ireg_l9[47:12]};
ireg_l0[47:0] <= { ps11_in[0],ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0],ireg_l0[47:12]};
ireg_l1[47:0] <= { ps11_in[0],ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0],ireg_l1[47:12]};
ireg_l2[47:0] <= { ps11_in[0],ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0],ireg_l2[47:12]};
ireg_l3[47:0] <= { ps11_in[0],ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0],ireg_l3[47:12]};
ireg_l4[47:0] <= { ps11_in[0],ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0],ireg_l4[47:12]};
ireg_l5[47:0] <= { ps11_in[0],ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0],ireg_l5[47:12]};
ireg_l6[47:0] <= { ps11_in[0],ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0],ireg_l6[47:12]};
ireg_l7[47:0] <= { ps11_in[0],ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0],ireg_l7[47:12]};
ireg_l8[47:0] <= { ps11_in[0],ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0],ireg_l8[47:12]};
ireg_l9[47:0] <= { ps11_in[0],ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0],ireg_l9[47:12]};
else if ( curr_state == `AMB_INIT_TEST ) begin
ireg_l0[47:0] <= { ps11_in[0], ps10_in[0], ps9_in[0], ps8_in[0], ps7_in[0], ps6_in[0],ps5_in[0],ps4_in[0], ps3_in[0], ps2_in[0], ps1_in[0], ps0_in[0], ireg_l0[47:12]};
ireg_l1[47:0] <= { ps11_in[1], ps10_in[1], ps9_in[1], ps8_in[1], ps7_in[1], ps6_in[1], ps5_in[1], ps4_in[1], ps3_in[1], ps2_in[1], ps1_in[1], ps0_in[1], ireg_l1[47:12]};
ireg_l2[47:0] <= { ps11_in[2], ps10_in[2], ps9_in[2], ps8_in[2], ps7_in[2], ps6_in[2], ps5_in[2], ps4_in[2], ps3_in[2], ps2_in[2], ps1_in[2], ps0_in[2], ireg_l2[47:12]};
ireg_l3[47:0] <= { ps11_in[3], ps10_in[3], ps9_in[3], ps8_in[3], ps7_in[3], ps6_in[3], ps5_in[3], ps4_in[3], ps3_in[3], ps2_in[3], ps1_in[3], ps0_in[3], ireg_l3[47:12]};
ireg_l4[47:0] <= { ps11_in[4], ps10_in[4], ps9_in[4], ps8_in[4], ps7_in[4], ps6_in[4], ps5_in[4], ps4_in[4], ps3_in[4], ps2_in[4], ps1_in[4], ps0_in[4], ireg_l4[47:12]};
ireg_l5[47:0] <= { ps11_in[5], ps10_in[5], ps9_in[5], ps8_in[5], ps7_in[5], ps6_in[5], ps5_in[5], ps4_in[5], ps3_in[5], ps2_in[5], ps1_in[5], ps0_in[5], ireg_l5[47:12]};
ireg_l6[47:0] <= { ps11_in[6], ps10_in[6], ps9_in[6], ps8_in[6], ps7_in[6], ps6_in[6], ps5_in[6], ps4_in[6], ps3_in[6], ps2_in[6], ps1_in[6], ps0_in[6], ireg_l6[47:12]};
ireg_l7[47:0] <= { ps11_in[7], ps10_in[7], ps9_in[7], ps8_in[7], ps7_in[7], ps6_in[7], ps5_in[7], ps4_in[7], ps3_in[7], ps2_in[7], ps1_in[7], ps0_in[7], ireg_l7[47:12]};
ireg_l8[47:0] <= { ps11_in[8], ps10_in[8], ps9_in[8], ps8_in[8], ps7_in[8], ps6_in[8], ps5_in[8], ps4_in[8], ps3_in[8], ps2_in[8], ps1_in[8], ps0_in[8], ireg_l8[47:12]};
ireg_l9[47:0] <= { ps11_in[9], ps10_in[9], ps9_in[9], ps8_in[9], ps7_in[9], ps6_in[9], ps5_in[9], ps4_in[9], ps3_in[9], ps2_in[9], ps1_in[9], ps0_in[9], ireg_l9[47:12]};
if (( ps0_in[1] !== ps0_in[0] ) && ( ps0_in[1] == ps0_in[2]) ||
( ps1_in[1] !== ps1_in[0] ) && ( ps1_in[1] == ps1_in[2]) ||
( ps2_in[1] !== ps2_in[0] ) && ( ps2_in[1] == ps2_in[2]) ||
( ps3_in[1] !== ps3_in[0] ) && ( ps3_in[1] == ps3_in[2]) ||
( ps4_in[1] !== ps4_in[0] ) && ( ps4_in[1] == ps4_in[2]) ||
( ps5_in[1] !== ps5_in[0] ) && ( ps5_in[1] == ps5_in[2]) ||
( ps6_in[1] !== ps6_in[0] ) && ( ps6_in[1] == ps6_in[2]) ||
( ps7_in[1] !== ps7_in[0] ) && ( ps7_in[1] == ps7_in[2]) ||
( ps8_in[1] !== ps8_in[0] ) && ( ps8_in[1] == ps8_in[2]) ||
( ps9_in[1] !== ps9_in[0] ) && ( ps9_in[1] == ps9_in[2]) ||
( ps10_in[1] !== ps10_in[0] ) && ( ps10_in[1] == ps10_in[2]) ||
( ps11_in[1] !== ps11_in[0] ) && ( ps11_in[1] == ps11_in[2])
ireg_l0[47:0] <= { ps11_in[1],ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1],ireg_l0[47:12]};
ireg_l1[47:0] <= { ps11_in[1],ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1],ireg_l1[47:12]};
ireg_l2[47:0] <= { ps11_in[1],ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1],ireg_l2[47:12]};
ireg_l3[47:0] <= { ps11_in[1],ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1],ireg_l3[47:12]};
ireg_l4[47:0] <= { ps11_in[1],ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1],ireg_l4[47:12]};
ireg_l5[47:0] <= { ps11_in[1],ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1],ireg_l5[47:12]};
ireg_l6[47:0] <= { ps11_in[1],ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1],ireg_l6[47:12]};
ireg_l7[47:0] <= { ps11_in[1],ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1],ireg_l7[47:12]};
ireg_l8[47:0] <= { ps11_in[1],ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1],ireg_l8[47:12]};
ireg_l9[47:0] <= { ps11_in[1],ps10_in[1],ps9_in[1],ps8_in[1],ps7_in[1],ps6_in[1],ps5_in[1],ps4_in[1],ps3_in[1],ps2_in[1],ps1_in[1],ps0_in[1],ireg_l9[47:12]};
ireg_l0[47:0] <= { ps11_in[0],ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0],ireg_l0[47:12]};
ireg_l1[47:0] <= { ps11_in[0],ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0],ireg_l1[47:12]};
ireg_l2[47:0] <= { ps11_in[0],ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0],ireg_l2[47:12]};
ireg_l3[47:0] <= { ps11_in[0],ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0],ireg_l3[47:12]};
ireg_l4[47:0] <= { ps11_in[0],ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0],ireg_l4[47:12]};
ireg_l5[47:0] <= { ps11_in[0],ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0],ireg_l5[47:12]};
ireg_l6[47:0] <= { ps11_in[0],ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0],ireg_l6[47:12]};
ireg_l7[47:0] <= { ps11_in[0],ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0],ireg_l7[47:12]};
ireg_l8[47:0] <= { ps11_in[0],ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0],ireg_l8[47:12]};
ireg_l9[47:0] <= { ps11_in[0],ps10_in[0],ps9_in[0],ps8_in[0],ps7_in[0],ps6_in[0],ps5_in[0],ps4_in[0],ps3_in[0],ps2_in[0],ps1_in[0],ps0_in[0],ireg_l9[47:12]};
ts3_ireg = {12'h3fe,36'h0};
always@(negedge frm_boundary_fast ) if ( curr_state == `AMB_INIT_CONFIG )
case ( ts3_pattern_state )
ts3_pattern <= {8'h0,LastAMB_ID};
ts3_pattern_state <= 3'h1;
ts3_pattern_state <= 3'h2;
ts3_pattern <= {2'b01, ps3_in[1], ps2_in[1],ps1_in[1],ps0_in[1], ps6_in[0],2'b00,ps9_in[1], ps8_in[1],ps7_in[1],ps6_in[1]};
ts3_pattern_state <= 3'h3;
ts3_pattern_state <= 3'h4;
ts3_pattern_state <= 3'h5;
ts3_pattern_state <= 3'h6;
ts3_pattern_state <= 3'h0;
assign pn0_out_tmp = (enter_calibrate_state ) ? 14'h3fff :
( sb2nbmap_reg == 3'h0 ) ? {ireg_l3[0],ireg_l2[0],ireg_l1[0],ireg_l0[0],ireg_l4[0],ireg_l3[0],ireg_l2[0],ireg_l1[0], ireg_l0[0], ireg_l4[0],ireg_l3[0],ireg_l2[0],ireg_l1[0],ireg_l0[0]} :
( sb2nbmap_reg == 3'h1 ) ? {ireg_l8[0],ireg_l7[0],ireg_l6[0],ireg_l5[0],ireg_l9[0],ireg_l8[0],ireg_l7[0],ireg_l6[0], ireg_l5[0], ireg_l9[0],ireg_l8[0],ireg_l7[0],ireg_l6[0],ireg_l5[0]} :
{ireg_l3[0],ireg_l2[0],ireg_l1[0],ireg_l0[0],ireg_l4[0],ireg_l3[0],ireg_l2[0],ireg_l1[0], ireg_l0[0], ireg_l4[0],ireg_l3[0],ireg_l2[0],ireg_l1[0],ireg_l0[0]};
assign pn1_out_tmp = (enter_calibrate_state ) ? 14'h3fff :
( sb2nbmap_reg == 3'h0 ) ? {ireg_l3[1],ireg_l2[1],ireg_l1[1],ireg_l0[1],ireg_l4[1],ireg_l3[1],ireg_l2[1],ireg_l1[1], ireg_l0[1], ireg_l4[1],ireg_l3[1],ireg_l2[1],ireg_l1[1],ireg_l0[1]} :
( sb2nbmap_reg == 3'h1 ) ? {ireg_l8[1],ireg_l7[1],ireg_l6[1],ireg_l5[1],ireg_l9[1],ireg_l8[1],ireg_l7[1],ireg_l6[1], ireg_l5[1], ireg_l9[1],ireg_l8[1],ireg_l7[1],ireg_l6[1],ireg_l5[1]} :
{ireg_l3[1],ireg_l2[1],ireg_l1[1],ireg_l0[1],ireg_l4[1],ireg_l3[1],ireg_l2[1],ireg_l1[1], ireg_l0[1], ireg_l4[1],ireg_l3[1],ireg_l2[1],ireg_l1[1],ireg_l0[1]};
assign pn2_out_tmp = (enter_calibrate_state ) ? 14'h3fff :
( sb2nbmap_reg == 3'h0 ) ? {ireg_l3[2],ireg_l2[2],ireg_l1[2],ireg_l0[2],ireg_l4[2],ireg_l3[2],ireg_l2[2],ireg_l1[2], ireg_l0[2], ireg_l4[2],ireg_l3[2],ireg_l2[2],ireg_l1[2],ireg_l0[2]} :
( sb2nbmap_reg == 3'h1 ) ? {ireg_l8[2],ireg_l7[2],ireg_l6[2],ireg_l5[2],ireg_l9[2],ireg_l8[2],ireg_l7[2],ireg_l6[2], ireg_l5[2], ireg_l9[2],ireg_l8[2],ireg_l7[2],ireg_l6[2],ireg_l5[2]} :
{ireg_l3[2],ireg_l2[2],ireg_l1[2],ireg_l0[2],ireg_l4[2],ireg_l3[2],ireg_l2[2],ireg_l1[2], ireg_l0[2], ireg_l4[2],ireg_l3[2],ireg_l2[2],ireg_l1[2],ireg_l0[2]};
assign pn3_out_tmp = (enter_calibrate_state ) ? 14'h3fff :
( sb2nbmap_reg == 3'h0 ) ? {ireg_l3[3],ireg_l2[3],ireg_l1[3],ireg_l0[3],ireg_l4[3],ireg_l3[3],ireg_l2[3],ireg_l1[3], ireg_l0[3], ireg_l4[3],ireg_l3[3],ireg_l2[3],ireg_l1[3],ireg_l0[3]} :
( sb2nbmap_reg == 3'h1 ) ? {ireg_l8[3],ireg_l7[3],ireg_l6[3],ireg_l5[3],ireg_l9[3],ireg_l8[3],ireg_l7[3],ireg_l6[3], ireg_l5[3], ireg_l9[3],ireg_l8[3],ireg_l7[3],ireg_l6[3],ireg_l5[3]} :
{ireg_l3[3],ireg_l2[3],ireg_l1[3],ireg_l0[3],ireg_l4[3],ireg_l3[3],ireg_l2[3],ireg_l1[3], ireg_l0[3], ireg_l4[3],ireg_l3[3],ireg_l2[3],ireg_l1[3],ireg_l0[3]};
assign pn4_out_tmp = (enter_calibrate_state ) ? 14'h3fff :
( sb2nbmap_reg == 3'h0 ) ? {ireg_l3[4],ireg_l2[4],ireg_l1[4],ireg_l0[4],ireg_l4[4],ireg_l3[4],ireg_l2[4],ireg_l1[4], ireg_l0[4], ireg_l4[4],ireg_l3[4],ireg_l2[4],ireg_l1[4],ireg_l0[4]} :
( sb2nbmap_reg == 3'h1 ) ? {ireg_l8[4],ireg_l7[4],ireg_l6[4],ireg_l5[4],ireg_l9[4],ireg_l8[4],ireg_l7[4],ireg_l6[4], ireg_l5[4], ireg_l9[4],ireg_l8[4],ireg_l7[4],ireg_l6[4],ireg_l5[4]} :
{ireg_l3[4],ireg_l2[4],ireg_l1[4],ireg_l0[4],ireg_l4[4],ireg_l3[4],ireg_l2[4],ireg_l1[4], ireg_l0[4], ireg_l4[4],ireg_l3[4],ireg_l2[4],ireg_l1[4],ireg_l0[4]};
assign pn5_out_tmp = (enter_calibrate_state ) ? 14'h3fff :
( sb2nbmap_reg == 3'h0 ) ? {ireg_l3[5],ireg_l2[5],ireg_l1[5],ireg_l0[5],ireg_l4[5],ireg_l3[5],ireg_l2[5],ireg_l1[5], ireg_l0[5], ireg_l4[5],ireg_l3[5],ireg_l2[5],ireg_l1[5],ireg_l0[5]} :
( sb2nbmap_reg == 3'h1 ) ? {ireg_l8[5],ireg_l7[5],ireg_l6[5],ireg_l5[5],ireg_l9[5],ireg_l8[5],ireg_l7[5],ireg_l6[5], ireg_l5[5], ireg_l9[5],ireg_l8[5],ireg_l7[5],ireg_l6[5],ireg_l5[5]} :
{ireg_l3[5],ireg_l2[5],ireg_l1[5],ireg_l0[5],ireg_l4[5],ireg_l3[5],ireg_l2[5],ireg_l1[5], ireg_l0[5], ireg_l4[5],ireg_l3[5],ireg_l2[5],ireg_l1[5],ireg_l0[5]};
assign pn6_out_tmp = (enter_calibrate_state ) ? 14'h3fff :
( sb2nbmap_reg == 3'h0 ) ? {ireg_l3[6],ireg_l2[6],ireg_l1[6],ireg_l0[6],ireg_l4[6],ireg_l3[6],ireg_l2[6],ireg_l1[6], ireg_l0[6], ireg_l4[6],ireg_l3[6],ireg_l2[6],ireg_l1[6],ireg_l0[6]} :
( sb2nbmap_reg == 3'h1 ) ? {ireg_l8[6],ireg_l7[6],ireg_l6[6],ireg_l5[6],ireg_l9[6],ireg_l8[6],ireg_l7[6],ireg_l6[6], ireg_l5[6], ireg_l9[6],ireg_l8[6],ireg_l7[6],ireg_l6[6],ireg_l5[6]} :
{ireg_l3[6],ireg_l2[6],ireg_l1[6],ireg_l0[6],ireg_l4[6],ireg_l3[6],ireg_l2[6],ireg_l1[6], ireg_l0[6], ireg_l4[6],ireg_l3[6],ireg_l2[6],ireg_l1[6],ireg_l0[6]};
assign pn7_out_tmp = (enter_calibrate_state ) ? 14'h3fff :
( sb2nbmap_reg == 3'h0 ) ? {ireg_l3[7],ireg_l2[7],ireg_l1[7],ireg_l0[7],ireg_l4[7],ireg_l3[7],ireg_l2[7],ireg_l1[7], ireg_l0[7], ireg_l4[7],ireg_l3[7],ireg_l2[7],ireg_l1[7],ireg_l0[7]} :
( sb2nbmap_reg == 3'h1 ) ? {ireg_l8[7],ireg_l7[7],ireg_l6[7],ireg_l5[7],ireg_l9[7],ireg_l8[7],ireg_l7[7],ireg_l6[7], ireg_l5[7], ireg_l9[7],ireg_l8[7],ireg_l7[7],ireg_l6[7],ireg_l5[7]} :
{ireg_l3[7],ireg_l2[7],ireg_l1[7],ireg_l0[7],ireg_l4[7],ireg_l3[7],ireg_l2[7],ireg_l1[7], ireg_l0[7], ireg_l4[7],ireg_l3[7],ireg_l2[7],ireg_l1[7],ireg_l0[7]};
assign pn8_out_tmp = (enter_calibrate_state ) ? 14'h3fff :
( sb2nbmap_reg == 3'h0 ) ? {ireg_l3[8],ireg_l2[8],ireg_l1[8],ireg_l0[8],ireg_l4[8],ireg_l3[8],ireg_l2[8],ireg_l1[8], ireg_l0[8], ireg_l4[8],ireg_l3[8],ireg_l2[8],ireg_l1[8],ireg_l0[8]} :
( sb2nbmap_reg == 3'h1 ) ? {ireg_l8[8],ireg_l7[8],ireg_l6[8],ireg_l5[8],ireg_l9[8],ireg_l8[8],ireg_l7[8],ireg_l6[8], ireg_l5[8], ireg_l9[8],ireg_l8[8],ireg_l7[8],ireg_l6[8],ireg_l5[8]} :
{ireg_l3[8],ireg_l2[8],ireg_l1[8],ireg_l0[8],ireg_l4[8],ireg_l3[8],ireg_l2[8],ireg_l1[8], ireg_l0[8], ireg_l4[8],ireg_l3[8],ireg_l2[8],ireg_l1[8],ireg_l0[8]};
assign pn9_out_tmp = (enter_calibrate_state ) ? 14'h3fff :
( sb2nbmap_reg == 3'h0 ) ? {ireg_l3[9],ireg_l2[9],ireg_l1[9],ireg_l0[9],ireg_l4[9],ireg_l3[9],ireg_l2[9],ireg_l1[9], ireg_l0[9], ireg_l4[9],ireg_l3[9],ireg_l2[9],ireg_l1[9],ireg_l0[9]} :
( sb2nbmap_reg == 3'h1 ) ? {ireg_l8[9],ireg_l7[9],ireg_l6[9],ireg_l5[9],ireg_l9[9],ireg_l8[9],ireg_l7[9],ireg_l6[9], ireg_l5[9], ireg_l9[9],ireg_l8[9],ireg_l7[9],ireg_l6[9],ireg_l5[9]} :
{ireg_l3[9],ireg_l2[9],ireg_l1[9],ireg_l0[9],ireg_l4[9],ireg_l3[9],ireg_l2[9],ireg_l1[9], ireg_l0[9], ireg_l4[9],ireg_l3[9],ireg_l2[9],ireg_l1[9],ireg_l0[9]};
assign pn10_out_tmp = (enter_calibrate_state ) ? 14'h3fff :
( sb2nbmap_reg == 3'h0 ) ? {ireg_l3[10],ireg_l2[10],ireg_l1[10],ireg_l0[10],ireg_l4[10],ireg_l3[10],ireg_l2[10],ireg_l1[10], ireg_l0[10], ireg_l4[10],ireg_l3[10],ireg_l2[10],ireg_l1[10],ireg_l0[10]} :
( sb2nbmap_reg == 3'h1 ) ? {ireg_l8[10],ireg_l7[10],ireg_l6[10],ireg_l5[10],ireg_l9[10],ireg_l8[10],ireg_l7[10],ireg_l6[10], ireg_l5[10], ireg_l9[10],ireg_l8[10],ireg_l7[10],ireg_l6[10],ireg_l5[10]} :
{ireg_l3[10],ireg_l2[10],ireg_l1[10],ireg_l0[10],ireg_l4[10],ireg_l3[10],ireg_l2[10],ireg_l1[10], ireg_l0[10], ireg_l4[10],ireg_l3[10],ireg_l2[10],ireg_l1[10],ireg_l0[10]};
assign pn11_out_tmp = (enter_calibrate_state ) ? 14'h3fff :
( sb2nbmap_reg == 3'h0 ) ? {ireg_l3[11],ireg_l2[11],ireg_l1[11],ireg_l0[11],ireg_l4[11],ireg_l3[11],ireg_l2[11],ireg_l1[11], ireg_l0[11], ireg_l4[11],ireg_l3[11],ireg_l2[11],ireg_l1[11],ireg_l0[11]} :
( sb2nbmap_reg == 3'h1 ) ? {ireg_l8[11],ireg_l7[11],ireg_l6[11],ireg_l5[11],ireg_l9[11],ireg_l8[11],ireg_l7[11],ireg_l6[11], ireg_l5[11], ireg_l9[11],ireg_l8[11],ireg_l7[11],ireg_l6[11],ireg_l5[11]} :
{ireg_l3[11],ireg_l2[11],ireg_l1[11],ireg_l0[11],ireg_l4[11],ireg_l3[11],ireg_l2[11],ireg_l1[11], ireg_l0[11], ireg_l4[11],ireg_l3[11],ireg_l2[11],ireg_l1[11],ireg_l0[11]};
shifter_p #(NB_LINK) shft0 (.signal_in ( pn0_out_tmp),
.delay_cycles (delay_reg),
.clk ( frm_boundary_fast));
shifter_p #(NB_LINK) shft1 (.signal_in ( pn1_out_tmp),
.delay_cycles (delay_reg),
.clk ( frm_boundary_fast));
shifter_p #(NB_LINK) shft2 (.signal_in ( pn2_out_tmp),
.delay_cycles (delay_reg),
.clk (frm_boundary_fast));
shifter_p #(NB_LINK) shft3 (.signal_in ( pn3_out_tmp),
.delay_cycles (delay_reg),
.clk (frm_boundary_fast));
shifter_p #(NB_LINK) shft4 (.signal_in ( pn4_out_tmp),
.delay_cycles (delay_reg),
.clk ( frm_boundary_fast));
shifter_p #(NB_LINK) shft5 (.signal_in ( pn5_out_tmp),
.delay_cycles (delay_reg),
.clk ( frm_boundary_fast));
shifter_p #(NB_LINK) shft6 (.signal_in ( pn6_out_tmp),
.delay_cycles (delay_reg),
.clk ( frm_boundary_fast));
shifter_p #(NB_LINK) shft7 (.signal_in ( pn7_out_tmp),
.delay_cycles (delay_reg),
.clk ( frm_boundary_fast));
shifter_p #(NB_LINK) shft8 (.signal_in ( pn8_out_tmp),
.delay_cycles (delay_reg),
.clk ( frm_boundary_fast));
shifter_p #(NB_LINK) shft9 (.signal_in ( pn9_out_tmp),
.delay_cycles (delay_reg),
.clk ( frm_boundary_fast));
shifter_p #(NB_LINK) shft10 (.signal_in ( pn10_out_tmp),
.delay_cycles (delay_reg),
.clk ( frm_boundary_fast));
shifter_p #(NB_LINK) shft11 (.signal_in ( pn11_out_tmp),
.delay_cycles (delay_reg),
.clk ( frm_boundary_fast));
enter_calibrate_state = 0;
assign pn = ( enter_calibrate_state ) ? 14'h3fff : pn_init ;
assign pn_bar = ( curr_state == `AMB_INIT_DISABLE ) ? pn : ~pn;
assign frm_start= frm_boundary; //|frm_align[13:0];
assign ps_in_bar = ps_bar;
voting_logic mod_detect_test_hdr_2of3(.a ( (ireg_l0[23:12] == 12'hffe ) ),
.b ( (ireg_l1[23:12] == 12'hffe ) ),
.c ( (ireg_l2[23:12] == 12'hffe ) ),
.out ( detect_test_hdr_2of3 ));
voting_logic mod_detect_cfg_hdr_2of3(.a ( (ireg_l0[23:12] == 12'h3fe ) ),
.b ( (ireg_l1[23:12] == 12'h3fe ) ),
.c ( (ireg_l2[23:12] == 12'h3fe ) ),
.out ( detect_cfg_hdr_2of3 ));
voting_logic mod_detect_poll_hdr_2of3(.a ( (ireg_l0[23:12] == 12'h7fe ) ),
.b ( (ireg_l1[23:12] == 12'h7fe ) ),
.c ( (ireg_l2[23:12] == 12'h7fe ) ),
.out ( detect_poll_hdr_2of3 ));