103
TR10a-LPQ User Manual
December
10,
2018
The main program PCIE_FUNDAMENTAL.cpp includes the header file "PCIE.h" and
defines the controller address according to the FPGA design.
The base address of BUTTON and LED controllers are 0x4000010 and 0x4000020
based on PCIE_BAR4, in respectively. The on-chip memory base address is
0x00000000 relative to the DMA controller.
Before accessing the FPGA through PCI Express, the application first calls PCIE_Load
to dynamically load the TERASIC_PCIE_AVMM.DLL. Then, it call PCIE_Open twice to
open two PCI Express devices:
hPCIE_0 = PCIE_Open(DEFAULT_PCIE_VID, DEFAULT_PCIE_DID, 0);
hPCIE_1 = PCIE_Open(DEFAULT_PCIE_VID, DEFAULT_PCIE_DID, 1);
The constant DEFAULT_PCIE_VID and DEFAULT_PCIE_DID used in PCIE_Open are
defined in TERASIC_PCIE_AVMM.h. If developers change the Vender ID and Device
ID and PCI Express IP, they also need to change the ID value define in
TERASIC_PCIE_AVMM.h. The third parameter (0 and 1 in this case) is used to specify
the PCIe device. 0 means the first device found in the PCIe bus with the given Vender
ID and Device ID. 1 means the second device found in the PCIe bus with the given
Vender ID and Device ID. If the return value of PCIE_Open is zero, it means the driver
cannot be accessed successfully. In this case, please make sure:
⚫
The FPGA is configured with the associated bit-stream file and the host is rebooted.
⚫
The PCI express driver is loaded successfully.
The LED control is implemented by calling PCIE_Write32 API, as shown below:
The button status query is implemented by calling the
PCIE_Read32
API, as shown
below: