Lattice PCI Express IP Demo

Introduction

The demo runs on a standard Windows PC, and accesses the Lattice PCIe evaluation board that is installed in a PCIe slot. The following figure shows the relationship of the hardware and software components of the demo. The PCIe IP, in the Lattice FPGA on the eval board, acts as a PCIe endpoint. A PCIe end-point device looks like a regular PCI device to application software executing on a PC. It is just a memory-mapped device occupying a certain range(s) of the PCI memory space. When the PC boots the BIOS and OS probe the PCIexpress and PCI buses and detect the devices present on the buses and assign them ranges in the PCI memory space. The PCI memory space is mapped into the application software’s memory space by the supplied driver and OS system calls. Once the mapping is done, application IP registers, sitting on top of the PCIexpress IP stack, can be read/written as memory locations by the application software. The demo software writes to the LED register, reads and displays the DIP switch setting and reads/writes the EBR memory.

The demo software shows that the Lattice PCIe IP correctly handles the PCIexpress protocol in a PC through the interaction with the devices on the eval board. The demo exercises the following functions:

Supported Boards

Setup

The FPGA bitstream must already be loaded into the SPI flash on the evaluation board. The FPGA must be programmed with the PCIe IP core when the PC powers up so that the endpoint is seen by the North Bridge root complex and the BIOS and OS allocate resources for it. If the FPGA is loaded with the bitstream (via ispVM) after the PC has booted, the PC will need to be restarted (soft reset, not a power-off) so that the board is seen when the PC boots.

Bitstreams are located in C:/Program Files/LatticeApps/PCIe/BitStreams

No setup is required if the demo programs are run from the Start->Programs->LatticePCIe program group. To run from the command line, the environment variable PCIE_BOARD needs to be set in the shell you are running from. When the PC if powered on, the status LEDs should light to indicate a good communication link over the PCIe bus. All four LEDs on the top right of the board must be lit. Their functions are:

Demo Operations

Device Info Page

The opening page, Device Info, displays information about the device driver and the device's PCI configuration registers.

The data displayed is for informational purposes and can not be edited. This information is obtained once by the Lattice PCIe driver when the Windows OS detects the board and loads the driver. Displaying this page does not cause the driver to issue PCI Config Type 0 read requests.

Tests Page

The Tests tab has various tests that can be run to show that the IP is accessible from host software via the PCIe bus. The GUI has fields for entering data to be sent to device registers in the FPGA design. These fields are color-coded to indicate the data format they accept.

EBR Memory Section

The EBR Memory section tests the access to the 16kB of EBR internal to the FPGA. Accesses are done on a byte basis. All 16k memory locations are accessed successively, testing the throughput of PCIe and memory interface. The following actions can be performed

16 Segment Display Section

The 16 Segment display section has two test modes. In the first mode a pre-set sequence of segments are lit and then characters are written to the display. Pressing the Run button starts this operation. It will take approximately 30 seconds to complete. You must observe the 16 Segment LEDs to see if it is operating correctly. The correct sequence is:
  1. Light all segments, one at a time, around the perimeter.
  2. Light all inner segments in a clock-wise order.
  3. Turn off all inner segments in reverse order
  4. Turn off all outer segments in reverse order
  5. Write the characters LATTICE* one at a time to the display
  6. The asterix character should be displayed when the test ends
The second mode of operation allows a single character to be sent to the display by typing the character into the box to the right of the Set button and then pressing Set. Any printable ASCII character can be displayed (lower case are displayed as upper case).

DIP Switch

The DIP Switch section shows that user changes to the switches on the eval board are seen by the application software on the PC. The GUI polls the DIP switch register 10 times a second and displays the value read from the 8 bit DIP switch register.

The Get button can be used to immediately update the value. This would be used if No Polling was selected from the Settings drop-down menu. Normally this is not used.

Counter

The Counter section allows you to control a 32 bit down counter in the FPGA hardware. The counter is driven by the 125 Mhz clock that feeds the IP. The counter is started by selecting the Start radio button. Counting begins from the value entered into the Reload Value field. The current count value is displayed in the Current Count field.

The Current Count value is updated 10 times a second by the GUI polling (reading) the count register in the FPGA application IP.

Rd/Wr Page

The Read/Write page is used for peeking and poking registers and EBR memory values in the application IP. This is primarily used for debugging and diagnosing the application IP registers. Consult the demo IP register map for a list of device registers and their functions.

Data accesses can be specified as byte, short or word operations by selecting the Data Size. Access are done to the selected BAR. The memory contents are displayed in the window. The address uses the convention that the upper nibble (31:28) specifies the BAR being accessed. The above example shows reading the GPIO registers (BAR 1, starting at offset 0) in the application IP and displaying them in word format.

Data can be written to registers using the WRITE button. Specify the BAR Offset to start writing at and the hex data in the Data field. Separate each value with a space. Data size should match the Data Size selected at the top of the page in Memory Settings.

Only BAR1 is accessible in the current demo.

16 Seg Page

The 16 Segment page provides a way to interactively light segments on the display. Clicking on a segment in the image will immediately cause the corresponding segment on the LED to be lit. The states of the LED segments are converted to a 16 bit word value (each segment is controlled by a bit) and written to the LED control register in the GPIO portion of the IP in the FPGA. This demonstrates a memory write across the PCIe bus.

Demo Operations:

IP Design Details

IP Block Diagram

GPIO Register Map

BAR1

Location

Offset (Hex)

Byte 3 [31:24]

Byte 2 [23:16]

Byte 1[15:8]

Byte 0 [7:0]

0000

ID Register

0004

Scratch Pad Register

0008

DIP Switch

rsvd

16 Segment LED

upper 8 bits lower 8 bits

000C

rsvd

rsvd

rsvd

Counter ctrl

0010

Current Counter Value

0014

Counter Reload Value

EBR Memory

The EBR is mapped as a 32 bit wide device with 4096 addresses. The total size is 16kB (4096 x 32 bit). It can be accessed with byte, short or word accesses.

BAR1

Location

Offset (Hex)

Byte 3 [31:24]

Byte 2 [23:16]

Byte 1[15:8]

Byte 0 [7:0]

1000





. . .





. . .





4ffc





Trouble Shooting

Trouble with the Board

Ensure the board is installed in a PCIe slot. It can physically fit into a PCI slot. This could damage the board or PC if power is applied when its the wrong type of slot.

Ensure the board has a valid PCIe bitstream loaded in the SPI flash and for ECP2M that the Mode DIP switches are set to program from SPI flash (does not apply to SC eval boards).

Ensure the 4 Status LEDs are on, indicating the board is seen as a PCIe endpoint. If the 2 yellow LEDs and 2 green LEDs are not on, the board will not be recognized by the PC BIOS or Windows. You can try installing in a different PCIe slot to see if that fixes the link-up problem. You can also try pressing the Eval Board's reset button immediately after the PC boots.

Ensure the board is seen by Windows. Check My Computer->Properties->Hardware->Device Manager and verify the LSC_PCIe driver and eval board are shown in the list. If not, shutdown the system and try another slot. If the board is present, check it Properties and the Resource tab to verify memory was assigned to it. Also verify the Vendor ID and Device ID are valid, as seen be Windows Plug-n-Play. If the values are invalid, perhaps the bitstream is corrupt and needs to be reloaded into SPI flash.

Trouble with the Driver

The eval board must be installed in the PC, and seen by Windows, for the driver to be installed. If you do not see the “Found New Hardware” message when logging in after installing the board, check the board LEDs. Try a different PCIe slot.

Make sure you specify the search location for the driver during installation. Tell Windows to install from the Demo\Drivers\evalBoard directory.

You will need administrator permission to install device driver files.

Trouble Running the Demo

The eval board must be installed in the PC, and seen by Windows, for the driver to be installed or loaded. The driver must be loaded by Windows in order to run the demo. Again verify Windows sees the board and has loaded a driver for it.

If the GUI displays an error (ERROR LOADING LIBRARY:Cpp_Jni - running in View Only mode) when launched, then the driver could not be found or loaded. There are 2 causes

  1. The driver was never loaded (or eval board is not installed)
  2. The board failed to be detected by Windows.
Either way, the board needs to be re-installed and seen by Windows and the LSC_PCIe driver needs to be associated with the hardware.

Windows Debug Tools

Windows offers some utilities to interrogate the operation of hardware devices. Use these tools to verify the eval board device driver is loaded and running.

Right-click on the My Computer icon and select Properties to bring up the Hardware Wizard and Device Manager. The Device Manager provides software driver information for devices detected by Windows Plug-n-Play manager. The most useful utility is to verify that the lscpcie driver and the lscvpci driver (if enabled) have been installed.