Arria V GZ Avalon-MM Interface for PCIe Solutions: User Guide

ID 723696
Date 5/21/2017
Public
Document Table of Contents

5.8.3. Examples 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 25. TLP Header Format

The CRA interface uses register addresses 0x2000, 0x2004, and 0x2008 to send TLPs, and register addresses 0x2010, 0x2014, and 0x2018 to check Completions. For details about these registers, refer to the table Root Port TLP Data Registers, 0x2000 - 0x2FFF. 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:
         | fmt |   typ   |t|  tc |t|a|l|t|t|e|att| at|       length      |
         | 000b|  00100b |0|_ 0 _|0|0|0|0|0|0| 0 | 0 |_______ 001 _______|
         |________ req_id: 0000 _________|___ tag: 17 ___|lbe: 0 |fbe: f |
         |    bdf.bus  |bdf.dev|bdf.func|rsvd20|reg_no.ext|reg_no.low|rsv|
         |______ 01 ___|__ 00 _|___ 0 __|_ 0 __|___ 0 ____|___ 04 ___| 0 |
         04000001 0000170f 01000010

    To send the TLP using the CRA interface, do the following steps:

    1. Write 0x0400_0001 to CRA interface address 0x2000.
    2. Write 0x0000_170F to CRA interface address 0x2004.
    3. Write 0x0000_0001 to CRA interface address 0x2008 (Start of Packet).
    4. Write 0x0100_0010 to CRA interface address 0x2000.
    5. Write 0x0000_0000 to CRA interface address 0x2004.
    6. Write 0x0000_0002 to CRA interface address 0x2008 (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).

        | fmt |   typ   |t|  tc |t|a|l|t|t|e|att| at|       length      |
        | 010b|  01010b |0|_ 0 _|0|0|0|0|0|0| 0 | 0 |_______ 001 _______|
        |_____ cpl_id: 0100 ___|cpl_status: 0|bcm: 0|__ byte_cnt: 004 __|
        |_____ req_id: 0000 ___|___ tag: 17 ___|rsvd20: 0| low_addr: 00 |
        4a000001 01000004 00001700 ffef0010

    To read the Completion using the CRA interface, do the following steps:

    1. Keep reading CRA interface address 0x2010 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 0x2014. The read data value is 0x4A00_0001.
    3. Read CRA interface address 0x2018. The read data value is 0x0100_0004.
    4. Read CRA interface address 0x2010. In this example, bits [1:0] = 0x2 (indicating that you will receive the EOP in the next step). If bits [1:0] = 0x0, the values read in the next two steps are still in the middle of the packet. In this case, you need to keep reading 0x2010, 0x2014, and 0x2018 after performing the next two steps.
    5. Read CRA interface address 0x2014. The read data value is 0x0000_1700.
    6. Read CRA interface address 0x2018. The read data value is BAR0's uninitialized value.
  2. Use the CRA interface to initialize BAR0 with 0xFFFF_FFFF using a Type 0 configuration TLP with the format as shown below:
        | fmt |   typ   |t|  tc |t|a|l|t|t|e|att| at|       length      |
        | 010b|  00100b |0|_ 0 _|0|0|0|0|0|0| 0 | 0 |_______ 001 _______|
        |________ req_id: 0000 _________|___ tag: 11 ___|lbe: 0 |fbe: f |
        |    bdf.bus  |bdf.dev|bdf.func|rsvd20|reg_no.ext|reg_no.low|rsv|
        |______ 01 ___|__ 00 _|___ 0 __|_ 0 __|___ 0 ____|___ 04 ___| 0 |
        44000001 0000110f 01000010 ffffffff

    To send the TLP using the CRA interface, do the following steps:

    1. Write 0x4400_0001 to CRA interface address 0x2000.
    2. Write 0x0000_110F to CRA interface address 0x2004.
    3. Write 0x0000_0001 to CRA interface address 0x2008 (Start of Packet).
    4. Write 0x0100_0010 to CRA interface address 0x2000.
    5. Write 0xFFFF_FFFF to CRA interface address 0x2004.
    6. Write 0x0000_0002 to CRA interface address 0x2008 (End of Packet).

    Check the corresponding Completion using the CRA interface. The Completion TLP has three dwords as shown below:

        | fmt |   typ   |t|  tc |t|a|l|t|t|e|att| at|       length      |
        | 000b|  01010b |0|_ 0 _|0|0|0|0|0|0| 0 | 0 |_______ 000 _______|
        |_____ cpl_id: 0100 ___|cpl_status: 0|bcm: 0|__ byte_cnt: 004 __|
        |_____ req_id: 0000 ___|___ tag: 11 ___|rsvd20: 0| low_addr: 00 |
        0a000000 01000004 00001100

    To read the Completion using the CRA interface, do the following steps:

    1. Keep reading CRA interface address 0x2010 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 0x2014. The read data value is 0x0A00_0000.
    3. Read CRA interface address 0x2018. The read data value is 0x0100_0004.
    4. Read CRA interface address 0x2010. In this example, bits [1:0] = 0x2.
    5. Read CRA interface address 0x2014. The read data value is 0x0000_1100.

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.