⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pci_exp_usrapp_tx.v

📁 已经在xilinx的ML555开发板上实现的PCIEx4的设计
💻 V
📖 第 1 页 / 共 5 页
字号:
//-- Copyright(C) 2005 by Xilinx, Inc. All rights reserved.//-- This text contains proprietary, confidential//-- information of Xilinx, Inc., is distributed//-- under license from Xilinx, Inc., and may be used,//-- copied and/or disclosed only pursuant to the terms//-- of a valid license agreement with Xilinx, Inc. This copyright//-- notice must be retained as part of this text at all times.`include "../board_common.v"module pci_exp_usrapp_tx                     (                                               trn_td,                                               trn_trem_n,                                               trn_tsof_n,                                               trn_teof_n,                                               trn_terrfwd_n,                                               trn_tsrc_rdy_n,                                               trn_tsrc_dsc_n,                                               trn_clk,                                               trn_reset_n,                                               trn_lnk_up_n,                                               trn_tdst_rdy_n,                                               trn_tdst_dsc_n,                                               trn_tbuf_av                                             );output [(64 - 1):0]       trn_td;output [(8 - 1):0]        trn_trem_n;output                                         trn_tsof_n;output                                         trn_teof_n;output                                         trn_terrfwd_n;output                                         trn_tsrc_rdy_n;output                                         trn_tsrc_dsc_n;input                                          trn_clk;input                                          trn_reset_n;input                                          trn_lnk_up_n;input                                          trn_tdst_rdy_n;input                                          trn_tdst_dsc_n;input  [(`PCI_EXP_TRN_BUF_AV_WIDTH - 1):0]     trn_tbuf_av;/* Output Variables */reg [(64 - 1):0]          trn_td;reg [(8 - 1):0]           trn_trem_n;reg                                            trn_tsof_n;reg                                            trn_teof_n;reg                                            trn_terrfwd_n;reg                                            trn_tsrc_rdy_n;reg                                            trn_tsrc_dsc_n;/* Local Variables */integer                                        i, j, k;reg  [7:0]                                     DATA_STORE [4095:0];reg  [31:0]                                    ADDRESS_32_L;reg  [31:0]                                    ADDRESS_32_H;reg  [63:0]                                    ADDRESS_64;reg  [15:0]                                    COMPLETER_ID;reg  [15:0]                                    COMPLETER_ID_CFG;reg  [15:0]                                    REQUESTER_ID;reg  [15:0]                                    DESTINATION_RID;reg  [2:0]                                     DEFAULT_TC;reg  [9:0]                                     DEFAULT_LENGTH;reg  [3:0]                                     DEFAULT_BE_LAST_DW;reg  [3:0]                                     DEFAULT_BE_FIRST_DW;reg  [1:0]                                     DEFAULT_ATTR;reg  [7:0]                                     DEFAULT_TAG;reg  [3:0]                                     DEFAULT_COMP;reg  [11:0]                                    EXT_REG_ADDR;reg                                            TD;reg                                            EP;reg  [15:0]                                    VENDOR_ID;reg  [9:0]                                     LENGTH; // For 1DW config and IO transactionsreg  [6:0]                                     RAND_;reg  [9:0]                                     CFG_DWADDR;reg  [15:0]                                    P_DEV_BDF;reg  [31:0]                                    P_IO_ADDR;reg  [31:0]                                    P_ADDRESS_1L;reg  [31:0]                                    P_ADDRESS_2L;reg  [31:0]                                    P_ADDRESS_3L;reg  [31:0]                                    P_ADDRESS_4L;reg  [31:0]                                    P_ADDRESS_H;reg  [9:0]                                     P_CFG_DWADDR;event                                          test_begin;reg  [31:0]                                    P_ADDRESS_MASK;reg  [31:0]                                    P_READ_DATA; // will store the results of a PCIE read completionreg  [31:0]                                    data;reg                                            p_read_data_valid;reg             [31:0]                         P_WRITE_DATA;reg  [31:0]                                    temp_register;// BAR Init variablesreg             [32:0]          BAR_INIT_P_BAR[6:0];           // 6 corresponds to Expansion ROM                                                                   // note that bit 32 is for overflow checkingreg             [31:0]          BAR_INIT_P_BAR_RANGE[6:0];     // 6 corresponds to Expansion ROMreg             [1:0]           BAR_INIT_P_BAR_ENABLED[6:0];   // 6 corresponds to Expansion ROM//                              0 = disabled;  1 = io mapped;  2 = mem32 mapped;  3 = mem64 mappedreg             [31:0]          BAR_INIT_P_MEM64_HI_START;     // start address for hi memory spacereg             [31:0]          BAR_INIT_P_MEM64_LO_START;     // start address for hi memory spacereg             [32:0]          BAR_INIT_P_MEM32_START;        // start address for low memory space                                                                   // top bit used for overflow indicatorreg             [32:0]          BAR_INIT_P_IO_START;           // start address for io spacereg             [100:0]         BAR_INIT_MESSAGE[3:0];         // to be used to display info to userreg             [32:0]          BAR_INIT_TEMP;reg                             OUT_OF_LO_MEM; // flags to indicate out of mem, mem64, and ioreg                             OUT_OF_IO;reg                             OUT_OF_HI_MEM;reg             [3:0]           ii;integer                         jj;reg             [31:0]          DEV_VEN_ID;  // holds device and vendor idinteger                         PIO_MAX_NUM_BLOCK_RAMS; // holds the max number of block RAMSreg             [31:0]          PIO_MAX_MEMORY;reg             [31:0]          PIO_ADDRESS;     // holds the current PIO testing addressreg                             pio_check_design; // boolean value to check PCI Express BAR configuration against                                                  // limitations of PIO design. Setting this to true will cause the                                                  // testbench to check if the core has been configured for more than                                                  // one IO space, one general purpose Mem32 space (not counting                                                  // the Mem32 EROM space), and one Mem64 space.reg                             cpld_to; // boolean value to indicate if time out has occured while waiting for cpldreg                             cpld_to_finish; // boolean value to indicate to $finish on cpld_toreg                             verbose; // boolean value to display additional info to stdoutinteger                         NUMBER_OF_IO_BARS;integer                         NUMBER_OF_MEM32_BARS; // Not counting the Mem32 EROM spaceinteger                         NUMBER_OF_MEM64_BARS;reg  [31:0]                     BMD_RD_ADDRESS_32;reg  [31:0]                     BMD_RD_ADDR_INC;reg  [31:0]                     BMD_RD_INC_NUM;reg  [31:0]                     BMD_RD_CUR_ADDR;reg                             BMD_wait_for_next;parameter                                      Tcq = 1;initialbegin   ADDRESS_32_L         = 32'b1011_1110_1110_1111_1100_1010_1111_1110;   ADDRESS_32_H         = 32'b1011_1110_1110_1111_1100_1010_1111_1110;   ADDRESS_64           =     { ADDRESS_32_H, ADDRESS_32_L };   COMPLETER_ID         = 16'b0000_0000_1010_0000;   COMPLETER_ID_CFG     = 16'b0000_0001_1010_0000;   REQUESTER_ID         = 16'b0000_0001_1010_1111;   DESTINATION_RID      = 16'b0000_0001_1010_1111;   DEFAULT_TC           = 3'b000;   DEFAULT_LENGTH       = 10'h000;   DEFAULT_BE_LAST_DW   = 4'h0;   DEFAULT_BE_FIRST_DW  = 4'h0;   DEFAULT_ATTR         = 2'b01;   DEFAULT_TAG          = 8'h00;   DEFAULT_COMP         = 4'h0;   EXT_REG_ADDR         = 12'h000;   TD                   = 0;   EP                   = 0;   VENDOR_ID            = 16'h10ee;   LENGTH               = 10'b00_0000_0001;   BMD_RD_ADDRESS_32    = 32'h3E000000;   BMD_RD_ADDR_INC      = 32'h00000020;   BMD_RD_INC_NUM       = 32'h00000008;   BMD_RD_CUR_ADDR      = BMD_RD_ADDRESS_32;   BMD_wait_for_next    = 1'b0;endinitial begin        // Pre-BAR initialization        BAR_INIT_MESSAGE[0] = "DISABLED";        BAR_INIT_MESSAGE[1] = "IO MAPPED";        BAR_INIT_MESSAGE[2] = "MEM32 MAPPED";        BAR_INIT_MESSAGE[3] = "MEM64 MAPPED";        OUT_OF_LO_MEM = 1'b0;        OUT_OF_IO  =    1'b0;        OUT_OF_HI_MEM = 1'b0;        // Disable variables to start        for (ii = 0; ii <= 6; ii = ii + 1) begin            BAR_INIT_P_BAR[ii] =            33'h00000_0000;            BAR_INIT_P_BAR_RANGE[ii] =      32'h0000_0000;            BAR_INIT_P_BAR_ENABLED[ii] =    2'b00;        end        BAR_INIT_P_MEM64_HI_START =  32'h0000_0001; // hi 32 bit start of 64bit memory        BAR_INIT_P_MEM64_LO_START =  32'h0000_0000; // low 32 bit start of 64bit memory//        BAR_INIT_P_MEM32_START =     33'h00000_0000; // start of 32bit memory        BAR_INIT_P_MEM32_START =     33'h01000_0000; // start of 32bit memory        BAR_INIT_P_IO_START      =   33'h00000_0000; // start of 32bit io        DEV_VEN_ID = (32'h00004250 << 16) | (32'h000010EE);        PIO_MAX_MEMORY = 8192; // PIO has max of 8Kbytes of memory        PIO_MAX_NUM_BLOCK_RAMS = 4; // PIO has four block RAMS to test        PIO_MAX_MEMORY = 2048; // PIO has 4 memory regions with 2 Kbytes of memory per region, ie 8 Kbytes        PIO_MAX_NUM_BLOCK_RAMS = 4; // PIO has four block RAMS to test        pio_check_design = 1; //  By default check to make sure the core has been configured                              //  appropriately for the PIO design        cpld_to = 0;    // By default time out has not occured        cpld_to_finish = 1; // By default end simulation on time out//        verbose = 0;  // turned off by default        verbose = 1;  // turned off by default        NUMBER_OF_IO_BARS =    0;        NUMBER_OF_MEM32_BARS = 0;        NUMBER_OF_MEM64_BARS = 0;end  reg [255:0] testname;  integer test_vars [31:0];  reg [7:0] expect_cpld_payload [4095:0];  reg [7:0] expect_msgd_payload [4095:0];  reg [7:0] expect_memwr_payload [4095:0];  reg [7:0] expect_memwr64_payload [4095:0];  reg [7:0] expect_cfgwr_payload [3:0];  reg expect_status;  reg expect_finish_check;  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/tests.v"    else begin      $display("[%t] %m: Error: Unrecognized TESTNAME: %0s", $realtime, testname);      $finish(2);    end  end  task TSK_SYSTEM_INITIALIZATION;  begin    //--------------------------------------------------------------------------    // Event # 1: Wait for Transaction reset to be de-asserted..    //--------------------------------------------------------------------------    wait (trn_reset_n == 1);    $display("[%t] : Transaction Reset Is De-asserted...", $realtime);    //--------------------------------------------------------------------------    // Event # 2: Wait for Transaction link to be asserted..    //--------------------------------------------------------------------------    wait (trn_lnk_up_n == 0);    $display("[%t] : Transaction Link Is Up...", $realtime);  end  endtask    /************************************************************    Task : TSK_TX_TYPE0_CONFIGURATION_READ    Inputs : Tag, PCI/PCI-Express Reg Address, First BypeEn    Outputs : Transaction Tx Interface Signaling    Description : Generates a Type 0 Configuration Read TLP    *************************************************************/    task TSK_TX_TYPE0_CONFIGURATION_READ;        input    [7:0]    tag_;        input    [11:0]    reg_addr_;        input    [3:0]    first_dw_be_;        begin            if (trn_lnk_up_n) begin                $display("[%t] : Trn interface is MIA", $realtime);                $finish(1);            end            TSK_TX_SYNCHRONIZE(0, 0);            trn_td             <= #(Tcq)    {                                            1'b0,                                            2'b00,                                            5'b00100,                                            1'b0,                                            3'b000,                                            4'b0000,                                            1'b0,                                            1'b0,                                            2'b00,                                            2'b00,                                            10'b0000000001,  // 32                                            COMPLETER_ID_CFG,                                            tag_,                                            4'b0000,                                            first_dw_be_     // 64                                            };            trn_tsof_n         <= #(Tcq)    0;            trn_teof_n         <= #(Tcq)    1;            trn_trem_n         <= #(Tcq)    0;            trn_tsrc_rdy_n     <= #(Tcq)    0 ;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -