pcie block plus使用tips

来源:互联网 发布:什么约会软件好 编辑:程序博客网 时间:2024/06/01 09:28

1、在pcie_blk_plus_ll_rx.v文件中增加:

`ifndef TCQ

 `define TCQ 1

`endif

2、仿真入口在pci_exp_usrapp_tx.v

         initial begin

   if ($value$plusargs("TESTNAME=%s", testname))

     $display("Running test {%0s}......", testname);

   else

   begin

     // $display("[%t] %m: No TESTNAME specified!", $realtime);

     // $finish(2);

     testname = "sample_smoke_test0";

     $display("Running default test {%0s}......", testname);

   end

   expect_status = 0;

   expect_finish_check = 0;

   // Tx transaction interface signal initialization.

   trn_td     = 0;

   trn_tsof_n = 1;

   trn_teof_n = 1;

   trn_trem_n = 0;

   trn_terrfwd_n = 1;

   trn_tsrc_rdy_n = 1 ;

   trn_tsrc_dsc_n = 1;

 

   // Payload data initialization.

   TSK_USR_DATA_SETUP_SEQ;

 

   //Test starts here

   if (testname == "dummy_test")

   begin

     $display("[%t] %m: Invalid TESTNAME: %0s", $realtime,testname);

     $finish(2);

   end

   `include "tests.v"

   else begin

     $display("[%t] %m: Error: Unrecognized TESTNAME: %0s",$realtime, testname);

     $finish(2);

   end

  end

3、一定要单独生成核,再包含各个文件

       否则,会产生不需要的vhdl文件,仿真也会出问题。

4、独立选项

4.1 vsim的选项

vsim 中有以下参数:

(1)+TESTNAME=sample_smoke_test0:用于指定仿真名称

vsim有两个相近的option:

#    -g<Name>=<Value>        Specify generic/parameter default Valuefor Name

#    -G<Name>=<Value>        Override generic/parameter withspecified Value

虽然没有明确的证据表明+xxx=xxx等价于上面的-Gxxx=xxx,大概理解其意思就可以。

找到真正的原因了,是在pci_exp_usr_tx.v文件中有$value$plusargs这个函数,这个函数就是来寻找vsim这种附加参数的。

(2)后仿的时候注意:-L xilinxcorelib_ver -L unisims_ver -L unimacro_ver

4.2 vlog的选项

仿真的时候:+define+BOARDx01 +define+SIM_USERTB +define+SIMULATION

5、“Unsupported target”

(1)报错:Unsupported  target.

cfg_to_turnoff_n是out,它给写成了In,导致例化的时候我把它例化了一个常数。例化的时候把这个端口选口就可以了,如果不用的话。

6、Completer ID的问题

Identifies the completer being accessedwith this configuration cycle. The Bus and Device numbers in this field are"captured" by the device on each configuration Type 0 write.

也即,在配置的时候并不直接对三个号()进行配置,靠PCIE协议的一个机制:不是自己的包不会收到。所以,每次Configuration Write中的这三个号都会被接收方用来更新自己的这三个号!!!!

Byte 8, 7:0 = Bus Number

Byte 9, 7:3 = Device Number

Byte 9, 2:0 = Function Number

 

在pci_exp_usrapp_tx.v中,

在一开始添加(不用添加,本来就有):

reg[15:0] REQUESTER_ID;

在initial中,将REQUESTER_ID改值为0;

initial

begin

//…

REQUESTER_ID = 16’b0;

end

ConfigurationWrite和Read这4个task是错误的。

           TSK_TX_SYNCHRONIZE(0, 0);

 

           trn_td             <=#(Tcq)   {

                                          1'b0,

                                          2'b10,

                                          5'b00101,

                                          1'b0,

                                           3'b000,

                                          4'b0000,

                                          1'b0,

                                          1'b0,

                                          2'b00,

                                           2'b00,

                                          10'b0000000001, // 32

                                           REQUESTER_ID,//COMPLETER_ID_CFG------------

                                          tag_,

                                           4'b0000,

                                          first_dw_be_    // 64

                                           };

所有task都错了。

 

7、关于TEST FAILED --- Haven't Received All Expected TLPs

这个信息会永远存在,它会启动一个定时器,然后当最后一个包的延迟之后,它会产生这个信息。

PIO在仿真的时候,仿完了之后加入

$display("[%t] : Finished transmissionof PCI-Express TLPs", $realtime);

$finish;

强制终止,避免了该信息的产生。自己编写的时候在确保的确收到了所有的包(对所有的要求回复的task使用TSK_WAIT_FOR_READ_DATA;这个语句即可。例如:

fork

TSK_TX_MEMORY_READ_32(DEFAULT_TAG,DEFAULT_TC, 10'd1, BAR_INIT_P_BAR[0][31:0]+8'h10, 4'h0, 4'hF);

TSK_WAIT_FOR_READ_DATA;

 join

最好也要加入$finish;

8、testBench中length大于2的包的数据不能正确写入rx.dat

1、原因:/board/RP 里面的trn_rrem_n总是ZZZZZZZ1或者ZZZZZZZ0,导致了接收时pci_exp_usrapp_rx.v这个文件调用写于pci_exp_usrapp_com.v中的TSK_READ_DATA这个task时,写入文件错误。

追踪trn_rrem_n这个信号,最终位于:/board/RP/rport/pcie_2_0_i/pcie_block_i,它是由源语PCIE_2_0例化出来的,它的TRNRREMN这个信号上。

       也即:源语PCIE_2_0的仿真模型有错或者生成的这个代码对这个模型的使用有误,导致了错误。

2、采用Fix AR#33918后,TRNRREMN这个信号不会是Z了。但是,/board/RP里面的trn_rrem_n总是ZZZZZZZ1或者ZZZZZZZ0。

就是在/board/RP里面,对pcie_2_0_i的映射时,将其1bit宽的信号TRNRREMN映射到了8bit宽的信号trn_rrem_n上。导致了接收时pci_exp_usrapp_rx.v这个文件调用写于pci_exp_usrapp_com.v中的TSK_READ_DATA这个task时,写入文件错误。

3、修改pci_exp_usrapp_com.v中的TSK_READ_DATA这个地方。将:

_rem = last ? ((trn_rem == 8'h0F) ? 4 : 8): 8;

修改为:

_rem = last ? ((trn_rem[0] == 1'b1) ? 4 :8) : 8;

这样就成功了。

 

注:Fix AR#33918的解决方案:

1. Make the following changes to the parameters in the pcie_2_0_rport_v6.v

file found in the <core name>/simulation/dsport directory.

parameter BAR0 = 32'h00000000,

parameter BAR1 = 32'h00000000,

parameter BAR2 = 32'h00FFFFFF,

parameter BAR3 = 32'hFFFF0000,

parameter BAR4 = 32'hFFF0FFF0,

parameter BAR5 = 32'hFFF1FFF1,

 

parameter DISABLE_BAR_FILTERING = "TRUE",

parameter DISABLE_ID_CHECK = "TRUE",

 

parameter DISABLE_RX_TC_FILTER = "TRUE",

parameter HEADER_TYPE = 8'h01,

parameter PCIe_CAP_DEVICE_PORT_TYPE = 4'b0100,

 

2. Replace the pci_exp_usrapp_cfg.v with the one that included in the zipfile.

This file provides the tasks necessary to make the write to the command

register using the back end configuration port.

 

3. Call the task TSK_WRITE_CFG_DW in you testbench as shown below before

you issue your first write from the endpoint:不知道为什么,不加上这句话的话,RP不能够接收Read和Write包。所以,如果DUT想发Read或Write包,一定在此前加上这句话。

还有如果想接收中断的话,那么加上这句话就能在rx.dat中,发现一个64Address的Mem Write。这就是中断。

board.RP.cfg_usrapp.TSK_WRITE_CFG_DW(32'h00000004, 32'h00000007, 4'b1110);

 

9、UCF

(1)自己写的

随核带来的UCF都不对

正确的UCF:

###############################################################################

#

# File:  xilinx_pci_exp_blk_plus_1_lane_ep_xc5vfx70t-ff1136-2_X0Y1.ucf

#

# Use this file only with the device listedbelow.  Any other

# combination is invalid.  Do not modify this file except in

# regions designated for "User"constraints.

#

# Copyright (c) 2009 Xilinx, Inc.  All rights reserved.

#

###############################################################################

# Define Device, Package And Speed Grade

###############################################################################

 

CONFIG PART = XC5VFX70T-FF1136-2;

 

###############################################################################

# User Time Names / User Time Groups / TimeSpecs

###############################################################################

 

# CONFIG STEPPING = "ES" ;

 

###############################################################################

# User Physical Constraints

###############################################################################

 

 

###############################################################################

# Pinout and Related I/O Constraints

###############################################################################

 

#

# SYS reset (input) signal.  The sys_reset_n signal should be

# obtained from the PCI Express interfaceif possible.  For

# slot based form factors, a system resetsignal is usually

# present on the connector.  For cable based form factors, a

# system reset signal may not beavailable.  In this case, the

# system reset signal must be generatedlocally by some form of

# supervisory circuit.  You may change the IOSTANDARD and LOC

# to suit your requirements and VCCOvoltage banking rules.

#

 

NET "sys_reset_n"      LOC = "E9"  | IOSTANDARD = LVCMOS25 | PULLUP | NODELAY ;

 

#

# SYS clock 250 MHz (input) signal. Thesys_clk_p and sys_clk_n

# signals are the PCI Express referenceclock. Virtex-5 GTP

# Transceiver architecture requires the useof a dedicated clock

# resources (FPGA input pins) associatedwith each GTP Transceiver Tile.

# To use these pins an IBUFDS primitive(refclk_ibuf) is

# instantiated in user's design.

# Please refer to the Virtex-5 GTPTransceiver User Guide

# (UG196) for guidelines regarding clockresource selection.

#

 

 

INST "refclk_ibuf"     DIFF_TERM = "TRUE" ;

 

#

# Transceiver instance placement.  This constraint selects the

# transceivers to be used, which alsodictates the pinout for the

# transmit and receive differentialpairs.  Please refer to the

# Virtex-5 GTP Transceiver User Guide(UG196) for more

# information.

#

# PCIe Lanes 0

INST"ep/pcie_ep0/pcie_blk/SIO/.pcie_gt_wrapper_i/GTD[0].GT_i" LOC =GTX_DUAL_X0Y2;

 

#

# PCI Express Block placement. Thisconstraint selects the PCI Express

# Block to be used.

#

 

INST"ep/pcie_ep0/pcie_blk/pcie_ep"                      LOC = PCIE_X0Y2;

 

###############################################################################

# Physical Constraints

###############################################################################

 

#

# BlockRAM placement

#

 

INST "ep/pcie_ep0/pcie_blk/pcie_mim_wrapper_i/bram_retry/generate_sdp.ram_sdp_inst"      LOC = RAMB36_X4Y28 ;

INST"ep/pcie_ep0/pcie_blk/pcie_mim_wrapper_i/bram_tl_tx/generate_tdp2[1].ram_tdp2_inst"LOC = RAMB36_X4Y27 ;

INST"ep/pcie_ep0/pcie_blk/pcie_mim_wrapper_i/bram_tl_rx/generate_tdp2[1].ram_tdp2_inst"LOC = RAMB36_X4Y26 ;

INST"ep/pcie_ep0/pcie_blk/pcie_mim_wrapper_i/bram_tl_tx/generate_tdp2[0].ram_tdp2_inst"LOC = RAMB36_X4Y25 ;

INST"ep/pcie_ep0/pcie_blk/pcie_mim_wrapper_i/bram_tl_rx/generate_tdp2[0].ram_tdp2_inst"LOC = RAMB36_X4Y24 ;

                                                                                    

#

# Switch and Button placement

#

 

NET "sys_clk_p"                 LOC = "AF4"  ;

NET "sys_clk_n"                 LOC = "AF3"  ;

NET "pci_exp_rxp<0>"      LOC = "AE1"  ;

NET "pci_exp_rxn<0>"      LOC = "AF1"  ;

NET "pci_exp_txp<0>"      LOC = "AD2"  ;

NET "pci_exp_txn<0>"      LOC = "AE2"  ;

 

 

###############################################################################

# Timing Constraints

###############################################################################

 

#

# Timing requirements and relatedconstraints.

#

 

 

NET "sys_clk_c"                                      PERIOD =10ns;

NET "usr_clk"                                      PERIOD =16ns;

NET"ep/pcie_ep0/pcie_blk/SIO/.pcie_gt_wrapper_i/gt_refclk_out" TNM_NET ="MGTCLK" ;

 

TIMESPEC "TS_MGTCLK"  = PERIOD "MGTCLK" 100.00 MHz HIGH50 % ;

 

###############################################################################

# End

###############################################################################

(2)PCIE Block和GTX的选取

技术支持的来信

Please make sure the GTX and PCIE cores arematching according to table of 5-3, As below

However if you want to use other lanes, youneed to verify whether the location is valid by trying PAR.

There is no specifying rule on how far PCIEcore should away from GTX.

However you can select all the possible GTXlocations from the table above.

Here is the example from ML507 referencedesign,

# PCIe Lane 0

INST "ep/BU2/U0/pcie_ep0/pcie_blk/SIO/.pcie_gt_wrapper_i/GTD[0].GT_i”;

LOC = GTX_DUAL_X0Y2;

INST"ep/BU2/U0/pcie_ep0/pcie_blk/pcie_ep" LOC = PCIE_X0Y0;

技术支持说:这些是推荐的,最好用这个,不用这个也可能行,但是最终行不行都得自己看PAR的布线。

(3)BlockRam的选取

每一个PCIE的核都要对应一些BlockRam。这些BlockRam对应不好,P&R也可以通过,但是implement就会工作不正常。系统发现不了这块板卡,并且容易造成死机。

这反映了这个Wrapper的设计不是很严禁,并且其时序约束也没有达到这个程度。

所以,对不同的PCIEBlock都要采用它建议的BlockRam。

 

对于PCIE_X0Y0来说

INST "ep/pcie_ep0/pcie_blk/pcie_mim_wrapper_i/bram_retry/generate_sdp.ram_sdp_inst"      LOC = RAMB36_X4Y4 ;

INST"ep/pcie_ep0/pcie_blk/pcie_mim_wrapper_i/bram_tl_tx/generate_tdp2[1].ram_tdp2_inst"LOC = RAMB36_X4Y3 ;

INST"ep/pcie_ep0/pcie_blk/pcie_mim_wrapper_i/bram_tl_rx/generate_tdp2[1].ram_tdp2_inst"LOC = RAMB36_X4Y2 ;

INST"ep/pcie_ep0/pcie_blk/pcie_mim_wrapper_i/bram_tl_tx/generate_tdp2[0].ram_tdp2_inst"LOC = RAMB36_X4Y1 ;

INST"ep/pcie_ep0/pcie_blk/pcie_mim_wrapper_i/bram_tl_rx/generate_tdp2[0].ram_tdp2_inst"LOC = RAMB36_X4Y0 ;

 

10、Maximum Payload Size的问题

(1)Although you have set the supportedpayload size to 512, the final MPS depends on the negotiated value with thehost.

(2)具体的数值在cfg_dcommand[15:0]寄存器里的cfg_dcommand[7:5]位。一会看一下这几个比特。

11、仿真文件结构

仿真文件依托于一个硬核的仿真模型文件:pcie_2_0_v6_rp,将其例化为pcie_2_0_i。这个模块的参数都由其parameter配置好,所以这个模块无须用cfg包来配置。如果需要配置,可以通过cfg接口进行写操作。

这个模块的接口与end block plus for pci express相似。

在此基础上,仿真模型采用了一系列*_usr_app.v文件,这些文件使用上述模块完成了向pcie fabric也就是串行的线上的发送数据和接收数据的工作。这些文件有很多task可以用,比较方便。

12、对中断的仿真

要使用以下Task来使能MSI,同时要使能BusMaster。

1、使能MSI:

         /************************************************************

       Task : TSK_CAPABILITY_SCAN

       Inputs : None

       Outputs : None

       Description : Scans PCI Core's Capabilities registers.

  *************************************************************/

 

   task TSK_MSI_ENABLE ;

      begin

                     DEFAULT_TAG          = 0;

                     DEFAULT_TC                   = 0;

                    

 

       $display("[%t] : Enabling MSI ", $realtime);

               

              TSK_TX_TYPE0_CONFIGURATION_READ(DEFAULT_TAG,12'h48, 4'hF);

                       DEFAULT_TAG = DEFAULT_TAG + 1;

                       TSK_WAIT_FOR_READ_DATA;

                       MSI_Cap_Reg = P_READ_DATA;

             

              if(MSI_Cap_Reg[23]== 1'b0)//32bit Addr

              begin

                     $display("[%t]: 32 Addr;MSI_Cap_Reg:%h", $realtime,MSI_Cap_Reg);  

      

                     TSK_TX_TYPE0_CONFIGURATION_WRITE(DEFAULT_TAG,12'h48,32'h00010000,

4'b0100);

                     TSK_TX_CLK_EAT(500);

                     TSK_TX_TYPE0_CONFIGURATION_WRITE(DEFAULT_TAG,12'h4C,32'ha5a50000,

4'hF);

                     TSK_TX_CLK_EAT(500);

                     TSK_TX_TYPE0_CONFIGURATION_WRITE(DEFAULT_TAG,12'h50,32'h00000000,

4'hF);

                     TSK_TX_CLK_EAT(500);

              end

              else//64bitAddr

              begin                    

                     $display("[%t]: 64 Addr;MSI_Cap_Reg:%h", $realtime,MSI_Cap_Reg);  

             

                     TSK_TX_TYPE0_CONFIGURATION_WRITE(DEFAULT_TAG,12'h48,32'h00010000,

4'b0100);

                     TSK_TX_CLK_EAT(500);

                     TSK_TX_TYPE0_CONFIGURATION_WRITE(DEFAULT_TAG,12'h4C,32'ha5a50000,

4'hF);

                     TSK_TX_CLK_EAT(500);

                     TSK_TX_TYPE0_CONFIGURATION_WRITE(DEFAULT_TAG,12'h50,32'h0000a5a5,

4'hF);

                     TSK_TX_CLK_EAT(500);                 

              end

             

     end

   endtask

 

 

 

endmodule // pci_exp_usrapp_tx

2、使能BusMaster(位于Command[2])

在TSK_BAR_PROGRAM中,对Command寄存器的值应当改为7.也即,要有以下代码:

       //Program PCI Command Register

 

       TSK_TX_TYPE0_CONFIGURATION_WRITE(DEFAULT_TAG, 12'h04, 32'h00000007,4'h1);

       DEFAULT_TAG = DEFAULT_TAG + 1;

       TSK_TX_CLK_EAT(100);

 

3、都配置好后,如果一个中断正常的发生了,那么Rx.dat里面会产生一个64位地址的MemWrite。

但是有的时候就是收不到。

经实践,在Wrapper的顶层文件终有一个选项, 

parameter        MSI = 4'b0001,这种情况下可以收到64位地址的MemWrite

parameter        MSI = 4'b0000,这种情况下不能收到64位地址的MemWrite,这时,可以看到核的cfg_interrupt_rdy_n信号会变为0,这就说明了中断已经成功发出,这就够了。

4、在实际测试的时候,使能MSI后,Command[10]会变成0.并不是说Interrupt被屏蔽了,而是协议规定了,使能MSI后Command[10]就会变成0.

13、trn_rnp_ok_n

任何一个核的问题,要去其配置端口进行仔细寻找。不知cfg接口,trn_接口也存在这种信号,比如:trn_rnp_ok_n

该信号不为0(acitive)会导致接收不正常

14、TSK_TX_MEMORY_WRITE_32的字节顺序

使用该task前要初始化DATA_STORE,该task是这样工作的:

DATA_STORE[0] = 8'ha4;

DATA_STORE[1] = 8'ha5;

DATA_STORE[2] = 8'ha6;

DATA_STORE[3] = 8'ha7;

 

$display("[%t] : MEMWRITE32, Address =%x(Loop)  End,", $realtime,BAOffsetAddr);

TSK_TX_MEMORY_WRITE_32(DEFAULT_TAG,DEFAULT_TC, 10'd1,BAOffsetAddr, 4'h0, 4'hf, 1'b0);

 

这样,接收端得到的trn_rd[31:0]上是a4a5a6a7,也即没有按照DATA_STORE的顺序。

15、关于Bar0的获取

Xilinx技术支持说:根本不用获取Bar0,直接将地址的低几位作为offset即可。她的意思是,Bar0肯定是申请了多少就会有多少个0的。因为pcie的配置过程就是先往bar0里面写全1,然后读取,看看有多少个0,然后读取这个寄存器以决定它要多少空间。然后再配置这个寄存器,那么低位肯定还是0。

16、trn_tdst_rdy_n

这个信号,不知在Buffer不够的时候才会de-assert。我觉得在中断或者其他情况下也会de-assert。

所以发送的事后一定要不断检测这个信号。一旦de-assert就要pend住。

原创粉丝点击