原创 如何理解Xilinx的BMD?

2019-8-14 12:20 8038 44 3 分类: FPGA/CPLD 文集: Xilinx PCIe仿真模型
BM是Bus Master的缩写,其中D是DMA。xapp1052讲使用PCIe的系统中通常有两种硬件实现的DMA,一种是系统DMA(System DMA),另外一种是总线主机DMA。
系统DMA通常是位于总线中心位置,且为总线中所有设备所共享,当前这种实现方式已经不多见了。如今在基于PCIe的系统中最常见的还是BMD,BMD由位于Endpoint的设备实现,之所以称为总线主机(Bus Masters),是因为数据写入系统内存或从系统内存读回都是由它们发起(这里说“发起”应该不准确,实际上发起方还是Host,因为需要host写DMA控制寄存器并“Start”DMA,然后Endpoint才能开始启动DMA操作的。
在实际设计的时候,记得将Endpoint的Bus Master Enable位设置为‘1’,该使能位位于PCI命令寄存器中(比特2),而PCI命令寄存器则位于PCI配置空间的04~05h。下图是PCI命令寄存器各段详细定义。这里重点说下Bus Master,该比特设置为1,表示本设备被设置为总线主机。

下图展示了PCI命令寄存器位于PCI配置空间的具体位置:



所以,xapp1052通篇都是基于将Endpoint作为总线主机来描述的。而当我们查看参考设计的时候,由于是DS端口模型,即downstream 端口模型,此时应该是没有设置Endpoint为总线主机,所有TLP都是由模拟的RP下发。

xapp1052参考设计的仿真似乎根本不支持BMD,在其测试文件ursapp_tx里对应PCI命令寄存器是这样配置的:

// Program PCI Command Register
  • TSK_TX_TYPE0_CONFIGURATION_WRITE(DEFAULT_TAG, 12'h04, 32'h00000003, 4'h1);
  • DEFAULT_TAG = DEFAULT_TAG + 1;
  • TSK_TX_CLK_EAT(100);
  • 复制代码

    而实际参考其它人自行修改的测试文件,对应PCI命令寄存器的配置应该是这样的(如果是测试BMD就将PCI命令寄存器的bit-2置位,否则写0):

    // Program PCI Command Register
  • if(testname == "bmd")
  • TSK_TX_TYPE0_CONFIGURATION_WRITE(DEFAULT_TAG, 12'h04, 32'h00000007, 4'h1);
  • else
  • TSK_TX_TYPE0_CONFIGURATION_WRITE(DEFAULT_TAG, 12'h04, 32'h00000003, 4'h1);
  • DEFAULT_TAG = DEFAULT_TAG + 1;
  • TSK_TX_CLK_EAT(100);
  • 复制代码


    下面是一段Xilinx工程师对xapp1052参考设计的说明:

    The flow for this application is:
  • 1) Driver sends down 1DW MRD and MWR requests to the EP to program backend descriptor registers. The last MWR starts the DMA transfer by writing to the control register.
  • 2) The TX engine sends out MRD and/or MWR requests to the root.
  • 3) After the requested data is transfered, the EP interrupts the driver.
  • 4) The driver comes down and verifies the transfer is complete by reading the backend descriptor registers and it also gets the performance information from the EP.
  • 复制代码

    附加一个下载Windriver的链接:https://www.jungo.com/st/contact-form-2/?product=WinDriver

    作者: coyoo, 来源:面包板社区

    链接: https://mbb.eet-china.com/blog/uid-me-1010859.html

    版权声明:本文为博主原创,未经本人允许,禁止转载!

    PARTNER CONTENT

    文章评论0条评论)

    登录后参与讨论
    我要评论
    0
    44
    关闭 站长推荐上一条 /3 下一条