L-tile and H-tile Avalon® Memory-mapped Intel® FPGA IP for PCI Express* User Guide

ID 683667
Date 9/26/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

9.4. Example of Reading and Writing BAR0 Using the CRA Interface

You can use the CRA interface to send TLP requests. The Fmt and Type fields of the TLP Header provide the information required to determine the size of the remaining part of the TLP Header, and if the packet contains a data payload following the Header.

Figure 67. TLP Header Format

The CRA interface uses register addresses 0x2000 and 0x2004 to send TLPs, and register addresses 0x2008 and 0x200C to check for Completions. For details on these registers, refer to the table Root Port TLP Data Registers.

Below are examples of how to use Type 0 configuration TLPs to read from BAR0 and write to it.
  1. Use the CRA interface to read an uninitialized BAR0 using a Type 0 configuration TLP with the format as shown below:
    To send the TLP using the CRA interface, do the following steps:
    1. Write 0x0400_0001 to CRA interface address 0x2000.
    2. Write 0x0000_0001 to CRA interface address 0x2004 (Start of Packet).
    3. Write 0x0000_170F to CRA interface address 0x2000.
    4. Write 0x0000_0000 to CRA interface address 0x2004 (Continue).
    5. Write 0x0100_0010 to CRA interface address 0x2000.
    6. Write 0x0000_0000 to CRA interface address 0x2004 (Continue).
    7. Write 0x0000_0000 to CRA interface address 0x2000 (dummy data to achieve alignment).
    8. Write 0x0000_0002 to CRA interface address 0x2004 (End of Packet).

    Check the corresponding Completion using the CRA interface. The Completion TLP has four dwords, with the first three dwords as shown below, followed by one dword of uninitialized BAR0 value (which is 0xFFEF0010 in the following picture).

    To read the Completion using the CRA interface, do the following steps:
    1. Keep reading CRA interface address 0x200C until bit [0] = 0x1 (indicating the Completion packet has arrived, and you can receive the SOP in the next step).
    2. Read CRA interface address 0x2008. The read data value in this example is 0x4A00_0001.
    3. Read CRA interface address 0x200C. In this example, bits [1:0] = 0, which indicate the value read in the next step is still in the middle of the packet.
    4. Read CRA interface address 0x2008. The read data value is 0x0100_0004.
    5. Read CRA interface address 0x200C. In this example, bits [1:0] = 0, which indicate the value read in the next step is still in the middle of the packet.
    6. Read CRA interface address 0x2008. The read data value is 0x00001700.
    7. Read CRA interface address 0x200C. In this example, bits [1:0] = 2, which indicate the value read in the next step is the EOP of the packet.
    8. Read CRA interface address 0x2008. The read data value is BAR0's uninitialized value 0xFFEF0010.
  2. Use the CRA interface to initialize BAR0 with 0xFFFF_FFFF using a Type 0 configuration TLP with the format as shown below:
    To send the TLP using the CRA interface, do the following steps:
    1. Write 0x0400_0001 to CRA interface address 0x2000.
    2. Write 0x0000_0001 to CRA interface address 0x2004 (Start of Packet).
    3. Write 0x0000_110F to CRA interface address 0x2000.
    4. Write 0x0000_0000 to CRA interface address 0x2004 (Continue).
    5. Write 0x0100_0010 to CRA interface address 0x2000.
    6. Write 0x0000_0000 to CRA interface address 0x2004 (Continue).
    7. Write 0xFFFF_FFFF to CRA interface address 0x2000.
    8. Write 0x0000_0002 to CRA interface address 0x2004 (End of Packet).

    Check the corresponding Completion using the CRA interface. The Completion TLP

    has three dwords as shown below:
    To read the Completion using the CRA interface, do the following steps:
    1. Keep reading CRA interface address 0x200C until bit [0] = 0x1 (indicating the Completion packet has arrived, and you can receive the SOP in the next step).
    2. Read CRA interface address 0x2008. The read data value is 0x0A00_0000.
    3. Read CRA interface address 0x200C. In this example, bits [1:0] = 0, which indicate the value read in the next step is still in the middle of the packet.
    4. Read CRA interface address 0x2008. The read data value is 0x0100_0004.
    5. Read CRA interface address 0x200C. In this example, bits [1:0] = 0, which indicate the value read in the next step is still in the middle of the packet.
    6. Read CRA interface address 0x2008. The read data value is 0x00001100.
    7. Read CRA interface address 0x200C. In this example, bits [1:0] = 2, which indicate the value read in the next step is the EOP of the packet.
    8. Read CRA interface address 0x2008. The read data value is BAR0’s size.

You can repeat Step 1 to read BAR0 after writing 0xFFFF_FFFF to it, and repeat Step 2 to configure the BAR0 address space.

Use the same method to configure BAR1, BAR2, BAR3, BAR4 and BAR5.