Xilinx FPGA AXI接口仿真及JTAG to AXI Master IP调试

前言

  在进行FPGA开发时,经常会用到AXI总线,但由于仿真和实际调试中,对AXI总线的操作较为繁琐,本问提出如何在仿真中产生AXI master激励并且在调试过程中,在没有PS的情况下如何调试AXI master接口。

1、 AXI master仿真接口

1.1 仿真代码准备

  以XIlinx AXI JTAG 代码例程为例子
  其中需要修改的配置如下:
  (1) ·define dut_path xx修改,将xx改为需要替换AXI_lite master信号所在模块,如例程代码中直接替换顶层仿真文件tb_uart中axi信号,直接指向顶层即可。
  (2) 修改代码中`dut_path.xx的信号名称,修改xx使之与需要仿真的信号名称一致,这样,就可以采用该代码实现AXI_lite master仿真

  • 所有代码如下:
`define dut_path  tb_uart
//-----------------------------------------------------------------------------
module tb_jtag_axi4lite_rw ( 
  input  wire enable_read_messaging ,
  input  wire enable_write_messaging 

  );

localparam A_IDLE = 'd0;
localparam WR0    = 'd1;
localparam WR1    = 'd2;
localparam RD0    = 'd3;
localparam RD1    = 'd4;
  
//---------------------------------------------------------------------------
// AXI-Lite Interface
//----------------------------------------------------------------------------
reg         wr_req         = 0      ; // 
reg         rd_req         = 0      ; // 
reg  [31:0] address        = 0      ; // 
reg  [31:0] wr_data        = 0      ; // 
reg  [31:0] rd_data        = 0      ; // 
reg   [3:0] accessor       = 0      ; //

//----------------------------------------------------------------------------
// AXI-Lite Interface
//----------------------------------------------------------------------------
reg         clk           = 0       ; // 
reg         aresetn       = 0       ; // 

reg  [31:0] axi_awaddr              ;  // 
reg         axi_awvalid             ;  // 
reg         axi_awready             ;  // 
reg   [3:0] axi_wstrb               ;  // 

reg  [31:0] axi_wdata               ;  // 
reg         axi_wvalid              ;  // 
reg         axi_wready              ;  // 

reg   [1:0] axi_bresp               ;  //

reg         axi_bvalid              ;  // 
reg         axi_bready              ;  // 

reg  [31:0] axi_araddr              ;  // 
reg         axi_arvalid             ;  // 
reg         axi_arready             ;  // 

reg  [31:0] axi_rdata               ;  // 
reg   [1:0] axi_rresp               ;  // 
reg         axi_rvalid              ;  // 
reg         axi_rready              ;  // 

  // Status
reg         access_busy    = 0      ;  // 

//---------------------------------------------------------------------------
// AXI write task.
//---------------------------------------------------------------------------
task axi_write;
  input [31:0] addr;
  input [31:0] data;
  begin
    while (access_busy)       // Wait on other tasks completing
      @(posedge clk);
    
    @(posedge clk);        // Drive Address, data and the request flag
    wr_req  <= 1'b1;
    wr_data <= data;
    address <= addr;

    while (access_busy == 0)  // Wait until the AXI convertor is busy
      @(posedge clk);

    wr_req  <= 1'b0;       // Clear the request

    while (access_busy)       // Wait for the AXI4-Lite transaction to complete
      @(posedge clk);

    if (enable_write_messaging)
      $display ("MWR: @ 0x%8x = 0x%x", address, data);

  end
endtask // axi_write

//---------------------------------------------------------------------------
// AXI read task.
//---------------------------------------------------------------------------
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值