📄 pci_exp_usrapp_tx.v
字号:
Outputs : None Description : Synchronize with tx clock and handshake signals *************************************************************/ task TSK_TX_SYNCHRONIZE; input first_; input last_call_; reg last_; begin if (trn_lnk_up_n) begin $display("[%t] : Trn interface is MIA", $realtime); $finish(1); end @(posedge trn_clk); if ((trn_tdst_rdy_n == 1'b1) && (first_ == 1'b1)) begin while (trn_tdst_rdy_n == 1'b1) begin @(posedge trn_clk); end end if (first_ == 1'b1) begin last_ = (trn_trem_n == 8'h00) ? 0 : 1; // read data driven into memory `BOARD.`XILINX_PCI_EXP_DOWNSTREAM_PORT_INST.com_usrapp.TSK_READ_DATA(last_, `TX_LOG, trn_td, trn_trem_n); end if (last_call_) `BOARD.`XILINX_PCI_EXP_DOWNSTREAM_PORT_INST.com_usrapp.TSK_PARSE_FRAME(`TX_LOG); end endtask // TSK_TX_SYNCHRONIZE /************************************************************ Task : TSK_USR_DATA_SETUP_SEQ Inputs : None Outputs : None Description : Populates scratch pad data area with known good data. *************************************************************/ task TSK_USR_DATA_SETUP_SEQ; integer i_; begin for (i_ = 0; i_ <= 4095; i_ = i_ + 1) begin DATA_STORE[i_] = i_; end end endtask // TSK_USR_DATA_SETUP_SEQ /************************************************************ Task : TSK_TX_CLK_EAT Inputs : None Outputs : None Description : Consume clocks. *************************************************************/ task TSK_TX_CLK_EAT; input [31:0] clock_count; integer i_; begin for (i_ = 0; i_ < clock_count; i_ = i_ + 1) begin @(posedge trn_clk); end end endtask // TSK_TX_CLK_EAT /************************************************************ Task: TSK_SIMULATION_TIMEOUT Description: Set simulation timeout value *************************************************************/ task TSK_SIMULATION_TIMEOUT; input [31:0] timeout; begin force `BOARD.`XILINX_PCI_EXP_DOWNSTREAM_PORT_INST.rx_usrapp.sim_timeout = timeout; end endtask /************************************************************ Task : TSK_TX_BAR_READ Inputs : Tag, Length, Address, Last Byte En, First Byte En Outputs : Transaction Tx Interface Signaling Description : Generates a Memory Read 32,64 or IO Read TLP requesting 1 dword *************************************************************/ task TSK_TX_BAR_READ; input [2:0] bar_index; input [31:0] byte_offset; input [7:0] tag_; input [2:0] tc_; begin case(BAR_INIT_P_BAR_ENABLED[bar_index]) 2'b01 : // IO SPACE begin if (verbose) $display("[%t] : IOREAD, address = %x", $realtime, BAR_INIT_P_BAR[bar_index][31:0]+(byte_offset)); TSK_TX_IO_READ(tag_, BAR_INIT_P_BAR[bar_index][31:0]+(byte_offset), 4'hF); end 2'b10 : // MEM 32 SPACE begin if (verbose) $display("[%t] : MEMREAD32, address = %x", $realtime, BAR_INIT_P_BAR[bar_index][31:0]+(byte_offset)); TSK_TX_MEMORY_READ_32(tag_, tc_, 10'd1, BAR_INIT_P_BAR[bar_index][31:0]+(byte_offset), 4'h0, 4'hF); end 2'b11 : // MEM 64 SPACE begin if (verbose) $display("[%t] : MEMREAD64, address = %x", $realtime, BAR_INIT_P_BAR[bar_index][31:0]+(byte_offset)); TSK_TX_MEMORY_READ_64(tag_, tc_, 10'd1, {BAR_INIT_P_BAR[ii+1][31:0], BAR_INIT_P_BAR[bar_index][31:0]+(byte_offset)}, 4'h0, 4'hF); end default : begin $display("Error case in task TSK_TX_BAR_READ"); end endcase end endtask // TSK_TX_BAR_READ /************************************************************ Task : TSK_TX_BAR_WRITE Inputs : Bar Index, Byte Offset, Tag, Tc, 32 bit Data Outputs : Transaction Tx Interface Signaling Description : Generates a Memory Write 32, 64, IO TLP with 32 bit data *************************************************************/ task TSK_TX_BAR_WRITE; input [2:0] bar_index; input [31:0] byte_offset; input [7:0] tag_; input [2:0] tc_; input [31:0] data_; begin case(BAR_INIT_P_BAR_ENABLED[bar_index]) 2'b01 : // IO SPACE begin if (verbose) $display("[%t] : IOWRITE, address = %x, Write Data %x", $realtime, BAR_INIT_P_BAR[bar_index][31:0]+(byte_offset), data_); TSK_TX_IO_WRITE(tag_, BAR_INIT_P_BAR[bar_index][31:0]+(byte_offset), 4'hF, data_); end 2'b10 : // MEM 32 SPACE begin DATA_STORE[0] = data_[7:0]; DATA_STORE[1] = data_[15:8]; DATA_STORE[2] = data_[23:16]; DATA_STORE[3] = data_[31:24]; if (verbose) $display("[%t] : MEMWRITE32, address = %x, Write Data %x", $realtime, BAR_INIT_P_BAR[bar_index][31:0]+(byte_offset), data_); TSK_TX_MEMORY_WRITE_32(tag_, tc_, 10'd1, BAR_INIT_P_BAR[bar_index][31:0]+(byte_offset), 4'h0, 4'hF, 1'b0); end 2'b11 : // MEM 64 SPACE begin DATA_STORE[0] = data_[7:0]; DATA_STORE[1] = data_[15:8]; DATA_STORE[2] = data_[23:16]; DATA_STORE[3] = data_[31:24]; if (verbose) $display("[%t] : MEMWRITE64, address = %x, Write Data %x", $realtime, BAR_INIT_P_BAR[bar_index][31:0]+(byte_offset), data_); TSK_TX_MEMORY_WRITE_64(tag_, tc_, 10'd1, {BAR_INIT_P_BAR[bar_index+1][31:0], BAR_INIT_P_BAR[bar_index][31:0]+(byte_offset)}, 4'h0, 4'hF, 1'b0); end default : begin $display("Error case in task TSK_TX_BAR_WRITE"); end endcase end endtask // TSK_TX_BAR_WRITE /************************************************************ Task : TSK_SET_READ_DATA Inputs : Data Outputs : None Description : Called from common app. Common app hands read data to usrapp_tx. *************************************************************/ task TSK_SET_READ_DATA; input [3:0] be_; // not implementing be's yet input [31:0] data_; // might need to change this to byte begin P_READ_DATA = data_; p_read_data_valid = 1; end endtask // TSK_SET_READ_DATA /************************************************************ Task : TSK_WAIT_FOR_READ_DATA Inputs : None Outputs : Read data P_READ_DATA will be valid Description : Called from tx app. Common app hands read data to usrapp_tx. This task must be executed immediately following a call to TSK_TX_TYPE0_CONFIGURATION_READ in order for the read process to function correctly. Otherwise there is a potential race condition with p_read_data_valid. *************************************************************/ task TSK_WAIT_FOR_READ_DATA; integer j; begin j = 10; p_read_data_valid = 0; fork while (!p_read_data_valid) @(posedge trn_clk); begin // second process while ((j > 0) && (!p_read_data_valid)) begin TSK_TX_CLK_EAT(100); j = j - 1; end if (!p_read_data_valid) begin $display("TIMEOUT ERROR in usrapp_tx:TSK_WAIT_FOR_READ_DATA. Completion data never received."); $finish; end end join end endtask // TSK_WAIT_FOR_READ_DATA /************************************************************ Function : TSK_DISPLAY_PCIE_MAP Inputs : none Outputs : none Description : Displays the Memory Manager's P_MAP calculations based on range values read from PCI_E device. *************************************************************/ task TSK_DISPLAY_PCIE_MAP; reg[2:0] ii; begin for (ii=0; ii <= 6; ii = ii + 1) begin if (ii !=6) begin $display("\tBAR %x: VALUE = %x RANGE = %x TYPE = %s", ii, BAR_INIT_P_BAR[ii][31:0], BAR_INIT_P_BAR_RANGE[ii], BAR_INIT_MESSAGE[BAR_INIT_P_BAR_ENABLED[ii]]); end else begin $display("\tEROM : VALUE = %x RANGE = %x TYPE = %s", BAR_INIT_P_BAR[6][31:0], BAR_INIT_P_BAR_RANGE[6], BAR_INIT_MESSAGE[BAR_INIT_P_BAR_ENABLED[6]]); end end end endtask /************************************************************ Task : TSK_BUILD_PCIE_MAP Inputs : Outputs : Description : Looks at range values read from config space and builds corresponding mem/io map *************************************************************/ task TSK_BUILD_PCIE_MAP; integer ii; begin $display("[%t] PCI EXPRESS BAR MEMORY/IO MAPPING PROCESS BEGUN...",$realtime); // handle bars 0-6 (including erom) for (ii = 0; ii <= 6; ii = ii + 1) begin if (BAR_INIT_P_BAR_RANGE[ii] != 32'h0000_0000) begin if ((ii != 6) && (BAR_INIT_P_BAR_RANGE[ii] & 32'h0000_0001)) begin // if not erom and io bit set // bar is io mapped NUMBER_OF_IO_BARS = NUMBER_OF_IO_BARS + 1; if (pio_check_design && (NUMBER_OF_IO_BARS > 1)) begin $display("[%t] Warning: PIO design only supports 1 IO BAR. Testbench will disable BAR %x",$realtime, ii); BAR_INIT_P_BAR_ENABLED[ii] = 2'h0; // disable BAR end else BAR_INIT_P_BAR_ENABLED[ii] = 2'h1; if (!OUT_OF_IO) begin // We need to calculate where the next BAR should start based on the BAR's range BAR_INIT_TEMP = BAR_INIT_P_IO_START & {1'b1,(BAR_INIT_P_BAR_RANGE[ii] & 32'hffff_fff0)}; if (BAR_INIT_TEMP < BAR_INIT_P_IO_START) begin // Current BAR_INIT_P_IO_START is NOT correct start for new base BAR_INIT_P_BAR[ii] = BAR_INIT_TEMP + FNC_CONVERT_RANGE_TO_SIZE_32(ii); BAR_INIT_P_IO_START = BAR_INIT_P_BAR[ii] + FNC_CONVERT_RANGE_TO_SIZE_32(ii); end else begin // Initial BAR case and Current BAR_INIT_P_IO_START is correct start for new base BAR_INIT_P_BAR[ii] = BAR_INIT_P_IO_START; BAR_INIT_P_IO_START
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -