data/full_repos/permissive/208113388/afu/afp/afp3_eng_rtry_queue.v
1: b"%Error: data/full_repos/permissive/208113388/afu/afp/afp3_eng_rtry_queue.v:376: Cannot find file containing module: 'afp3_ram1024x018'\n  afp3_ram1024x018  rtry_queue\n  ^~~~~~~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/208113388/afu/afp,data/full_repos/permissive/208113388/afp3_ram1024x018\n             data/full_repos/permissive/208113388/afu/afp,data/full_repos/permissive/208113388/afp3_ram1024x018.v\n             data/full_repos/permissive/208113388/afu/afp,data/full_repos/permissive/208113388/afp3_ram1024x018.sv\n             afp3_ram1024x018\n             afp3_ram1024x018.v\n             afp3_ram1024x018.sv\n             obj_dir/afp3_ram1024x018\n             obj_dir/afp3_ram1024x018.v\n             obj_dir/afp3_ram1024x018.sv\n%Error: data/full_repos/permissive/208113388/afu/afp/afp3_eng_rtry_queue.v:583: Cannot find file containing module: 'afp3_ram1024x004'\n  afp3_ram1024x004  resp_code_ary\n  ^~~~~~~~~~~~~~~~\n%Error: Exiting due to 2 error(s)\n"
module afp3_eng_rtry_queue
  (

    input                 clock                                           
  , input                 reset


  , input                 xtouch_wt4rsp_enable_q
  , input                 mmio_eng_capture_all_resp_code_enable


  , input                 main_idle_st


  , input                 rspi_eng_resp_valid
  , input           [7:0] rspi_eng_resp_opcode
  , input                 rspi_resp_is_rtry
  , input                 rspi_resp_is_xtouch_rtry
  , input                 rspi_resp_is_cpy_xx_q
  , input                 rspi_resp_is_cpy_st_q
  , input           [8:0] rspi_resp_afutag_q
  , input           [1:0] rspi_resp_dl_orig_q
  , input           [1:0] rspi_resp_dl_q
  , input           [1:0] rspi_resp_dp_q
  , input           [3:0] rspi_resp_code_q
  , input                 rspi_resp_is_pending_q
  , input                 rspi_resp_is_rtry_lwt_q
  , input                 rspi_resp_is_rtry_req_q
  , input                 rspi_resp_is_rtry_hwt_q


  , input                 we_ld_wt4rsp_st
  , input                 xtouch_wt4rsp_st
  , input                 cpy_ld_wt4rsp_st
  , input                 cpy_st_wt4rsp_st
  , input                 wkhstthrd_wt4rsp_st
  , input                 incr_wt4ldrsp_st
  , input                 incr_wt4strsp_st
  , input                 atomic_wt4rsp_st
  , input                 intrpt_wt4rsp_st
  , input                 we_st_wt4rsp_st

  , input                 we_rtry_ld_idle_st
  , input                 xtouch_rtry_idle_st
  , input                 cpy_rtry_ld_idle_st
  , input                 cpy_rtry_st_idle_st
  , input                 wkhstthrd_rtry_idle_st
  , input                 incr_rtry_idle_st
  , input                 atomic_rtry_idle_st
  , input                 we_rtry_st_idle_st

  ,`ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
    input           [4:0] pending_cnt_q


  , input                 start_eng_display_seq
  , input                 eng_display_idle_st


  , input                 eng_display_rtry_queue_rden
  , input           [9:0] eng_display_addr_q


  , output                rtry_queue_empty
  , output                rtry_queue_func_rden_dly2_q
  , output                rtry_queue_cpy_xx_q
  , output                rtry_queue_cpy_st_q
  , output          [8:0] rtry_queue_afutag_q     
  , output          [1:0] rtry_queue_dl_q         
  , output                rtry_queue_is_pending_q
  , output                rtry_queue_is_rtry_lwt_q
  , output                rtry_queue_is_rtry_req_q
  , output                rtry_queue_is_rtry_hwt_q

  , output                resp_code_is_done
  , output                resp_code_is_rty_req
  , output                resp_code_is_failed
  , output                resp_code_is_adr_error


  , output          [8:0] cpy_rtry_xx_afutag_q
  , output reg            cpy_rtry_xx_cpy_st_q
  , output reg      [1:0] cpy_rtry_xx_dl_q
  , output reg            cpy_rtry_st_size_256_q




  , output                rtry_queue_func_rden_blocker

  ,`ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
    output         [10:0] rtry_queue_rdaddr_q
  ,`ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
    output         [10:0] rtry_queue_wraddr_q
  ,`ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
    output         [17:0] rtry_queue_rddata
  ,`ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
    output          [3:0] resp_code_rddata                 

  );






 `ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
  wire            rtry_queue_empty_int;
 `ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
  wire            rtry_queue_full;
  wire            rtry_queue_last_wraddr;
  wire            rtry_queue_last_rdaddr;
  reg       [3:0] rtry_queue_wr_sel;
  wire            rtry_queue_wren;
  wire            rtry_is_128B_2nd_half;
  wire      [9:0] new_afutag;
  wire     [17:0] rtry_queue_wrdata;
  wire            rtry_queue_func_rden_blocker_int;
  wire            rtry_queue_func_rden;
  reg             rtry_queue_rden;
  reg       [9:0] rtry_queue_rdaddr;
  reg       [2:0] rtry_queue_rd_sel;
 `ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
  wire     [17:0] rtry_queue_rddata_int;




  reg             resp_code_wren;
  wire      [9:0] resp_code_wraddr;
  wire      [3:0] resp_code_wrdata;
  reg             resp_code_rden;
  reg       [9:0] resp_code_rdaddr;
 `ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
  wire      [3:0] resp_code_rddata_int;


  wire     [10:0] rtry_queue_size;
  wire            rtry_queue_wrap_match;
  wire     [10:0] rtry_queue_tl_mn_hd;
  wire     [10:0] rtry_queue_tl_pl_arysz_mn_hd;






  wire            mmio_eng_capture_all_resp_code_enable_d;
  reg             mmio_eng_capture_all_resp_code_enable_q;

  wire            rspi_eng_resp_valid_d;
  reg             rspi_eng_resp_valid_q;


  wire            rspi_resp_is_xlate_done_d;
  reg             rspi_resp_is_xlate_done_q;

  wire            rspi_resp_is_intrp_rdy_d;
  reg             rspi_resp_is_intrp_rdy_q;


  wire            rtry_valid_d;
  reg             rtry_valid_q;
  reg      [10:0] rtry_queue_wraddr_int_d;
 `ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
  reg      [10:0] rtry_queue_wraddr_int_q;
  reg      [10:0] rtry_queue_rdaddr_int_d;
 `ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
  reg      [10:0] rtry_queue_rdaddr_int_q;
  wire            rtry_queue_func_rden_dly1_int_d;
  reg             rtry_queue_func_rden_dly1_int_q;
  wire            rtry_queue_func_rden_dly2_int_d;
  reg             rtry_queue_func_rden_dly2_int_q;

  wire            rtry_queue_capture_en;
  wire            rtry_queue_cpy_xx_int_d;
  reg             rtry_queue_cpy_xx_int_q;
  wire            rtry_queue_cpy_st_int_d;
  reg             rtry_queue_cpy_st_int_q;
  wire      [9:0] rtry_queue_afutag_int_d;
  reg       [9:0] rtry_queue_afutag_int_q;
  wire      [1:0] rtry_queue_dl_int_d;
  reg       [1:0] rtry_queue_dl_int_q;
  wire            rtry_queue_is_pending_int_d;
  reg             rtry_queue_is_pending_int_q;
  wire            rtry_queue_is_rtry_lwt_int_d;
  reg             rtry_queue_is_rtry_lwt_int_q;
  wire            rtry_queue_is_rtry_req_int_d;
  reg             rtry_queue_is_rtry_req_int_q;
  wire            rtry_queue_is_rtry_hwt_int_d;
  reg             rtry_queue_is_rtry_hwt_int_q;

  wire      [8:0] cpy_rtry_xx_afutag_int_d;
  reg       [8:0] cpy_rtry_xx_afutag_int_q;
  wire            cpy_rtry_xx_cpy_st_d;

  wire      [1:0] cpy_rtry_xx_dl_d;

  reg             cpy_rtry_st_size_256_d;







  reg      [10:0] rtry_queue_numentriesval_d;
 `ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
  reg      [10:0] rtry_queue_numentriesval_q;
  reg      [10:0] rtry_queue_maxqdepth_d;
 `ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
  reg      [10:0] rtry_queue_maxqdepth_q;

  wire            rtry_wr_count_en;
  reg      [31:0] rtry_wr_count_d;
 `ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
  reg      [31:0] rtry_wr_count_q;

  wire            rtry_rd_count_en;
  reg      [31:0] rtry_rd_count_d;
 `ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
  reg      [31:0] rtry_rd_count_q;

  wire            rtry_pending_count_en;
  reg      [31:0] rtry_pending_count_d;
 `ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
  reg      [31:0] rtry_pending_count_q;

  wire            rtry_req_count_en;
  reg      [31:0] rtry_req_count_d;
 `ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
  reg      [31:0] rtry_req_count_q;

  wire            rtry_hwt_count_en;
  reg      [31:0] rtry_hwt_count_d;
 `ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
  reg      [31:0] rtry_hwt_count_q;

  wire            rtry_lwt_count_en;
  reg      [31:0] rtry_lwt_count_d;
 `ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
  reg      [31:0] rtry_lwt_count_q;







  localparam    [7:0] TLX_AFU_RESP_ENCODE_XLATE_DONE           = 8'b00011000;
  localparam    [7:0] TLX_AFU_RESP_ENCODE_INTRP_RDY            = 8'b00011010;


  localparam    [3:0] TLX_AFU_RESP_CODE_DONE                   = 4'b0000;
  localparam    [3:0] TLX_AFU_RESP_CODE_RTY_HWT                = 4'b0001;
  localparam    [3:0] TLX_AFU_RESP_CODE_RTY_REQ                = 4'b0010;
  localparam    [3:0] TLX_AFU_RESP_CODE_LW_RTY_REQ             = 4'b0011;
  localparam    [3:0] TLX_AFU_RESP_CODE_XLATE_PENDING          = 4'b0100;
  localparam    [3:0] TLX_AFU_RESP_CODE_INTRP_PENDING          = 4'b0100;
  localparam    [3:0] TLX_AFU_RESP_CODE_THREAD_NOT_FOUND       = 4'b0100;
  localparam    [3:0] TLX_AFU_RESP_CODE_DERROR                 = 4'b1000;
  localparam    [3:0] TLX_AFU_RESP_CODE_BAD_LENGTH             = 4'b1001;
  localparam    [3:0] TLX_AFU_RESP_CODE_BAD_ADDR               = 4'b1011;
  localparam    [3:0] TLX_AFU_RESP_CODE_BAD_HANDLE             = 4'b1011;
  localparam    [3:0] TLX_AFU_RESP_CODE_FAILED                 = 4'b1110;
  localparam    [3:0] TLX_AFU_RESP_CODE_ADR_ERROR              = 4'b1111;






  assign  mmio_eng_capture_all_resp_code_enable_d =  mmio_eng_capture_all_resp_code_enable;










  assign  rtry_valid_d =  ( rspi_resp_is_rtry && ~( rspi_resp_is_xtouch_rtry && ~xtouch_wt4rsp_enable_q ));


  assign  rtry_queue_empty_int =  (( rtry_queue_wraddr_int_q[9:0] == rtry_queue_rdaddr_int_q[9:0] ) && ( rtry_queue_wraddr_int_q[10] == rtry_queue_rdaddr_int_q[10] ));
  assign  rtry_queue_full      =  (( rtry_queue_wraddr_int_q[9:0] == rtry_queue_rdaddr_int_q[9:0] ) && ( rtry_queue_wraddr_int_q[10] != rtry_queue_rdaddr_int_q[10] ));


  assign  rtry_queue_last_wraddr =  ( rtry_queue_wraddr_int_q[9:0] == 10'b11_1111_1111 );
  assign  rtry_queue_last_rdaddr =  ( rtry_queue_rdaddr_int_q[9:0] == 10'b11_1111_1111 );


  assign  rtry_queue_wren = ( ~reset && ~rtry_queue_full && rtry_valid_q );



  assign  rtry_wr_count_en = ( reset || main_idle_st || rtry_queue_wren );

  always @*
    begin
      if ( reset || main_idle_st )
        rtry_wr_count_d[31:0] =  32'b0;
      else if ( rtry_queue_wren && ~( rtry_wr_count_q[31:0] == 32'hFFFFFFFF ))
        rtry_wr_count_d[31:0] = ( rtry_wr_count_q[31:0] + 32'b1 );
      else
        rtry_wr_count_d[31:0] =   rtry_wr_count_q[31:0];
    end


  always @*
    begin
      rtry_queue_wr_sel[3:0] =  { ( reset || main_idle_st ), rtry_queue_full, rtry_valid_q, rtry_queue_last_wraddr };

      casez ( rtry_queue_wr_sel[3:0] )







            4'b1??? :  rtry_queue_wraddr_int_d[10:0] =  {                        1'b0,                           10'b0           };
            4'b01?? :  rtry_queue_wraddr_int_d[10:0] =  {  rtry_queue_wraddr_int_q[10],   rtry_queue_wraddr_int_q[9:0]           };
            4'b0010 :  rtry_queue_wraddr_int_d[10:0] =  {  rtry_queue_wraddr_int_q[10], ( rtry_queue_wraddr_int_q[9:0] + 10'b1 ) };
            4'b0011 :  rtry_queue_wraddr_int_d[10:0] =  { ~rtry_queue_wraddr_int_q[10],                          10'b0           };

            default :  rtry_queue_wraddr_int_d[10:0] =  {  rtry_queue_wraddr_int_q[10],   rtry_queue_wraddr_int_q[9:0]           };

      endcase
    end


  assign  rtry_is_128B_2nd_half  =  rspi_resp_is_cpy_xx_q  &
                                   (rspi_resp_dl_q[1:0] == 2'b10) &
                                   (rspi_resp_dl_orig_q[1:0] == 2'b11) &
                                   (rspi_resp_dp_q[1] == 1'b1);

  assign  new_afutag[9:0]  = {1'b1, rspi_resp_afutag_q[8:1], (rspi_resp_afutag_q[0] | rtry_is_128B_2nd_half)};


  assign  rtry_queue_wrdata[17]    =  rspi_resp_is_cpy_xx_q;
  assign  rtry_queue_wrdata[16]    =  rspi_resp_is_cpy_st_q;
  assign  rtry_queue_wrdata[15:6]  =  new_afutag[9:0];
  assign  rtry_queue_wrdata[5:4]   =  rspi_resp_dl_q[1:0];
  assign  rtry_queue_wrdata[3]     =  rspi_resp_is_pending_q;
  assign  rtry_queue_wrdata[2]     =  rspi_resp_is_rtry_lwt_q;
  assign  rtry_queue_wrdata[1]     =  rspi_resp_is_rtry_req_q;
  assign  rtry_queue_wrdata[0]     =  rspi_resp_is_rtry_hwt_q;



  afp3_ram1024x018  rtry_queue
    ( .clk   ( clock ),

      .wren  ( rtry_queue_wren ),
      .wrad  ( rtry_queue_wraddr_int_q[9:0] ),
      .data  ( rtry_queue_wrdata[17:0] ),

      .rden  ( rtry_queue_rden ),
      .rdad  ( rtry_queue_rdaddr[9:0] ),
      .q     ( rtry_queue_rddata_int[17:0] )
    );










  assign  rtry_queue_func_rden_blocker_int =  ~( we_ld_wt4rsp_st ||
                                                xtouch_wt4rsp_st ||
                                                cpy_ld_wt4rsp_st ||
                                                cpy_st_wt4rsp_st ||
                                             wkhstthrd_wt4rsp_st ||
                                                incr_wt4ldrsp_st ||
                                                incr_wt4strsp_st ||
                                                atomic_wt4rsp_st ||
                                                intrpt_wt4rsp_st ||
                                                 we_st_wt4rsp_st )  ||
                            
                               ( rtry_queue_func_rden_dly1_int_q ||
                                 rtry_queue_func_rden_dly2_int_q )  ||  
             
                                           ( ~we_rtry_ld_idle_st ||
                                            ~xtouch_rtry_idle_st ||
                                            ~cpy_rtry_ld_idle_st ||
                                            ~cpy_rtry_st_idle_st ||
                                         ~wkhstthrd_rtry_idle_st ||
                                              ~incr_rtry_idle_st ||
                                            ~atomic_rtry_idle_st ||
                                             ~we_rtry_st_idle_st )  || 
             
                                   ~( pending_cnt_q[4:0] == 5'b0 );

  assign  rtry_queue_func_rden            = ~rtry_queue_empty_int && ~rtry_queue_func_rden_blocker_int && ~reset && ~start_eng_display_seq && eng_display_idle_st;
  assign  rtry_queue_func_rden_dly1_int_d =  rtry_queue_func_rden;
  assign  rtry_queue_func_rden_dly2_int_d =  rtry_queue_func_rden_dly1_int_q;


  assign  rtry_rd_count_en = ( reset || main_idle_st || rtry_queue_func_rden );
  always @*
    begin
      if ( reset || main_idle_st )
        rtry_rd_count_d[31:0] =  32'b0;
      else if (  rtry_queue_func_rden && ~( rtry_rd_count_q[31:0] == 32'hFFFFFFFF ))
        rtry_rd_count_d[31:0] = ( rtry_rd_count_q[31:0] + 32'b1 );
      else
        rtry_rd_count_d[31:0] =   rtry_rd_count_q[31:0];
    end


  always @*
    begin

      if ( start_eng_display_seq || ~eng_display_idle_st )
        begin
          rtry_queue_rden        =  eng_display_rtry_queue_rden;
          rtry_queue_rdaddr[9:0] =  eng_display_addr_q[9:0];
        end
      else
        begin
          rtry_queue_rden        =  rtry_queue_func_rden;
          rtry_queue_rdaddr[9:0] =  rtry_queue_rdaddr_int_q[9:0]; 
        end


      rtry_queue_rd_sel[2:0] =  { ( reset || main_idle_st ), rtry_queue_func_rden, rtry_queue_last_rdaddr };

      casez ( rtry_queue_rd_sel[2:0] )






            3'b1?? :  rtry_queue_rdaddr_int_d[10:0] =  {                    1'b0,                              10'b0            };
            3'b010 :  rtry_queue_rdaddr_int_d[10:0] =  {  rtry_queue_rdaddr_int_q[10], ( rtry_queue_rdaddr_int_q[9:0] + 10'b1 ) };
            3'b011 :  rtry_queue_rdaddr_int_d[10:0] =  { ~rtry_queue_rdaddr_int_q[10],                         10'b0            };

           default :  rtry_queue_rdaddr_int_d[10:0] =  {  rtry_queue_rdaddr_int_q[10],   rtry_queue_rdaddr_int_q[9:0]           };

      endcase

    end


  assign  rtry_queue_capture_en         =  rtry_queue_func_rden_dly1_int_q;
  assign  rtry_queue_cpy_xx_int_d       =  rtry_queue_rddata_int[17];
  assign  rtry_queue_cpy_st_int_d       =  rtry_queue_rddata_int[16];
  assign  rtry_queue_afutag_int_d[9:0]  =  rtry_queue_rddata_int[15:6];
  assign  rtry_queue_dl_int_d[1:0]      =  rtry_queue_rddata_int[5:4];
  assign  rtry_queue_is_pending_int_d   =  rtry_queue_rddata_int[3];
  assign  rtry_queue_is_rtry_lwt_int_d  =  rtry_queue_rddata_int[2];
  assign  rtry_queue_is_rtry_req_int_d  =  rtry_queue_rddata_int[1];
  assign  rtry_queue_is_rtry_hwt_int_d  =  rtry_queue_rddata_int[0];



  assign  cpy_rtry_xx_afutag_int_d[8:0] =  rtry_queue_afutag_int_q[8:0];
  assign  cpy_rtry_xx_cpy_st_d          =  rtry_queue_cpy_st_int_q;
  assign  cpy_rtry_xx_dl_d[1:0]         =  rtry_queue_dl_int_q[1:0];



  always @*
    begin
      if ( cpy_rtry_xx_dl_d[1:0] == 2'b11 )
        cpy_rtry_st_size_256_d  =  1'b1;
      else
        cpy_rtry_st_size_256_d  = 1'b0;
    end





  assign  rtry_queue_size[10:0] =  11'b10000000000;


  assign  rtry_queue_wrap_match =  ( rtry_queue_rdaddr_int_q[10] == rtry_queue_wraddr_int_q[10] );


  assign  rtry_queue_tl_mn_hd[10:0]          =  ( { 1'b0, rtry_queue_wraddr_int_q[9:0] } - { 1'b0, rtry_queue_rdaddr_int_q[9:0] } );


  assign  rtry_queue_tl_pl_arysz_mn_hd[10:0] =  ( { 1'b0, rtry_queue_wraddr_int_q[9:0] } + ( rtry_queue_size[10:0] - { 1'b0, rtry_queue_rdaddr_int_q[9:0] } ));

  always @*
    begin

      if ( rtry_queue_wrap_match )
        rtry_queue_numentriesval_d[10:0] =  rtry_queue_tl_mn_hd[10:0];
      else
        rtry_queue_numentriesval_d[10:0] =  rtry_queue_tl_pl_arysz_mn_hd[10:0];


      if ( reset || main_idle_st )
        rtry_queue_maxqdepth_d[10:0] =  11'b0;
      else if  ( rtry_queue_numentriesval_q[10:0] > rtry_queue_maxqdepth_q[10:0] )
        rtry_queue_maxqdepth_d[10:0] =  rtry_queue_numentriesval_q[10:0];
      else
        rtry_queue_maxqdepth_d[10:0] =  rtry_queue_maxqdepth_q[10:0];

    end






  assign  rspi_eng_resp_valid_d =  rspi_eng_resp_valid;


  assign  rspi_resp_is_xlate_done_d          =  ( rspi_eng_resp_opcode[7:0] == TLX_AFU_RESP_ENCODE_XLATE_DONE[7:0]     );
  assign  rspi_resp_is_intrp_rdy_d           =  ( rspi_eng_resp_opcode[7:0] == TLX_AFU_RESP_ENCODE_INTRP_RDY[7:0]      );

  always @*
    begin
     if (mmio_eng_capture_all_resp_code_enable_q )
       resp_code_wren        =  rspi_eng_resp_valid_q;
     else
       resp_code_wren        =  rspi_eng_resp_valid_q && ( rspi_resp_is_xlate_done_q || rspi_resp_is_intrp_rdy_q );
    end

  assign  resp_code_wraddr[9:0] =  { rspi_resp_is_cpy_st_q, rspi_resp_afutag_q[8:0] };
  assign  resp_code_wrdata[3:0] =  rspi_resp_code_q[3:0];

  always @*
    begin
     if ( main_idle_st )
       begin 
         resp_code_rden        =  eng_display_rtry_queue_rden;
         resp_code_rdaddr[9:0] =  eng_display_addr_q[9:0]; 
       end
     else
       begin 
         resp_code_rden        =  rtry_queue_func_rden_dly1_int_q;
	 resp_code_rdaddr[9:0] =  { rtry_queue_cpy_st_int_d, rtry_queue_afutag_int_d[8:0]} ;

       end
    end



  afp3_ram1024x004  resp_code_ary
    ( .clk   ( clock ),

      .wren  ( resp_code_wren ),
      .wrad  ( resp_code_wraddr[9:0] ),
      .data  ( resp_code_wrdata[3:0] ),

      .rden  ( resp_code_rden ),
      .rdad  ( resp_code_rdaddr[9:0] ),
      .q     ( resp_code_rddata_int[3:0] )
    );



  assign  resp_code_is_done      =  ( resp_code_rddata_int[3:0] == TLX_AFU_RESP_CODE_DONE[3:0]      );
  assign  resp_code_is_rty_req   =  ( resp_code_rddata_int[3:0] == TLX_AFU_RESP_CODE_RTY_REQ[3:0]   );
  assign  resp_code_is_failed    =  ( resp_code_rddata_int[3:0] == TLX_AFU_RESP_CODE_FAILED[3:0]    );
  assign  resp_code_is_adr_error =  ( resp_code_rddata_int[3:0] == TLX_AFU_RESP_CODE_ADR_ERROR[3:0] );






  assign  rtry_queue_func_rden_dly2_q =  rtry_queue_func_rden_dly2_int_q;
  assign  rtry_queue_cpy_xx_q         =  rtry_queue_cpy_xx_int_q;
  assign  rtry_queue_cpy_st_q         =  rtry_queue_cpy_st_int_q;
  assign  rtry_queue_afutag_q[8:0]    =  rtry_queue_afutag_int_q[8:0];       
  assign  rtry_queue_dl_q[1:0]        =  rtry_queue_dl_int_q[1:0];           
  assign  rtry_queue_is_pending_q     =  rtry_queue_is_pending_int_q;
  assign  rtry_queue_is_rtry_lwt_q    =  rtry_queue_is_rtry_lwt_int_q;
  assign  rtry_queue_is_rtry_req_q    =  rtry_queue_is_rtry_req_int_q;
  assign  rtry_queue_is_rtry_hwt_q    =  rtry_queue_is_rtry_hwt_int_q;


  assign  rtry_pending_count_en = ( reset || main_idle_st || ( rtry_queue_func_rden_dly2_int_q && rtry_queue_is_pending_int_q ));

  always @*
    begin
      if ( reset || main_idle_st )
        rtry_pending_count_d[31:0] = 32'b0;
      else if ( rtry_queue_func_rden_dly2_int_q && rtry_queue_is_pending_int_q && ~( rtry_pending_count_q[31:0] == 32'hFFFFFFFF ))
        rtry_pending_count_d[31:0] = ( rtry_pending_count_q[31:0] + 32'b1 );
      else
        rtry_pending_count_d[31:0] =   rtry_pending_count_q[31:0];
    end


  assign  rtry_req_count_en = ( reset || main_idle_st || ( rtry_queue_func_rden_dly2_int_q && rtry_queue_is_rtry_req_int_q ));

  always @*
    begin
      if ( reset || main_idle_st )
        rtry_req_count_d[31:0] =  32'b0;
      else if ( rtry_queue_func_rden_dly2_int_q && rtry_queue_is_rtry_req_int_q && ~( rtry_req_count_q[31:0] == 32'hFFFFFFFF ))
        rtry_req_count_d[31:0] = ( rtry_req_count_q[31:0] + 32'b1 );
      else
        rtry_req_count_d[31:0] =   rtry_req_count_q[31:0];
    end

  assign  rtry_hwt_count_en = ( reset || main_idle_st || ( rtry_queue_func_rden_dly2_int_q && rtry_queue_is_rtry_hwt_int_q ));

  always @*
    begin
      if ( reset || main_idle_st )
        rtry_hwt_count_d[31:0] =  32'b0;
      else if ( rtry_queue_func_rden_dly2_int_q && rtry_queue_is_rtry_hwt_int_q && ~( rtry_hwt_count_q[31:0] == 32'hFFFFFFFF ))
        rtry_hwt_count_d[31:0] = ( rtry_hwt_count_q[31:0] + 32'b1 );
      else
        rtry_hwt_count_d[31:0] =   rtry_hwt_count_q[31:0];
    end


  assign  rtry_lwt_count_en = ( reset || main_idle_st || ( rtry_queue_func_rden_dly2_int_q && rtry_queue_is_rtry_lwt_int_q ));

  always @*
    begin
      if ( reset || main_idle_st )
        rtry_lwt_count_d[31:0] =  32'b0;
      else if ( rtry_queue_func_rden_dly2_int_q && rtry_queue_is_rtry_lwt_int_q && ~( rtry_lwt_count_q[31:0] == 32'hFFFFFFFF ))
        rtry_lwt_count_d[31:0] = ( rtry_lwt_count_q[31:0] + 32'b1 );
      else
        rtry_lwt_count_d[31:0] =   rtry_lwt_count_q[31:0];
    end








  assign  cpy_rtry_xx_afutag_q[8:0]   =  cpy_rtry_xx_afutag_int_q[8:0];






  assign  rtry_queue_empty          =  rtry_queue_empty_int;






  assign  rtry_queue_func_rden_blocker =  rtry_queue_func_rden_blocker_int;
  assign  rtry_queue_rdaddr_q[10:0]    =  rtry_queue_rdaddr_int_q[10:0];
  assign  rtry_queue_wraddr_q[10:0]    =  rtry_queue_wraddr_int_q[10:0];
  assign  rtry_queue_rddata[17:0]      =  rtry_queue_rddata_int[17:0];
  assign  resp_code_rddata[3:0]        =  resp_code_rddata_int[3:0];













  always @ ( posedge clock )
    begin
      mmio_eng_capture_all_resp_code_enable_q     <= mmio_eng_capture_all_resp_code_enable_d;

      rspi_eng_resp_valid_q                       <= rspi_eng_resp_valid_d;

      rspi_resp_is_xlate_done_q                   <= rspi_resp_is_xlate_done_d;
      rspi_resp_is_intrp_rdy_q                    <= rspi_resp_is_intrp_rdy_d;

      rtry_valid_q                                <= rtry_valid_d;
      rtry_queue_wraddr_int_q[10:0]               <= rtry_queue_wraddr_int_d[10:0];     
      rtry_queue_rdaddr_int_q[10:0]               <= rtry_queue_rdaddr_int_d[10:0];     
      rtry_queue_func_rden_dly1_int_q             <= rtry_queue_func_rden_dly1_int_d;       
      rtry_queue_func_rden_dly2_int_q             <= rtry_queue_func_rden_dly2_int_d;
      if ( rtry_queue_capture_en )
        begin      
          rtry_queue_cpy_xx_int_q                 <= rtry_queue_cpy_xx_int_d;     
          rtry_queue_cpy_st_int_q                 <= rtry_queue_cpy_st_int_d;     
          rtry_queue_afutag_int_q[9:0]            <= rtry_queue_afutag_int_d[9:0];     
          rtry_queue_dl_int_q[1:0]                <= rtry_queue_dl_int_d[1:0];         
          rtry_queue_is_pending_int_q             <= rtry_queue_is_pending_int_d; 
          rtry_queue_is_rtry_lwt_int_q            <= rtry_queue_is_rtry_lwt_int_d; 
          rtry_queue_is_rtry_req_int_q            <= rtry_queue_is_rtry_req_int_d; 
          rtry_queue_is_rtry_hwt_int_q            <= rtry_queue_is_rtry_hwt_int_d;
        end
      cpy_rtry_xx_afutag_int_q[8:0]               <= cpy_rtry_xx_afutag_int_d[8:0];    
      cpy_rtry_xx_cpy_st_q                        <= cpy_rtry_xx_cpy_st_d;
      cpy_rtry_xx_dl_q[1:0]                       <= cpy_rtry_xx_dl_d[1:0];        
      cpy_rtry_st_size_256_q                      <= cpy_rtry_st_size_256_d;     




      rtry_queue_numentriesval_q[10:0]            <= rtry_queue_numentriesval_d[10:0];
      rtry_queue_maxqdepth_q[10:0]                <= rtry_queue_maxqdepth_d[10:0];

      if ( rtry_wr_count_en )
        rtry_wr_count_q[31:0]                     <= rtry_wr_count_d[31:0];

      if ( rtry_rd_count_en )
        rtry_rd_count_q[31:0]                     <= rtry_rd_count_d[31:0];

      if ( rtry_pending_count_en )
        rtry_pending_count_q[31:0]                <= rtry_pending_count_d[31:0];

      if ( rtry_req_count_en )
        rtry_req_count_q[31:0]                    <= rtry_req_count_d[31:0];

      if ( rtry_hwt_count_en )
        rtry_hwt_count_q[31:0]                    <= rtry_hwt_count_d[31:0];

      if ( rtry_lwt_count_en )
        rtry_lwt_count_q[31:0]                    <= rtry_lwt_count_d[31:0];

    end

endmodule
module afp3_eng_rtry_queue
  (

    input                 clock                                           
  , input                 reset


  , input                 xtouch_wt4rsp_enable_q
  , input                 mmio_eng_capture_all_resp_code_enable


  , input                 main_idle_st


  , input                 rspi_eng_resp_valid
  , input           [7:0] rspi_eng_resp_opcode
  , input                 rspi_resp_is_rtry
  , input                 rspi_resp_is_xtouch_rtry
  , input                 rspi_resp_is_cpy_xx_q
  , input                 rspi_resp_is_cpy_st_q
  , input           [8:0] rspi_resp_afutag_q
  , input           [1:0] rspi_resp_dl_orig_q
  , input           [1:0] rspi_resp_dl_q
  , input           [1:0] rspi_resp_dp_q
  , input           [3:0] rspi_resp_code_q
  , input                 rspi_resp_is_pending_q
  , input                 rspi_resp_is_rtry_lwt_q
  , input                 rspi_resp_is_rtry_req_q
  , input                 rspi_resp_is_rtry_hwt_q


  , input                 we_ld_wt4rsp_st
  , input                 xtouch_wt4rsp_st
  , input                 cpy_ld_wt4rsp_st
  , input                 cpy_st_wt4rsp_st
  , input                 wkhstthrd_wt4rsp_st
  , input                 incr_wt4ldrsp_st
  , input                 incr_wt4strsp_st
  , input                 atomic_wt4rsp_st
  , input                 intrpt_wt4rsp_st
  , input                 we_st_wt4rsp_st

  , input                 we_rtry_ld_idle_st
  , input                 xtouch_rtry_idle_st
  , input                 cpy_rtry_ld_idle_st
  , input                 cpy_rtry_st_idle_st
  , input                 wkhstthrd_rtry_idle_st
  , input                 incr_rtry_idle_st
  , input                 atomic_rtry_idle_st
  , input                 we_rtry_st_idle_st

  ,`ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
    input           [4:0] pending_cnt_q


  , input                 start_eng_display_seq
  , input                 eng_display_idle_st


  , input                 eng_display_rtry_queue_rden
  , input           [9:0] eng_display_addr_q


  , output                rtry_queue_empty
  , output                rtry_queue_func_rden_dly2_q
  , output                rtry_queue_cpy_xx_q
  , output                rtry_queue_cpy_st_q
  , output          [8:0] rtry_queue_afutag_q     
  , output          [1:0] rtry_queue_dl_q         
  , output                rtry_queue_is_pending_q
  , output                rtry_queue_is_rtry_lwt_q
  , output                rtry_queue_is_rtry_req_q
  , output                rtry_queue_is_rtry_hwt_q

  , output                resp_code_is_done
  , output                resp_code_is_rty_req
  , output                resp_code_is_failed
  , output                resp_code_is_adr_error


  , output          [8:0] cpy_rtry_xx_afutag_q
  , output reg            cpy_rtry_xx_cpy_st_q
  , output reg      [1:0] cpy_rtry_xx_dl_q
  , output reg            cpy_rtry_st_size_256_q




  , output                rtry_queue_func_rden_blocker

  ,`ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
    output         [10:0] rtry_queue_rdaddr_q
  ,`ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
    output         [10:0] rtry_queue_wraddr_q
  ,`ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
    output         [17:0] rtry_queue_rddata
  ,`ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
    output          [3:0] resp_code_rddata                 

  );







 `ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
  wire            rtry_queue_empty_int;
 `ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
  wire            rtry_queue_full;
  wire            rtry_queue_last_wraddr;
  wire            rtry_queue_last_rdaddr;
  reg       [3:0] rtry_queue_wr_sel;
  wire            rtry_queue_wren;
  wire            rtry_is_128B_2nd_half;
  wire      [9:0] new_afutag;
  wire     [17:0] rtry_queue_wrdata;
  wire            rtry_queue_func_rden_blocker_int;
  wire            rtry_queue_func_rden;
  reg             rtry_queue_rden;
  reg       [9:0] rtry_queue_rdaddr;
  reg       [2:0] rtry_queue_rd_sel;
 `ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
  wire     [17:0] rtry_queue_rddata_int;




  reg             resp_code_wren;
  wire      [9:0] resp_code_wraddr;
  wire      [3:0] resp_code_wrdata;
  reg             resp_code_rden;
  reg       [9:0] resp_code_rdaddr;
 `ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
  wire      [3:0] resp_code_rddata_int;


  wire     [10:0] rtry_queue_size;
  wire            rtry_queue_wrap_match;
  wire     [10:0] rtry_queue_tl_mn_hd;
  wire     [10:0] rtry_queue_tl_pl_arysz_mn_hd;






  wire            mmio_eng_capture_all_resp_code_enable_d;
  reg             mmio_eng_capture_all_resp_code_enable_q;

  wire            rspi_eng_resp_valid_d;
  reg             rspi_eng_resp_valid_q;


  wire            rspi_resp_is_xlate_done_d;
  reg             rspi_resp_is_xlate_done_q;

  wire            rspi_resp_is_intrp_rdy_d;
  reg             rspi_resp_is_intrp_rdy_q;


  wire            rtry_valid_d;
  reg             rtry_valid_q;
  reg      [10:0] rtry_queue_wraddr_int_d;
 `ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
  reg      [10:0] rtry_queue_wraddr_int_q;
  reg      [10:0] rtry_queue_rdaddr_int_d;
 `ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
  reg      [10:0] rtry_queue_rdaddr_int_q;
  wire            rtry_queue_func_rden_dly1_int_d;
  reg             rtry_queue_func_rden_dly1_int_q;
  wire            rtry_queue_func_rden_dly2_int_d;
  reg             rtry_queue_func_rden_dly2_int_q;

  wire            rtry_queue_capture_en;
  wire            rtry_queue_cpy_xx_int_d;
  reg             rtry_queue_cpy_xx_int_q;
  wire            rtry_queue_cpy_st_int_d;
  reg             rtry_queue_cpy_st_int_q;
  wire      [9:0] rtry_queue_afutag_int_d;
  reg       [9:0] rtry_queue_afutag_int_q;
  wire      [1:0] rtry_queue_dl_int_d;
  reg       [1:0] rtry_queue_dl_int_q;
  wire            rtry_queue_is_pending_int_d;
  reg             rtry_queue_is_pending_int_q;
  wire            rtry_queue_is_rtry_lwt_int_d;
  reg             rtry_queue_is_rtry_lwt_int_q;
  wire            rtry_queue_is_rtry_req_int_d;
  reg             rtry_queue_is_rtry_req_int_q;
  wire            rtry_queue_is_rtry_hwt_int_d;
  reg             rtry_queue_is_rtry_hwt_int_q;

  wire      [8:0] cpy_rtry_xx_afutag_int_d;
  reg       [8:0] cpy_rtry_xx_afutag_int_q;
  wire            cpy_rtry_xx_cpy_st_d;

  wire      [1:0] cpy_rtry_xx_dl_d;

  reg             cpy_rtry_st_size_256_d;







  reg      [10:0] rtry_queue_numentriesval_d;
 `ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
  reg      [10:0] rtry_queue_numentriesval_q;
  reg      [10:0] rtry_queue_maxqdepth_d;
 `ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
  reg      [10:0] rtry_queue_maxqdepth_q;

  wire            rtry_wr_count_en;
  reg      [31:0] rtry_wr_count_d;
 `ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
  reg      [31:0] rtry_wr_count_q;

  wire            rtry_rd_count_en;
  reg      [31:0] rtry_rd_count_d;
 `ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
  reg      [31:0] rtry_rd_count_q;

  wire            rtry_pending_count_en;
  reg      [31:0] rtry_pending_count_d;
 `ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
  reg      [31:0] rtry_pending_count_q;

  wire            rtry_req_count_en;
  reg      [31:0] rtry_req_count_d;
 `ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
  reg      [31:0] rtry_req_count_q;

  wire            rtry_hwt_count_en;
  reg      [31:0] rtry_hwt_count_d;
 `ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
  reg      [31:0] rtry_hwt_count_q;

  wire            rtry_lwt_count_en;
  reg      [31:0] rtry_lwt_count_d;
 `ifdef MARK_DEBUG_ACTIVE (* mark_debug = "TRUE" *) `endif
  reg      [31:0] rtry_lwt_count_q;







  localparam    [7:0] TLX_AFU_RESP_ENCODE_XLATE_DONE           = 8'b00011000;
  localparam    [7:0] TLX_AFU_RESP_ENCODE_INTRP_RDY            = 8'b00011010;


  localparam    [3:0] TLX_AFU_RESP_CODE_DONE                   = 4'b0000;
  localparam    [3:0] TLX_AFU_RESP_CODE_RTY_HWT                = 4'b0001;
  localparam    [3:0] TLX_AFU_RESP_CODE_RTY_REQ                = 4'b0010;
  localparam    [3:0] TLX_AFU_RESP_CODE_LW_RTY_REQ             = 4'b0011;
  localparam    [3:0] TLX_AFU_RESP_CODE_XLATE_PENDING          = 4'b0100;
  localparam    [3:0] TLX_AFU_RESP_CODE_INTRP_PENDING          = 4'b0100;
  localparam    [3:0] TLX_AFU_RESP_CODE_THREAD_NOT_FOUND       = 4'b0100;
  localparam    [3:0] TLX_AFU_RESP_CODE_DERROR                 = 4'b1000;
  localparam    [3:0] TLX_AFU_RESP_CODE_BAD_LENGTH             = 4'b1001;
  localparam    [3:0] TLX_AFU_RESP_CODE_BAD_ADDR               = 4'b1011;
  localparam    [3:0] TLX_AFU_RESP_CODE_BAD_HANDLE             = 4'b1011;
  localparam    [3:0] TLX_AFU_RESP_CODE_FAILED                 = 4'b1110;
  localparam    [3:0] TLX_AFU_RESP_CODE_ADR_ERROR              = 4'b1111;






  assign  mmio_eng_capture_all_resp_code_enable_d =  mmio_eng_capture_all_resp_code_enable;










  assign  rtry_valid_d =  ( rspi_resp_is_rtry && ~( rspi_resp_is_xtouch_rtry && ~xtouch_wt4rsp_enable_q ));


  assign  rtry_queue_empty_int =  (( rtry_queue_wraddr_int_q[9:0] == rtry_queue_rdaddr_int_q[9:0] ) && ( rtry_queue_wraddr_int_q[10] == rtry_queue_rdaddr_int_q[10] ));
  assign  rtry_queue_full      =  (( rtry_queue_wraddr_int_q[9:0] == rtry_queue_rdaddr_int_q[9:0] ) && ( rtry_queue_wraddr_int_q[10] != rtry_queue_rdaddr_int_q[10] ));


  assign  rtry_queue_last_wraddr =  ( rtry_queue_wraddr_int_q[9:0] == 10'b11_1111_1111 );
  assign  rtry_queue_last_rdaddr =  ( rtry_queue_rdaddr_int_q[9:0] == 10'b11_1111_1111 );


  assign  rtry_queue_wren = ( ~reset && ~rtry_queue_full && rtry_valid_q );



  assign  rtry_wr_count_en = ( reset || main_idle_st || rtry_queue_wren );

  always @*
    begin
      if ( reset || main_idle_st )
        rtry_wr_count_d[31:0] =  32'b0;
      else if ( rtry_queue_wren && ~( rtry_wr_count_q[31:0] == 32'hFFFFFFFF ))
        rtry_wr_count_d[31:0] = ( rtry_wr_count_q[31:0] + 32'b1 );
      else
        rtry_wr_count_d[31:0] =   rtry_wr_count_q[31:0];
    end


  always @*
    begin
      rtry_queue_wr_sel[3:0] =  { ( reset || main_idle_st ), rtry_queue_full, rtry_valid_q, rtry_queue_last_wraddr };

      casez ( rtry_queue_wr_sel[3:0] )







            4'b1??? :  rtry_queue_wraddr_int_d[10:0] =  {                        1'b0,                           10'b0           };
            4'b01?? :  rtry_queue_wraddr_int_d[10:0] =  {  rtry_queue_wraddr_int_q[10],   rtry_queue_wraddr_int_q[9:0]           };
            4'b0010 :  rtry_queue_wraddr_int_d[10:0] =  {  rtry_queue_wraddr_int_q[10], ( rtry_queue_wraddr_int_q[9:0] + 10'b1 ) };
            4'b0011 :  rtry_queue_wraddr_int_d[10:0] =  { ~rtry_queue_wraddr_int_q[10],                          10'b0           };

            default :  rtry_queue_wraddr_int_d[10:0] =  {  rtry_queue_wraddr_int_q[10],   rtry_queue_wraddr_int_q[9:0]           };

      endcase
    end


  assign  rtry_is_128B_2nd_half  =  rspi_resp_is_cpy_xx_q  &
                                   (rspi_resp_dl_q[1:0] == 2'b10) &
                                   (rspi_resp_dl_orig_q[1:0] == 2'b11) &
                                   (rspi_resp_dp_q[1] == 1'b1);

  assign  new_afutag[9:0]  = {1'b1, rspi_resp_afutag_q[8:1], (rspi_resp_afutag_q[0] | rtry_is_128B_2nd_half)};


  assign  rtry_queue_wrdata[17]    =  rspi_resp_is_cpy_xx_q;
  assign  rtry_queue_wrdata[16]    =  rspi_resp_is_cpy_st_q;
  assign  rtry_queue_wrdata[15:6]  =  new_afutag[9:0];
  assign  rtry_queue_wrdata[5:4]   =  rspi_resp_dl_q[1:0];
  assign  rtry_queue_wrdata[3]     =  rspi_resp_is_pending_q;
  assign  rtry_queue_wrdata[2]     =  rspi_resp_is_rtry_lwt_q;
  assign  rtry_queue_wrdata[1]     =  rspi_resp_is_rtry_req_q;
  assign  rtry_queue_wrdata[0]     =  rspi_resp_is_rtry_hwt_q;



  afp3_ram1024x018  rtry_queue
    ( .clk   ( clock ),

      .wren  ( rtry_queue_wren ),
      .wrad  ( rtry_queue_wraddr_int_q[9:0] ),
      .data  ( rtry_queue_wrdata[17:0] ),

      .rden  ( rtry_queue_rden ),
      .rdad  ( rtry_queue_rdaddr[9:0] ),
      .q     ( rtry_queue_rddata_int[17:0] )
    );










  assign  rtry_queue_func_rden_blocker_int =  ~( we_ld_wt4rsp_st ||
                                                xtouch_wt4rsp_st ||
                                                cpy_ld_wt4rsp_st ||
                                                cpy_st_wt4rsp_st ||
                                             wkhstthrd_wt4rsp_st ||
                                                incr_wt4ldrsp_st ||
                                                incr_wt4strsp_st ||
                                                atomic_wt4rsp_st ||
                                                intrpt_wt4rsp_st ||
                                                 we_st_wt4rsp_st )  ||
                            
                               ( rtry_queue_func_rden_dly1_int_q ||
                                 rtry_queue_func_rden_dly2_int_q )  ||  
             
                                           ( ~we_rtry_ld_idle_st ||
                                            ~xtouch_rtry_idle_st ||
                                            ~cpy_rtry_ld_idle_st ||
                                            ~cpy_rtry_st_idle_st ||
                                         ~wkhstthrd_rtry_idle_st ||
                                              ~incr_rtry_idle_st ||
                                            ~atomic_rtry_idle_st ||
                                             ~we_rtry_st_idle_st )  || 
             
                                   ~( pending_cnt_q[4:0] == 5'b0 );

  assign  rtry_queue_func_rden            = ~rtry_queue_empty_int && ~rtry_queue_func_rden_blocker_int && ~reset && ~start_eng_display_seq && eng_display_idle_st;
  assign  rtry_queue_func_rden_dly1_int_d =  rtry_queue_func_rden;
  assign  rtry_queue_func_rden_dly2_int_d =  rtry_queue_func_rden_dly1_int_q;


  assign  rtry_rd_count_en = ( reset || main_idle_st || rtry_queue_func_rden );
  always @*
    begin
      if ( reset || main_idle_st )
        rtry_rd_count_d[31:0] =  32'b0;
      else if (  rtry_queue_func_rden && ~( rtry_rd_count_q[31:0] == 32'hFFFFFFFF ))
        rtry_rd_count_d[31:0] = ( rtry_rd_count_q[31:0] + 32'b1 );
      else
        rtry_rd_count_d[31:0] =   rtry_rd_count_q[31:0];
    end


  always @*
    begin

      if ( start_eng_display_seq || ~eng_display_idle_st )
        begin
          rtry_queue_rden        =  eng_display_rtry_queue_rden;
          rtry_queue_rdaddr[9:0] =  eng_display_addr_q[9:0];
        end
      else
        begin
          rtry_queue_rden        =  rtry_queue_func_rden;
          rtry_queue_rdaddr[9:0] =  rtry_queue_rdaddr_int_q[9:0]; 
        end


      rtry_queue_rd_sel[2:0] =  { ( reset || main_idle_st ), rtry_queue_func_rden, rtry_queue_last_rdaddr };

      casez ( rtry_queue_rd_sel[2:0] )






            3'b1?? :  rtry_queue_rdaddr_int_d[10:0] =  {                    1'b0,                              10'b0            };
            3'b010 :  rtry_queue_rdaddr_int_d[10:0] =  {  rtry_queue_rdaddr_int_q[10], ( rtry_queue_rdaddr_int_q[9:0] + 10'b1 ) };
            3'b011 :  rtry_queue_rdaddr_int_d[10:0] =  { ~rtry_queue_rdaddr_int_q[10],                         10'b0            };

           default :  rtry_queue_rdaddr_int_d[10:0] =  {  rtry_queue_rdaddr_int_q[10],   rtry_queue_rdaddr_int_q[9:0]           };

      endcase

    end


  assign  rtry_queue_capture_en         =  rtry_queue_func_rden_dly1_int_q;
  assign  rtry_queue_cpy_xx_int_d       =  rtry_queue_rddata_int[17];
  assign  rtry_queue_cpy_st_int_d       =  rtry_queue_rddata_int[16];
  assign  rtry_queue_afutag_int_d[9:0]  =  rtry_queue_rddata_int[15:6];
  assign  rtry_queue_dl_int_d[1:0]      =  rtry_queue_rddata_int[5:4];
  assign  rtry_queue_is_pending_int_d   =  rtry_queue_rddata_int[3];
  assign  rtry_queue_is_rtry_lwt_int_d  =  rtry_queue_rddata_int[2];
  assign  rtry_queue_is_rtry_req_int_d  =  rtry_queue_rddata_int[1];
  assign  rtry_queue_is_rtry_hwt_int_d  =  rtry_queue_rddata_int[0];



  assign  cpy_rtry_xx_afutag_int_d[8:0] =  rtry_queue_afutag_int_q[8:0];
  assign  cpy_rtry_xx_cpy_st_d          =  rtry_queue_cpy_st_int_q;
  assign  cpy_rtry_xx_dl_d[1:0]         =  rtry_queue_dl_int_q[1:0];



  always @*
    begin
      if ( cpy_rtry_xx_dl_d[1:0] == 2'b11 )
        cpy_rtry_st_size_256_d  =  1'b1;
      else
        cpy_rtry_st_size_256_d  = 1'b0;
    end





  assign  rtry_queue_size[10:0] =  11'b10000000000;


  assign  rtry_queue_wrap_match =  ( rtry_queue_rdaddr_int_q[10] == rtry_queue_wraddr_int_q[10] );


  assign  rtry_queue_tl_mn_hd[10:0]          =  ( { 1'b0, rtry_queue_wraddr_int_q[9:0] } - { 1'b0, rtry_queue_rdaddr_int_q[9:0] } );


  assign  rtry_queue_tl_pl_arysz_mn_hd[10:0] =  ( { 1'b0, rtry_queue_wraddr_int_q[9:0] } + ( rtry_queue_size[10:0] - { 1'b0, rtry_queue_rdaddr_int_q[9:0] } ));

  always @*
    begin

      if ( rtry_queue_wrap_match )
        rtry_queue_numentriesval_d[10:0] =  rtry_queue_tl_mn_hd[10:0];
      else
        rtry_queue_numentriesval_d[10:0] =  rtry_queue_tl_pl_arysz_mn_hd[10:0];


      if ( reset || main_idle_st )
        rtry_queue_maxqdepth_d[10:0] =  11'b0;
      else if  ( rtry_queue_numentriesval_q[10:0] > rtry_queue_maxqdepth_q[10:0] )
        rtry_queue_maxqdepth_d[10:0] =  rtry_queue_numentriesval_q[10:0];
      else
        rtry_queue_maxqdepth_d[10:0] =  rtry_queue_maxqdepth_q[10:0];

    end






  assign  rspi_eng_resp_valid_d =  rspi_eng_resp_valid;


  assign  rspi_resp_is_xlate_done_d          =  ( rspi_eng_resp_opcode[7:0] == TLX_AFU_RESP_ENCODE_XLATE_DONE[7:0]     );
  assign  rspi_resp_is_intrp_rdy_d           =  ( rspi_eng_resp_opcode[7:0] == TLX_AFU_RESP_ENCODE_INTRP_RDY[7:0]      );

  always @*
    begin
     if (mmio_eng_capture_all_resp_code_enable_q )
       resp_code_wren        =  rspi_eng_resp_valid_q;
     else
       resp_code_wren        =  rspi_eng_resp_valid_q && ( rspi_resp_is_xlate_done_q || rspi_resp_is_intrp_rdy_q );
    end

  assign  resp_code_wraddr[9:0] =  { rspi_resp_is_cpy_st_q, rspi_resp_afutag_q[8:0] };
  assign  resp_code_wrdata[3:0] =  rspi_resp_code_q[3:0];

  always @*
    begin
     if ( main_idle_st )
       begin 
         resp_code_rden        =  eng_display_rtry_queue_rden;
         resp_code_rdaddr[9:0] =  eng_display_addr_q[9:0]; 
       end
     else
       begin 
         resp_code_rden        =  rtry_queue_func_rden_dly1_int_q;
	 resp_code_rdaddr[9:0] =  { rtry_queue_cpy_st_int_d, rtry_queue_afutag_int_d[8:0]} ;

       end
    end



  afp3_ram1024x004  resp_code_ary
    ( .clk   ( clock ),

      .wren  ( resp_code_wren ),
      .wrad  ( resp_code_wraddr[9:0] ),
      .data  ( resp_code_wrdata[3:0] ),

      .rden  ( resp_code_rden ),
      .rdad  ( resp_code_rdaddr[9:0] ),
      .q     ( resp_code_rddata_int[3:0] )
    );



  assign  resp_code_is_done      =  ( resp_code_rddata_int[3:0] == TLX_AFU_RESP_CODE_DONE[3:0]      );
  assign  resp_code_is_rty_req   =  ( resp_code_rddata_int[3:0] == TLX_AFU_RESP_CODE_RTY_REQ[3:0]   );
  assign  resp_code_is_failed    =  ( resp_code_rddata_int[3:0] == TLX_AFU_RESP_CODE_FAILED[3:0]    );
  assign  resp_code_is_adr_error =  ( resp_code_rddata_int[3:0] == TLX_AFU_RESP_CODE_ADR_ERROR[3:0] );






  assign  rtry_queue_func_rden_dly2_q =  rtry_queue_func_rden_dly2_int_q;
  assign  rtry_queue_cpy_xx_q         =  rtry_queue_cpy_xx_int_q;
  assign  rtry_queue_cpy_st_q         =  rtry_queue_cpy_st_int_q;
  assign  rtry_queue_afutag_q[8:0]    =  rtry_queue_afutag_int_q[8:0];       
  assign  rtry_queue_dl_q[1:0]        =  rtry_queue_dl_int_q[1:0];           
  assign  rtry_queue_is_pending_q     =  rtry_queue_is_pending_int_q;
  assign  rtry_queue_is_rtry_lwt_q    =  rtry_queue_is_rtry_lwt_int_q;
  assign  rtry_queue_is_rtry_req_q    =  rtry_queue_is_rtry_req_int_q;
  assign  rtry_queue_is_rtry_hwt_q    =  rtry_queue_is_rtry_hwt_int_q;


  assign  rtry_pending_count_en = ( reset || main_idle_st || ( rtry_queue_func_rden_dly2_int_q && rtry_queue_is_pending_int_q ));

  always @*
    begin
      if ( reset || main_idle_st )
        rtry_pending_count_d[31:0] = 32'b0;
      else if ( rtry_queue_func_rden_dly2_int_q && rtry_queue_is_pending_int_q && ~( rtry_pending_count_q[31:0] == 32'hFFFFFFFF ))
        rtry_pending_count_d[31:0] = ( rtry_pending_count_q[31:0] + 32'b1 );
      else
        rtry_pending_count_d[31:0] =   rtry_pending_count_q[31:0];
    end


  assign  rtry_req_count_en = ( reset || main_idle_st || ( rtry_queue_func_rden_dly2_int_q && rtry_queue_is_rtry_req_int_q ));

  always @*
    begin
      if ( reset || main_idle_st )
        rtry_req_count_d[31:0] =  32'b0;
      else if ( rtry_queue_func_rden_dly2_int_q && rtry_queue_is_rtry_req_int_q && ~( rtry_req_count_q[31:0] == 32'hFFFFFFFF ))
        rtry_req_count_d[31:0] = ( rtry_req_count_q[31:0] + 32'b1 );
      else
        rtry_req_count_d[31:0] =   rtry_req_count_q[31:0];
    end

  assign  rtry_hwt_count_en = ( reset || main_idle_st || ( rtry_queue_func_rden_dly2_int_q && rtry_queue_is_rtry_hwt_int_q ));

  always @*
    begin
      if ( reset || main_idle_st )
        rtry_hwt_count_d[31:0] =  32'b0;
      else if ( rtry_queue_func_rden_dly2_int_q && rtry_queue_is_rtry_hwt_int_q && ~( rtry_hwt_count_q[31:0] == 32'hFFFFFFFF ))
        rtry_hwt_count_d[31:0] = ( rtry_hwt_count_q[31:0] + 32'b1 );
      else
        rtry_hwt_count_d[31:0] =   rtry_hwt_count_q[31:0];
    end


  assign  rtry_lwt_count_en = ( reset || main_idle_st || ( rtry_queue_func_rden_dly2_int_q && rtry_queue_is_rtry_lwt_int_q ));

  always @*
    begin
      if ( reset || main_idle_st )
        rtry_lwt_count_d[31:0] =  32'b0;
      else if ( rtry_queue_func_rden_dly2_int_q && rtry_queue_is_rtry_lwt_int_q && ~( rtry_lwt_count_q[31:0] == 32'hFFFFFFFF ))
        rtry_lwt_count_d[31:0] = ( rtry_lwt_count_q[31:0] + 32'b1 );
      else
        rtry_lwt_count_d[31:0] =   rtry_lwt_count_q[31:0];
    end








  assign  cpy_rtry_xx_afutag_q[8:0]   =  cpy_rtry_xx_afutag_int_q[8:0];






  assign  rtry_queue_empty          =  rtry_queue_empty_int;






  assign  rtry_queue_func_rden_blocker =  rtry_queue_func_rden_blocker_int;
  assign  rtry_queue_rdaddr_q[10:0]    =  rtry_queue_rdaddr_int_q[10:0];
  assign  rtry_queue_wraddr_q[10:0]    =  rtry_queue_wraddr_int_q[10:0];
  assign  rtry_queue_rddata[17:0]      =  rtry_queue_rddata_int[17:0];
  assign  resp_code_rddata[3:0]        =  resp_code_rddata_int[3:0];













  always @ ( posedge clock )
    begin
      mmio_eng_capture_all_resp_code_enable_q     <= mmio_eng_capture_all_resp_code_enable_d;

      rspi_eng_resp_valid_q                       <= rspi_eng_resp_valid_d;

      rspi_resp_is_xlate_done_q                   <= rspi_resp_is_xlate_done_d;
      rspi_resp_is_intrp_rdy_q                    <= rspi_resp_is_intrp_rdy_d;

      rtry_valid_q                                <= rtry_valid_d;
      rtry_queue_wraddr_int_q[10:0]               <= rtry_queue_wraddr_int_d[10:0];     
      rtry_queue_rdaddr_int_q[10:0]               <= rtry_queue_rdaddr_int_d[10:0];     
      rtry_queue_func_rden_dly1_int_q             <= rtry_queue_func_rden_dly1_int_d;       
      rtry_queue_func_rden_dly2_int_q             <= rtry_queue_func_rden_dly2_int_d;
      if ( rtry_queue_capture_en )
        begin      
          rtry_queue_cpy_xx_int_q                 <= rtry_queue_cpy_xx_int_d;     
          rtry_queue_cpy_st_int_q                 <= rtry_queue_cpy_st_int_d;     
          rtry_queue_afutag_int_q[9:0]            <= rtry_queue_afutag_int_d[9:0];     
          rtry_queue_dl_int_q[1:0]                <= rtry_queue_dl_int_d[1:0];         
          rtry_queue_is_pending_int_q             <= rtry_queue_is_pending_int_d; 
          rtry_queue_is_rtry_lwt_int_q            <= rtry_queue_is_rtry_lwt_int_d; 
          rtry_queue_is_rtry_req_int_q            <= rtry_queue_is_rtry_req_int_d; 
          rtry_queue_is_rtry_hwt_int_q            <= rtry_queue_is_rtry_hwt_int_d;
        end
      cpy_rtry_xx_afutag_int_q[8:0]               <= cpy_rtry_xx_afutag_int_d[8:0];    
      cpy_rtry_xx_cpy_st_q                        <= cpy_rtry_xx_cpy_st_d;
      cpy_rtry_xx_dl_q[1:0]                       <= cpy_rtry_xx_dl_d[1:0];        
      cpy_rtry_st_size_256_q                      <= cpy_rtry_st_size_256_d;     




      rtry_queue_numentriesval_q[10:0]            <= rtry_queue_numentriesval_d[10:0];
      rtry_queue_maxqdepth_q[10:0]                <= rtry_queue_maxqdepth_d[10:0];

      if ( rtry_wr_count_en )
        rtry_wr_count_q[31:0]                     <= rtry_wr_count_d[31:0];

      if ( rtry_rd_count_en )
        rtry_rd_count_q[31:0]                     <= rtry_rd_count_d[31:0];

      if ( rtry_pending_count_en )
        rtry_pending_count_q[31:0]                <= rtry_pending_count_d[31:0];

      if ( rtry_req_count_en )
        rtry_req_count_q[31:0]                    <= rtry_req_count_d[31:0];

      if ( rtry_hwt_count_en )
        rtry_hwt_count_q[31:0]                    <= rtry_hwt_count_d[31:0];

      if ( rtry_lwt_count_en )
        rtry_lwt_count_q[31:0]                    <= rtry_lwt_count_d[31:0];

    end

endmodule