qdma enable jtag debugger

news2025/4/5 15:05:42

在这里插入图片描述
ip上的m_axi_lite 是连接到qdma_v4_0_11_dma5_rtl_top这个ip的
和jtag debugger没有关系

qdma enable jtag debugger 读取的是ip内部reg

在这里插入图片描述
在这里插入图片描述

///home/nic626/smart_nic/build_dir/qdma_no_sriov_ex/qdma_no_sriov_ex.srcs/sources_1/ip/qdma_no_sriov.xcix!/qdma_no_sriov/ip_0/source/qdma_no_sriov_pcie4_ip_debug_wrapper.v
//assign trc_rst_n = ~sys_rst;
//assign trc_clk   = sys_clk;

qdma_no_sriov_pcie4_ip_debug_probes #(
    .PHY_LANE (PHY_LANE)  
  ) debug_probes_inst(
  //reset state debugging probes
	.user_clk            (user_clk),                //input                  user_clk,
	.user_reset          (user_reset),              //input                  user_reset,
	.sys_rst             (sys_rst),
    .sys_clk             (sys_clk),
	.reset_state         (reset_state),             //input [2:0]            reset_state,
	                                                ////ltssm debugging probes
	.ltssm               (ltssm),                   //input [5:0]            ltssm,
	.cfg_negotiated_width(cfg_negotiated_width),    //input [3:0]            cfg_negotiated_width), 
	.cfg_current_speed   (cfg_current_speed),       //input [2:0]            cfg_current_speed,
	                                                ////Receiver detect probes
	.pclk                (pclk),                    //input                  pclk,
	.prst_n              (prst_n),                  //input                  prst_n,
	.txdetectrx          (txdetectrx),              //input                  txdetectrx,
	.powerdown           (powerdown),               //input [1:0]            powerdown,
	.phystatus           (phystatus),               //input [PHY_LANE-1:0]   phystatus,
	.rxstatus            (rxstatus),                //input [PHY_LANE*3-1:0] rxstatus,                      
	                                                ////trace memory access interface (DRP like interface)
	.trc_rst_n           (trc_rst_n),               //input                  trc_rst_n,
	.trc_clk             (trc_clk),                 //input                  trc_clk,
	.trc_en              (trc_en),                  //input                  trc_en, //trace enable
	//.trc_wr              (trc_wr),                  ////input                  trc_wr, //trace write enable //TODO: add write
	                                                ////support 
	.trc_addr            (trc_addr),                //input [16:0]           trc_addr, //address width compatible with XSDB
	//.trc_di              (trc_di),                  ////input [15:0]         trc_di, //trace write data input
	.trc_do              (trc_do),                  //output [15:0]          trc_do, 
	.trc_rdy             (trc_rdy)                  //output                 trc_rdy                            
  );

qdma_no_sriov_pcie4_ip_debug_axi4l_s debug_axi4l_s_inst (

  //--------------  AXI Interface Signals         --------------
 .AXI_aclk      (AXI_aclk),      // input                             AXI_aclk,
 .AXI_aresetn   (AXI_aresetn),   // input                             AXI_aresetn,
                                    
 .S_AXI_araddr  (AXI_araddr),  // input  [S_AXI_ADDR_WIDTH-1:0]     S_AXI_araddr,
 .S_AXI_arready (AXI_arready), // output reg                        S_AXI_arready,
 .S_AXI_arvalid (AXI_arvalid), // input                             S_AXI_arvalid,
 .S_AXI_arprot  (AXI_arprot),  // input  [2:0]                      S_AXI_arprot,
                                    
 .S_AXI_awaddr  (AXI_awaddr),  // input [S_AXI_ADDR_WIDTH-1:0]      S_AXI_awaddr,
 .S_AXI_awready (AXI_awready), // output reg                        S_AXI_awready,
 .S_AXI_awvalid (AXI_awvalid), // input                             S_AXI_awvalid,
 .S_AXI_awprot  (AXI_awprot),  // input  [2:0]                      S_AXI_awprot,
                                    
 .S_AXI_bresp   (AXI_bresp),   // output     [1:0]                  S_AXI_bresp,
 .S_AXI_bready  (AXI_bready),  // input                             S_AXI_bready,
 .S_AXI_bvalid  (AXI_bvalid),  // output reg                        S_AXI_bvalid,
                                    
 .S_AXI_rdata   (AXI_rdata),   // output     [S_AXI_DATA_WIDTH-1:0] S_AXI_rdata,
 .S_AXI_rready  (AXI_rready),  // input                             S_AXI_rready,
 .S_AXI_rvalid  (AXI_rvalid),  // output reg                        S_AXI_rvalid,
 .S_AXI_rresp   (AXI_rresp),   // output reg [1:0]                  S_AXI_rresp,
                                    
 .S_AXI_wdata   (AXI_wdata),   // input  [S_AXI_DATA_WIDTH-1:0]     S_AXI_wdata,
 .S_AXI_wready  (AXI_wready),  // output reg                        S_AXI_wready,
 .S_AXI_wvalid  (AXI_wvalid),  // input                             S_AXI_wvalid,
 .S_AXI_wstrb   (AXI_wstrb),   // input  [S_AXI_DATA_WIDTH/8-1:0]   S_AXI_wstrb,
                                 // trace memory access interface (DRP like interface)
 .trc_rst_n     (trc_rst_n),     // output                            trc_rst_n
 .trc_clk       (trc_clk),       // output                            trc_clk,
 .trc_en        (trc_en),        // output                            trc_en,        // trace enable
 .trc_wr        (trc_wr),        // output                            trc_wr,        // trace write enable                                 // TODO
 .trc_addr      (trc_addr),      // output reg [16:0]                 trc_addr,      // address width compatible with XSDB
 .trc_di        (trc_di),        //                                                  // out [15:0]                    trc_di,            // trace write data input
 .trc_do        (trc_do),        // input  [15:0]                     trc_do,
 .trc_rdy       (trc_rdy)        // input                             trc_rdy

);

//-----------------------------------------------------------------------------
//
// (c) Copyright 2012-2012 Xilinx, Inc. All rights reserved.
//
// This file contains confidential and proprietary information
// of Xilinx, Inc. and is protected under U.S. and
// international copyright and other intellectual property
// laws.
//
// DISCLAIMER
// This disclaimer is not a license and does not grant any
// rights to the materials distributed herewith. Except as
// otherwise provided in a valid license issued to you by
// Xilinx, and to the maximum extent permitted by applicable
// law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
// WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
// AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
// BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
// INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
// (2) Xilinx shall not be liable (whether in contract or tort,
// including negligence, or under any other theory of
// liability) for any loss or damage of any kind or nature
// related to, arising under or in connection with these
// materials, including for any direct, or any indirect,
// special, incidental, or consequential loss or damage
// (including loss of data, profits, goodwill, or any type of
// loss or damage suffered as a result of any action brought
// by a third party) even if such damage or loss was
// reasonably foreseeable or Xilinx had been advised of the
// possibility of the same.
//
// CRITICAL APPLICATIONS
// Xilinx products are not designed or intended to be fail-
// safe, or for use in any application requiring fail-safe
// performance, such as life-support or safety devices or
// systems, Class III medical devices, nuclear facilities,
// applications related to the deployment of airbags, or any
// other applications that could lead to death, personal
// injury, or severe property or environmental damage
// (individually and collectively, "Critical
// Applications"). Customer assumes the sole risk and
// liability of any use of Xilinx products in Critical
// Applications, subject only to applicable laws and
// regulations governing limitations on product liability.
//
// THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
// PART OF THIS FILE AT ALL TIMES.
//
//-----------------------------------------------------------------------------
//
// Project    : UltraScale+ FPGA PCI Express v4.0 Integrated Block
// File       : qdma_no_sriov_pcie4_ip_debug_probes.v
// Version    : 1.3 
//-----------------------------------------------------------------------------
//------------------------------------------------------------------------------

`timescale  1 ns / 1 ps

module qdma_no_sriov_pcie4_ip_debug_probes # (

    parameter C_MAJOR_VERSION     = 2016,
    parameter C_MINOR_VERSION     = 1,
    parameter C_CORE_MAJOR_VER    = 1,
    parameter C_CORE_MINOR_VER    = 0,
    parameter C_XSDB_SLAVE_TYPE   = 16'h0901,
    parameter C_XSDB_CSE_DRV_VER  = 16'h0001,
    parameter C_XSDB_CORE_TYPE    = 16'h0009,
    parameter C_XSDB_CG_VER       = 16'h0000,
    parameter C_XSDB_CG_ALPHA_VER = 16'h0000, // TODO: test reg is currently disabled 
    parameter C_XSDB_EDA_VER      = 16'h1001, // VIVADO 2016.1    
    parameter C_XSDB_NEXT_SLAVE   = 16'h0,
    parameter PHY_LANE            = 1          //Number of lanes
  ) (
  //reset state debugging probes
  input                  user_clk,
  input                  sys_rst,
  input                  sys_clk,
  input                  user_reset,
  input [2:0]            reset_state,
  //ltssm debugging probes
  //input                  core_clk,
  input [5:0]            ltssm,
  input [4:0]            cfg_negotiated_width, //TODO add support
  input [2:0]            cfg_current_speed,
  //Receiver detect probes
  input                  pclk,
  input                  prst_n,
  input                  txdetectrx,
  input [1:0]            powerdown,
  input [PHY_LANE-1:0]   phystatus,
  input [PHY_LANE*3-1:0] rxstatus,
  
  //trace memory access interface (DRP like interface)
  input                  trc_rst_n,
  input                  trc_clk,
  input                  trc_en, //trace enable
  //input                  trc_wr, //trace write enable //TODO: add write
  //support 
  input [16:0]           trc_addr, //address width compatible with XSDB
  //input [15:0]           trc_di, //trace write data input
  output [15:0]          trc_do, 
  output                 trc_rdy
  );

genvar i;

wire reset_trc_mem_rd;
wire ltssm_trc_mem_rd;
wire rxdet_trc_mem_rd;

/*******************************************************************************/
// Reset state capture
//TODO: How to reset, rtl uses cold_reset
/*******************************************************************************/
localparam NUM_RESET_STATE            = 8;
//localparam RST_ST_RESET               = 3'b000;
//localparam RST_ST_MGMT_RESET_DEASSERT = 3'b001;
//localparam RST_ST_PHY_RDY             = 3'b100;
//localparam RST_ST_RESET_DEASSERT      = 3'b101;
localparam RST_ST_TRC_DWIDTH = 16;
reg [2:0]  cur_reset_st = 3'b0;
reg [2:0]  pre_reset_st = 3'b0;
wire       reset_st_en;   //enable store the state transition
reg [15:0] reset_st_tmr;  //reset state timer
wire [RST_ST_TRC_DWIDTH-1:0]     reset_st_trc;


always @ (posedge sys_clk, posedge sys_rst) 
begin
    if(sys_rst) begin
        pre_reset_st <= 3'b0;
        cur_reset_st <= 3'b0;
    end else begin
        pre_reset_st <= cur_reset_st;
        cur_reset_st <= reset_state;
    end
end

assign reset_st_en = | (cur_reset_st ^ pre_reset_st); // detect state transaction

always @ (posedge sys_clk, posedge sys_rst) 
begin
    if (sys_rst)
        reset_st_tmr <= 16'b0;
    else 
        reset_st_tmr <= reset_st_en ? 16'b0 :
                       (& reset_st_tmr) ? reset_st_tmr : reset_st_tmr + 1'b1;
end

xpm_memory_dpdistram # (
  // Common module parameters
  .MEMORY_SIZE        (NUM_RESET_STATE*RST_ST_TRC_DWIDTH),   //positive integer
  .CLOCKING_MODE      (1),      //integer; 0=common, 1=independent
  .MEMORY_INIT_FILE   ("none"), //string; "none" or "<filename>.mem" 
  .MESSAGE_CONTROL    (0),      //do not change

  // Port A module parameters
  .WRITE_DATA_WIDTH_A (RST_ST_TRC_DWIDTH),     //positive integer
  .READ_DATA_WIDTH_A  (RST_ST_TRC_DWIDTH),     //positive integer
  .BYTE_WRITE_WIDTH_A (RST_ST_TRC_DWIDTH),     //integer; 8, 9, or WRITE_DATA_WIDTH_A value
  .ADDR_WIDTH_A       (3),      //positive integer
  .READ_RESET_VALUE_A ({RST_ST_TRC_DWIDTH{1'b0}}),  //vector of READ_DATA_WIDTH_A bits
  .READ_LATENCY_A     (2),      //non-negative integer

  // Port B module parameters
  .READ_DATA_WIDTH_B  (16),  //positive integer
  .ADDR_WIDTH_B       (3),      //positive integer
  .READ_RESET_VALUE_B ({16{1'b0}}),  //vector of READ_DATA_WIDTH_B bits
  .READ_LATENCY_B     (2)       //non-negative integer

) reset_state_mem_inst (
  // Port A module ports
  .clka   (sys_clk),
  .rsta   (sys_rst),
  .ena    (reset_st_en), 
  .regcea (1'b1),  //do not change
  .wea    (reset_st_en),
  .addra  (pre_reset_st),
  .dina   ({4'b0, 1'b0, pre_reset_st, 4'b0, 1'b0, cur_reset_st}),
  .douta  (),

  // Port B module ports
  .clkb   (trc_clk),
  .rstb   (~trc_rst_n),
  .enb    (reset_trc_mem_rd),
  .regceb (1'b1),  //do not change
  .addrb  (trc_addr[2:0]),
  .doutb  (reset_st_trc)

);


/*******************************************************************************/
// LTSSM trace capturing
// 1. Capture each state transistion
// 2. Record each transistion into a capture trace 32bit
//    ltssm_trace              = {
//                    ltssm_st_dur[15:0], // 16 bit scaled state duration
//                    ltssm_pre_st[5:0] , // previous state 
//                    ltssm_cur_st[5:0]   // current state
//                    }
// 3. store trace into BRAM
// 4. side-band probes
//         a. ltssm_trans_cnt // LTSSM transistion count, point to the latest
//         recorded debugging trace
//
/*******************************************************************************/
localparam MAX_NUM_LTSSM_TRACE = 512;
localparam LTSSM_TMEM_AWIDTH   = 9;   //LTSSM trace memory address width
localparam LTSSM_ST_WIDTH      = 6;
localparam LTSSM_WDATA_WIDTH   = 16;

reg [LTSSM_ST_WIDTH-1:0] cur_ltssm_st = 6'b0;
reg [LTSSM_ST_WIDTH-1:0] pre_ltssm_st = 6'b0;

reg  [LTSSM_TMEM_AWIDTH-1:0] ltssm_trace_cnt = {LTSSM_TMEM_AWIDTH{1'b0}};

wire ltssm_en;
//reg [1:0] ltssm_override;

(* mark_debug = "TRUE" *) wire                             ltssm_mem_rd;
(* mark_debug = "TRUE" *) wire [LTSSM_TMEM_AWIDTH -1:0]    ltssm_mem_raddr; // Yi Wang
(* mark_debug = "TRUE" *) wire [15:0]                      ltssm_mem_rdata;

(* mark_debug = "TRUE" *) wire                             ltssm_mem_wr;
(* mark_debug = "TRUE" *) wire [LTSSM_TMEM_AWIDTH-1:0]     ltssm_mem_waddr;
(* mark_debug = "TRUE" *) wire [LTSSM_WDATA_WIDTH-1:0]     ltssm_mem_wdata;

assign ltssm_en        = | (cur_ltssm_st ^ pre_ltssm_st);
assign ltssm_mem_wr    = ltssm_en;
assign ltssm_mem_waddr = ltssm_trace_cnt;
assign ltssm_mem_wdata = { 
                           
                           2'b0, //ltssm_override,                           
                           cur_ltssm_st,
                           2'b0,
                           pre_ltssm_st
                          
                           };

assign ltssm_mem_raddr = trc_addr[LTSSM_TMEM_AWIDTH -1:0]; //Yi Wang
assign ltssm_mem_rd    = ltssm_trc_mem_rd;

always @ (posedge user_clk,posedge sys_rst) begin
 if (sys_rst) begin
   cur_ltssm_st <= 6'b0;
   pre_ltssm_st <= 6'b0;
 end else if ((cur_ltssm_st == 6'b1) & (ltssm != 6'h2) ) begin
   cur_ltssm_st <= 6'b1;
   pre_ltssm_st <= 6'b1;
 end else begin
   cur_ltssm_st <= ltssm;
   pre_ltssm_st <= cur_ltssm_st;
 end
end

// always @(posedge user_clk,posedge sys_rst)
// begin
//   if (sys_rst) begin
//    ltssm_trace_cnt   <= {LTSSM_TMEM_AWIDTH{1'b0}};
//    //ltssm_override    <= 1'b0;
//   end else if (ltssm_en) begin
//     if  (ltssm_trace_cnt <= 'd254) begin
//      ltssm_trace_cnt   <= ltssm_trace_cnt + 1'b1;
//     // ltssm_override    <= ltssm_override;
//     end else if (ltssm_trace_cnt == 'd255) begin
//       ltssm_trace_cnt   <= 'd128;
//       //ltssm_override    <= ltssm_override + 1'b1;
//     end
//   end
//   else begin
//     ltssm_trace_cnt   <= ltssm_trace_cnt;
//     //ltssm_override    <= ltssm_override;
//   end
// end  
 always @(posedge user_clk,posedge sys_rst)
 begin
   if (sys_rst) begin
    ltssm_trace_cnt   <= {LTSSM_TMEM_AWIDTH{1'b0}};
   end else begin
      ltssm_trace_cnt   <= (ltssm_en & (~&ltssm_trace_cnt)) ? (ltssm_trace_cnt + 1'b1) :ltssm_trace_cnt;
   end
 end  
 
xpm_memory_sdpram # (

  // Common module parameters
  .MEMORY_SIZE        (MAX_NUM_LTSSM_TRACE*LTSSM_WDATA_WIDTH),   //positive integer
  .MEMORY_PRIMITIVE   ("blockram"),      //integer; 0=auto, 1=distributed, 2=block
  .CLOCKING_MODE      ("independent_clock"),      //integer; 0=common, 1=independent
  .ECC_MODE           (0),      //do not change
  .MEMORY_INIT_FILE   ("none"), //string; "none" or "<filename>.mem" 
  //.WAKEUP_TIME        (0),      //do not change
  .MESSAGE_CONTROL    (0),      //do not change

  // Port A module parameters
  //.WRITE_DATA_WIDTH_A (32),     //positive integer
 // .BYTE_WRITE_WIDTH_A (32),     //integer; 8, 9, or WRITE_DATA_WIDTH_A value
  .WRITE_DATA_WIDTH_A (LTSSM_WDATA_WIDTH),     //positive integer
  .BYTE_WRITE_WIDTH_A (LTSSM_WDATA_WIDTH),     //integer; 8, 9, or WRITE_DATA_WIDTH_A value
  .ADDR_WIDTH_A       (LTSSM_TMEM_AWIDTH),      //positive integer

  // Port B module parameters
  .READ_DATA_WIDTH_B  (16),     //positive integer
  .ADDR_WIDTH_B       (LTSSM_TMEM_AWIDTH),      //positive integer
  .READ_RESET_VALUE_B (16'b0),  //vector of READ_DATA_WIDTH_B bits
  .READ_LATENCY_B     (2)       //non-negative integer

) ltssm_trace_mem_inst (

  // Common module ports
  .sleep          (1'b0),  //do not change

  // Port A module ports
  .clka           (user_clk),
  .ena            (ltssm_mem_wr),
  .wea            (ltssm_mem_wr),
  .addra          (ltssm_mem_waddr),
  .dina           (ltssm_mem_wdata),
  .injectsbiterra (1'b0),  //do not change
  .injectdbiterra (1'b0),  //do not change

  // Port B module ports
  .clkb           (trc_clk),
  .rstb           (~trc_rst_n),
  .enb            (ltssm_mem_rd),
  .regceb         (1'b1),  //do not change
  .addrb          (ltssm_mem_raddr),
  .doutb          (ltssm_mem_rdata),
  .sbiterrb       (),      //do not change
  .dbiterrb       ()       //do not change

);

/*******************************************************************************/
// Receiver detection probes
// Per-lane based trace format
// rxdet_lane_trace               = {
//            rxdet_dur[7:0], //time duration txdetectrx <-> phystuatus
//            rxstatus[2:0], //          
//                      }
/*******************************************************************************/
localparam MAX_NUM_RXDET_TRACE    = 4;
localparam RXDET_TRACE_MEM_AWIDTH = 2;
localparam RXDET_TRACE_DWIDTH     = 16;

reg  [1:0] rxdet_iter_cnt          = 2'b0; //Receiver detection iteration count
reg  [7:0] rxdet_dur               = 8'b0; //Receiver detection state duration
reg  [PHY_LANE-1:0] rxdet_phystatus_rcved; //Per lane flag indicates valid phystatus reveived during receiver detection                
wire       rxdet_on;
wire       rxdet_start;
wire       rxdet_end;
wire [RXDET_TRACE_DWIDTH-1:0] rxdet_trace[PHY_LANE-1:0];
wire [RXDET_TRACE_DWIDTH-1:0] rxdet_lane_trace[PHY_LANE-1:0]; // per lane based receiver dection traces
reg  [RXDET_TRACE_DWIDTH-1:0] rxdet_lane_trace_r[PHY_LANE-1:0]; // per lane based receiver dection traces
wire [PHY_LANE-1:0] rxdet_lane_wen; //per lane based trace write enable


reg  rxdet_on_d = 1'b0;

assign rxdet_on       = txdetectrx & (powerdown[1] & ~powerdown[0]); 
assign rxdet_start    = rxdet_on & (~rxdet_on_d); 
assign rxdet_end      = (~rxdet_on) & rxdet_on_d;
assign rxdet_lane_wen = ({PHY_LANE{rxdet_on}} & phystatus) |  //valid rxdetection   
                        ({PHY_LANE{rxdet_end}} & ~rxdet_phystatus_rcved); //phystatus timeout

always @ (posedge pclk)
    rxdet_on_d <= rxdet_on;

always @ (posedge pclk) 
    rxdet_dur <= (rxdet_start | ~prst_n) ?  8'b0 : (rxdet_dur + 1'b1);

always @ (posedge pclk)
	if (~prst_n)
		rxdet_iter_cnt <= 2'b0;
	else
		rxdet_iter_cnt <= (~(&rxdet_iter_cnt) & rxdet_end ) ? (rxdet_iter_cnt + 1'b1) :
                                                           rxdet_iter_cnt;

generate  begin 
    for (i=0;i<PHY_LANE;i=i+1) begin : GEN_RXDET_TRC_MEM
	  always @ (posedge pclk)
	  	if (~prst_n | rxdet_start)
			rxdet_phystatus_rcved[i] <= 1'b0;
		else if (phystatus[i] & rxdet_on)
			rxdet_phystatus_rcved[i] <= 1'b1;

	  assign rxdet_trace[i] = { rxdet_dur[7:0], // detection durtion
                      		    3'b0,
                      		    phystatus[i],            // valid flag
					  		    1'b0,
                      		    rxstatus[i*3+:3]
                      		  }; 

  xpm_memory_dpdistram # (
      // Common module parameters
      .MEMORY_SIZE        (MAX_NUM_RXDET_TRACE * RXDET_TRACE_DWIDTH),   //positive integer
      .CLOCKING_MODE      (1),      //integer; 0=common, 1=independent
      .MEMORY_INIT_FILE   ("none"), //string; "none" or "<filename>.mem" 
      .MESSAGE_CONTROL    (0),      //do not change
    
      // Port A module parameters
      .WRITE_DATA_WIDTH_A (RXDET_TRACE_DWIDTH),     //positive integer
      .READ_DATA_WIDTH_A  (RXDET_TRACE_DWIDTH),     //positive integer
      .BYTE_WRITE_WIDTH_A (RXDET_TRACE_DWIDTH),     //integer; 8, 9, or WRITE_DATA_WIDTH_A value
      .ADDR_WIDTH_A       (RXDET_TRACE_MEM_AWIDTH),      //positive integer
      .READ_RESET_VALUE_A ({RXDET_TRACE_DWIDTH{1'b0}}),  //vector of READ_DATA_WIDTH_A bits
      .READ_LATENCY_A     (2),      //non-negative integer
    
      // Port B module parameters
      .READ_DATA_WIDTH_B  (16),  //positive integer
      .ADDR_WIDTH_B       (RXDET_TRACE_MEM_AWIDTH),      //positive integer
      .READ_RESET_VALUE_B ({16{1'b0}}),  //vector of READ_DATA_WIDTH_B bits
      .READ_LATENCY_B     (2)       //non-negative integer
    
    ) rxdet_trc_mem_inst (
      // Port A module ports
      .clka   (pclk),
      .rsta   (~prst_n),
      .ena    (rxdet_lane_wen[i]),
      .regcea (1'b1),  //do not change
      .wea    (rxdet_lane_wen[i]),
      .addra  (rxdet_iter_cnt),
      .dina   (rxdet_trace[i]),
      .douta  (),
    
      // Port B module ports
      .clkb   (trc_clk),
      .rstb   (~trc_rst_n),
      .enb    (rxdet_trc_mem_rd),     //TODO
      .regceb (1'b1),  //do not change
      .addrb  (trc_addr[RXDET_TRACE_MEM_AWIDTH-1:0]),
      .doutb  (rxdet_lane_trace[i])
    );

     always @ (posedge trc_clk) begin
       if(~trc_rst_n) 
           rxdet_lane_trace_r[i] <= 16'b0;
       else 
           rxdet_lane_trace_r[i] <= rxdet_lane_trace[i];
     end

   end
end
endgenerate

/*******************************************************************************/
// Active probes, sync to the trc_clk domain
// 
/*******************************************************************************/
wire [4:0] cfg_negotiated_width_sync;
wire [2:0] cfg_current_speed_sync;

xpm_cdc_array_single # (
 .DEST_SYNC_FF   (3),
 .SIM_ASSERT_CHK (0),
 .SRC_INPUT_REG  (1),
 .VERSION        (0),
 .WIDTH          (5)
) negotiated_width_xpm_cdc_array_single_inst (
  .src_clk (user_clk),
  .src_in  (cfg_negotiated_width),
  .dest_clk(trc_clk) ,
  .dest_out(cfg_negotiated_width_sync)
);

xpm_cdc_array_single # (
 .DEST_SYNC_FF   (3),
 .SIM_ASSERT_CHK (0),
 .SRC_INPUT_REG  (1),
 .VERSION        (0),
 .WIDTH          (3)
) cur_speed_xpm_cdc_array_single_inst (
  .src_clk (user_clk),
  .src_in  (cfg_current_speed),
  .dest_clk(trc_clk) ,
  .dest_out(cfg_current_speed_sync)
);


/*******************************************************************************/
//read data mux
//Trace access memory:
// 0x00000 ~ 0x00FFF: reserved for static information
// 0x01000 ~ 0x01FFF: LTSSM trace memory
// 0x02000 ~ 0x02007: reset trace memory
// 0x03000 ~ 0x03FFF: Receiver detection trace
//              0x030i0 ~ 0x030iF : Receiver detection for lane i
// 0x04000 ~ 0x04FFF: probes for active signals
/*******************************************************************************/
reg   [3:0]  trc_rd_wdn; 
reg   [15:0] trc_rdt_muxed;
reg   [15:0] trc_rdt_reg;

assign trc_do           = trc_rdt_reg;
assign reset_trc_mem_rd = trc_rd_wdn[0] | trc_rd_wdn[1] | trc_rd_wdn[2];
assign ltssm_trc_mem_rd = trc_rd_wdn[0] | trc_rd_wdn[1] | trc_rd_wdn[2];
assign rxdet_trc_mem_rd = trc_rd_wdn[0] | trc_rd_wdn[1] | trc_rd_wdn[2];
assign trc_rdy          = trc_rd_wdn[3];

always @ (*) begin
    trc_rdt_muxed = 16'hdead;
    if(&trc_addr[16:4]) begin
        case (trc_addr[3:0])
            4'h0 : trc_rdt_muxed = C_XSDB_SLAVE_TYPE  ;
            4'h1 : trc_rdt_muxed = C_XSDB_CSE_DRV_VER ;
            4'h2 : trc_rdt_muxed = C_XSDB_CORE_TYPE   ;
            4'h3 : trc_rdt_muxed = C_XSDB_CG_VER      ;
            4'h4 : trc_rdt_muxed = C_XSDB_CG_ALPHA_VER;
            4'h5 : trc_rdt_muxed = C_XSDB_EDA_VER     ;
            4'h6 : trc_rdt_muxed = 16'habcd            ; //test register
            4'h7 : trc_rdt_muxed = C_XSDB_NEXT_SLAVE;
        endcase
    end else begin
        case (trc_addr[16:12]) 
            5'h1 : trc_rdt_muxed = ltssm_mem_rdata;
            5'h2 : trc_rdt_muxed = reset_st_trc;
            5'h3 : trc_rdt_muxed = rxdet_lane_trace_r[trc_addr[4+:4]];
            5'h4 : begin
              case(trc_addr[1:0]) 
			    2'h0 : trc_rdt_muxed = PHY_LANE;
                2'h1 : trc_rdt_muxed = cfg_negotiated_width_sync;
                2'h2 : trc_rdt_muxed = cfg_current_speed_sync;
              endcase
            end
        endcase
    end
end
        
always @ (posedge trc_clk) 
    if(~trc_rst_n)
        trc_rdt_reg <= 16'h0;
    else 
        trc_rdt_reg <= trc_rd_wdn[2] ? trc_rdt_muxed : trc_rdt_reg;

always @ (posedge trc_clk) begin
    if(~trc_rst_n) begin
        trc_rd_wdn <= 4'b0;
    end else if (trc_en & ~|(trc_rd_wdn)) begin
        trc_rd_wdn <= 4'b1;
    end else begin
        trc_rd_wdn[0] <=1'b0;
        trc_rd_wdn[3:1] <= trc_rd_wdn[2:0];
    end
end

function [7:0] binary2Onehot_3bit;
input [2:0] code_bin;
begin
    case(code_bin) 
        3'b000: binary2Onehot_3bit = 8'b00000001;
        3'b001: binary2Onehot_3bit = 8'b00000010;
        3'b010: binary2Onehot_3bit = 8'b00000100;
        3'b011: binary2Onehot_3bit = 8'b00001000;
        3'b100: binary2Onehot_3bit = 8'b00010000;
        3'b101: binary2Onehot_3bit = 8'b00100000;
        3'b110: binary2Onehot_3bit = 8'b01000000;
        3'b111: binary2Onehot_3bit = 8'b10000000;
     endcase
end
endfunction 

endmodule

//-----------------------------------------------------------------------------
//
// (c) Copyright 2012-2012 Xilinx, Inc. All rights reserved.
//
// This file contains confidential and proprietary information
// of Xilinx, Inc. and is protected under U.S. and
// international copyright and other intellectual property
// laws.
//
// DISCLAIMER
// This disclaimer is not a license and does not grant any
// rights to the materials distributed herewith. Except as
// otherwise provided in a valid license issued to you by
// Xilinx, and to the maximum extent permitted by applicable
// law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
// WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
// AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
// BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
// INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
// (2) Xilinx shall not be liable (whether in contract or tort,
// including negligence, or under any other theory of
// liability) for any loss or damage of any kind or nature
// related to, arising under or in connection with these
// materials, including for any direct, or any indirect,
// special, incidental, or consequential loss or damage
// (including loss of data, profits, goodwill, or any type of
// loss or damage suffered as a result of any action brought
// by a third party) even if such damage or loss was
// reasonably foreseeable or Xilinx had been advised of the
// possibility of the same.
//
// CRITICAL APPLICATIONS
// Xilinx products are not designed or intended to be fail-
// safe, or for use in any application requiring fail-safe
// performance, such as life-support or safety devices or
// systems, Class III medical devices, nuclear facilities,
// applications related to the deployment of airbags, or any
// other applications that could lead to death, personal
// injury, or severe property or environmental damage
// (individually and collectively, "Critical
// Applications"). Customer assumes the sole risk and
// liability of any use of Xilinx products in Critical
// Applications, subject only to applicable laws and
// regulations governing limitations on product liability.
//
// THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
// PART OF THIS FILE AT ALL TIMES.
//
//-----------------------------------------------------------------------------
//
// Project    : UltraScale+ FPGA PCI Express v4.0 Integrated Block
// File       : qdma_no_sriov_pcie4_ip_debug_axi4l_s.v
// Version    : 1.3 
//-----------------------------------------------------------------------------
//------------------------------------------------------------------------------

`timescale 1ns/1ns

//AXI4-LITE slave interface to bridge the DRP like debugging trace interface

module qdma_no_sriov_pcie4_ip_debug_axi4l_s # (

    parameter S_AXI_ADDR_WIDTH = 32,
    parameter S_AXI_DATA_WIDTH = 32
)(
  //--------------  AXI Interface Signals         --------------
  input                             AXI_aclk,
  input                             AXI_aresetn,
  
 (* mark_debug = "TRUE" *) input  [S_AXI_ADDR_WIDTH-1:0]     S_AXI_araddr,
 (* mark_debug = "TRUE" *) output reg                        S_AXI_arready,
 (* mark_debug = "TRUE" *) input                             S_AXI_arvalid,
 (* mark_debug = "TRUE" *) input  [2:0]                      S_AXI_arprot,
  
  input [S_AXI_ADDR_WIDTH-1:0]      S_AXI_awaddr,
  output reg                        S_AXI_awready,
  input                             S_AXI_awvalid,
  input  [2:0]                      S_AXI_awprot,
  
  output [1:0]                      S_AXI_bresp,  
  input                             S_AXI_bready,
  output reg                        S_AXI_bvalid,
  
  output [S_AXI_DATA_WIDTH-1:0]     S_AXI_rdata,
  input                             S_AXI_rready,
  output reg                        S_AXI_rvalid,
  output [1:0]                      S_AXI_rresp,
  
  input  [S_AXI_DATA_WIDTH-1:0]     S_AXI_wdata,
  output reg                        S_AXI_wready,
  input                             S_AXI_wvalid,
  input  [S_AXI_DATA_WIDTH/8-1:0]   S_AXI_wstrb,

  //trace memory access interface (DRP like interface)
  output                            trc_rst_n,
  output                            trc_clk,
 (* mark_debug = "TRUE" *) output                            trc_en, //trace enable
 (* mark_debug = "TRUE" *) output                            trc_wr, //trace write enable //TODO 
 (* mark_debug = "TRUE" *) output reg [16:0]                 trc_addr, //address width compatible with XSDB
 (* mark_debug = "TRUE" *) output [15:0]                     trc_di, //trace write data input
 (* mark_debug = "TRUE" *) input  [15:0]                     trc_do, 
 (* mark_debug = "TRUE" *) input                             trc_rdy

);


localparam IDLE_ST = 3'h0;
localparam WR_ST   = 3'h1;
localparam WR_DATA = 3'h2;
localparam WR_WT   = 3'h3;
localparam WR_RESP = 3'h4;
localparam RD_ST   = 3'h5;
localparam RD_WT   = 3'h6;

reg [2:0] cur_st = IDLE_ST;
reg [2:0] nxt_st ;
reg [2:0] pre_st = IDLE_ST;

//Dummy write interface
wire trc_wr_done ;


assign S_AXI_rdata = {16'h0,trc_do};   //trc_do-->S_AXI_rdata

always @ (posedge AXI_aclk) 
    if(~AXI_aresetn) begin
        pre_st <= IDLE_ST;
        cur_st <= IDLE_ST;
    end else begin
        pre_st <= cur_st;
        cur_st <= nxt_st;
    end

always @ (*) begin
    nxt_st = cur_st;
    case(cur_st) 
        IDLE_ST : begin
            if (S_AXI_awvalid) 
                nxt_st = WR_ST;
            else if (S_AXI_arvalid) 
                nxt_st = RD_ST;
        end
        WR_ST: nxt_st = WR_DATA;
        WR_DATA: begin
            if(S_AXI_wvalid)
                nxt_st = WR_WT;
        end
        WR_WT:
            if ( trc_wr_done || S_AXI_bresp[0] )
                nxt_st = WR_RESP;
        WR_RESP:
            if(S_AXI_bvalid & S_AXI_bready & S_AXI_arvalid) 
                nxt_st = RD_ST;
            else if (S_AXI_bvalid & S_AXI_bready & !S_AXI_arvalid)
                nxt_st = IDLE_ST;
        RD_ST:
            nxt_st = RD_WT;
        RD_WT: 
            if(trc_rdy | S_AXI_rresp[0])
                nxt_st = IDLE_ST;
    endcase
end

/*******************************************************************************/
//AXI outputs
/*******************************************************************************/
always @ (posedge AXI_aclk)
    if (~AXI_aresetn)
        S_AXI_arready <= 1'b0;
    else if( cur_st == RD_ST) 
        S_AXI_arready <= 1'b1;
    else 
        S_AXI_arready <= 1'b0;

always @ (posedge AXI_aclk)
    if (~AXI_aresetn)
        S_AXI_awready <= 1'b0;
    else if( cur_st == WR_ST) 
        S_AXI_awready <= 1'b1;
    else 
        S_AXI_awready <= 1'b0;

always @ (posedge AXI_aclk)
    if (~AXI_aresetn)
        S_AXI_bvalid <= 1'b0;
    else if ( S_AXI_bvalid & S_AXI_bready) 
        S_AXI_bvalid <= 1'b0;
    else if ( cur_st == WR_RESP) 
        S_AXI_bvalid <= 1'b1;

always @ (posedge AXI_aclk)
    if (~AXI_aresetn)
        S_AXI_rvalid <= 1'b0;
    else if ( S_AXI_rvalid & S_AXI_rready) 
        S_AXI_rvalid <= 1'b0;
    else if ( cur_st == RD_WT & (trc_rdy | S_AXI_rresp[0]) ) 
        S_AXI_rvalid <= 1'b1;

always @ (posedge AXI_aclk) 
    if (~AXI_aresetn)
        S_AXI_wready <= 1'b0;
    else if (S_AXI_wready & S_AXI_wvalid ) 
        S_AXI_wready <= 1'b0;
    else if (cur_st == WR_DATA & S_AXI_wvalid)
        S_AXI_wready <= 1'b1;

//TODO: error response
assign S_AXI_rresp = 2'b0;
assign S_AXI_bresp = 2'b0;
/*******************************************************************************/
// TRACE access
/*******************************************************************************/
always @ (posedge AXI_aclk) 
begin
    if (~AXI_aresetn) 
        trc_addr <= 17'h0;
    else if (cur_st == WR_ST) 
        trc_addr <= S_AXI_awaddr[16:0];
    else if (cur_st == RD_ST)
        trc_addr <= S_AXI_araddr[16:0];
end

assign trc_en      = (cur_st == RD_ST);
assign trc_wr      = 1'b0;
assign trc_rst_n   = AXI_aresetn;
assign trc_clk     = AXI_aclk;
assign trc_wr_done = 1'b1;

endmodule

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1917865.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

经典文献阅读之--DEviLOG(使用合成数据和真实世界数据的数据驱动占用网格映射基于Transformer的BEV方案量产方案)

Tip: 如果你在进行深度学习、自动驾驶、模型推理、微调或AI绘画出图等任务&#xff0c;并且需要GPU资源&#xff0c;可以考虑使用UCloud云计算旗下的Compshare的GPU算力云平台。他们提供高性价比的4090 GPU&#xff0c;按时收费每卡2.6元&#xff0c;月卡只需要1.7元每小时&…

【中项第三版】系统集成项目管理工程师 | 第 11 章 规划过程组② | 11.3 - 11.5

前言 第 11 章对应的内容选择题和案例分析都会进行考查&#xff0c;这一章节属于10大管理的内容&#xff0c;学习要以教材为准。本章上午题分值预计在15分。 目录 11.3 收集需求 11.3.1 主要输入 11.3.2 主要工具与技术 11.3.3 主要输出 11.4 定义范围 11.4.1 主要输入…

Hi3861 OpenHarmony嵌入式应用入门--HTTPD

httpd 是 Apache HTTP Server 的守护进程名称&#xff0c;Apache HTTP Server 是一种广泛使用的开源网页服务器软件。 本项目是从LwIP中抽取的HTTP服务器代码&#xff1b; Hi3861 SDK中已经包含了一份预编译的lwip&#xff0c;但没有开启HTTP服务器功能&#xff08;静态库无法…

C# 解析省份、城市、区域 json文件

一、json文件内容如下&#xff0c;&#xff08;小程序里好像有用到...&#xff09;: 二、读取包含省份城市区域的json文件&#xff0c;并整理成想要的结果&#xff1a; string path Server.MapPath("/js"); string file System.IO.Path.Combine(path, "数据.…

Hi3861 OpenHarmony嵌入式应用入门--华为 IoTDA 设备接入

华为云物联网平台&#xff08;IoT 设备接入云服务&#xff09;提供海量设备的接入和管理能力&#xff0c;可以将自己的 IoT 设备 联接到华为云&#xff0c;支撑设备数据采集上云和云端下发命令给设备进行远程控制&#xff0c;配合华为云物联网平台的服 务实现设备与设备之间的控…

MySQL的约束键多表查询

约束 概念 概念&#xff1a;约束是作用于表中字段上的规则&#xff0c;用于限制存储在表中的数据。目的&#xff1a;保证数据中数据的正确、有效性和完整性。 外键约束 概念 ​ 外键用来让两张表的数据之间建立连接&#xff0c;从而保证数据的一致性和完整性。 注意&#x…

钉钉扫码登录第三方

钉钉文档 实现登录第三方网站 - 钉钉开放平台 (dingtalk.com) html页面 将html放在 <!DOCTYPE html> <html lang"en"><head><meta charset"UTF-8"><title>登录</title>// jquery<script src"http://code.jqu…

PHP趣味测评微信小程序开发搭建趣味测评流量主变现系统

趣味测评微信小程序&#xff1a;开发搭建&#xff0c;乐在其中&#x1f389; &#x1f31f;【开篇&#xff1a;探索趣味测评的魅力】&#x1f31f; 你是否厌倦了千篇一律的问卷调查&#xff1f;想要来点不一样的互动体验&#xff1f;那么&#xff0c;趣味测评微信小程序绝对是…

为什么大多数过来人还是建议你考一本HCIE

HCIE认证是华为推出的高级网络工程师认证。 然而&#xff0c;对于是否值得考取HCIE&#xff0c;许多人有不同的看法。 有些人质疑它的价值&#xff0c;但也有很多过来人强烈推荐。 今天探讨一番。为什么尽管有质疑声&#xff0c;许多经验丰富的老网工还是建议你考一本HCIE。 01…

自动清理群晖nas中的.TMP文件

公司某个部门需要使用群晖nas共享盘&#xff0c;对人员的相关权限有要求&#xff0c;部分人员对于某个文件夹&#xff0c;以及里面的文件不能有删除权限&#xff0c;在用户被剥夺了删除权限后&#xff0c;造成了一个问题&#xff0c;那就是这些没有删除权限的人员&#xff0c;在…

精益创业方法论在创业实践中的应用:以乔布斯视角探索创新与变革的艺术——张驰咨询

史蒂夫乔布斯以其非凡的愿景、不懈的迭代精神与对产品极致的追求&#xff0c;成为无数创业者心中的灯塔。本文将借鉴乔布斯的创新思维与精益创业方法论相结合&#xff0c;构建一套融合理论与实践的深度框架&#xff0c;旨在指导创业者在不确定的市场环境中高效探索、快速验证并…

jvm 07 GC算法,内存池,对象内存分配

01 垃圾判断算法 1.1引用计数算法 最简单的垃圾判断算法。在对象中添加一个属性用于标记对象被引用的次数&#xff0c;每多一个其他对象引用&#xff0c;计数1&#xff0c; 当引用失效时&#xff0c;计数-1&#xff0c;如果计数0&#xff0c;表示没有其他对象引用&#xff0c;…

Springboot 设置个性化banner

在 Spring Boot 中自定义 banner 的方法有几种&#xff0c;可以通过以下步骤来实现&#xff1a; 1、使用文本文件作为 banner 在 src/main/resources 目录下创建一个名为 banner.txt 的文件。 编辑这个文件&#xff0c;输入想要显示的文本。确保文本中包含换行符和空格…

【排序 - 插入排序 和 希尔排序】

插入排序&#xff08;Insertion Sort&#xff09;是一种简单直观的排序算法&#xff0c;它的工作原理是逐步构建有序序列。在排序过程中&#xff0c;它将未排序的元素逐个插入到已排序的部分中&#xff0c;从而在每次插入时扩展已排序序列的长度。 原理介绍 插入排序的基本思…

mindspore打卡20天之Shufflenet图像分类

ShuffleNet图像分类 当前案例不支持在GPU设备上静态图模式运行&#xff0c;其他模式运行皆支持。 ShuffleNet网络介绍 ShuffleNetV1是旷视科技提出的一种计算高效的CNN模型&#xff0c;和MobileNet, SqueezeNet等一样主要应用在移动端&#xff0c;所以模型的设计目标就是利用有…

浅谈后置处理器之边界提取器

浅谈后置处理器之边界提取器 边界提取器&#xff08;Boundary Extractor&#xff09;作为一种常用的后置处理器&#xff0c;主要用于从服务器响应中提取特定内容&#xff0c;这些内容可以是文本、变量或cookies等&#xff0c;以便于后续请求中重用。本文档将详细介绍如何在JMe…

高阶面试-dubbo的学习

SPI机制 SPI&#xff0c;service provider interface&#xff0c;服务发现机制&#xff0c;其实就是把接口实现类的全限定名配置在文件里面&#xff0c;然后通过加载器ServiceLoader去读取配置加载实现类&#xff0c;比如说数据库驱动&#xff0c;我们把mysql的jar包放到项目的…

人员定位系统可以用在哪些方面?为什么这么受欢迎?

人员定位系统大家都不陌生&#xff0c;它也随着科技的发展变得越来越高端、功能也越来越完善了。从一开始的对讲机沟通到后来的蓝牙定位等等&#xff0c;定位系统的精准度越来越高不说&#xff0c;续航能力也越来也强&#xff0c;以往比较单一和迷你的汽车定位产品都能达到一年…

《故障复盘 · 记一次事务用法错误导致的大量锁表问题》

&#x1f4e2; 大家好&#xff0c;我是 【战神刘玉栋】&#xff0c;有10多年的研发经验&#xff0c;致力于前后端技术栈的知识沉淀和传播。 &#x1f497; &#x1f33b; CSDN入驻不久&#xff0c;希望大家多多支持&#xff0c;后续会继续提升文章质量&#xff0c;绝不滥竽充数…

VS2019使用C#写窗体程序技巧(1)

1、打开串口 private void button1_Click(object sender, EventArgs e){myPort cmb1.Text;mybaud Convert.ToInt32(cmb2.Text, 10);databit 8;parity Parity.None;stopBit StopBits.One;textBox9.Text "2";try{sp new SerialPort(myPort, mybaud, parity, dat…