Q 0.10 : Transmitter and Receiver Elements – The Math Behind Flow Control

In Lecture 9, we discussed Flow Control initialization. Now, in Lecture 10, we are diving into the specific hardware elements—the counters and registers—inside the Transmitter and Receiver. We will also break down the exact math the system uses to calculate whether a pending Transaction Layer Packet (TLP) is allowed to cross the Link!

To manage flow control effectively, the Transaction Layer utilizes several specific elements on both the transmitting and receiving ends.

Part 1: Transmitter Elements

Before a packet can be sent, the transmitter must verify that the receiver has enough room. It tracks this using four key elements:

  • Transactions Pending Buffer: This buffer holds the transactions that are currently waiting to be sent across the given Virtual Channel.
  • Credits Consumed (CC) Counter: This counter maintains a running tally of the total credit sum for all transactions that the transmitter has already sent for this specific buffer.
  • Credit Limit (CL) Counter: This counter represents the receiver’s capacity. It is initialized by the receiver with the size of its corresponding Flow Control buffer during initialization. During run-time, this limit is periodically increased via Flow Control Update packets as the receiver frees up buffer space.
  • Flow Control Gating Logic: This is the “decision maker.” It performs the mathematical calculations to determine if the receiver has sufficient credits to accept the next pending packet.

Part 2: Receiver Elements

On the other side of the Link, the receiver must manage the incoming traffic and track how much space it has left using three main elements:

  • Flow Control Buffer: This physical memory space stores the incoming headers or data payloads.
  • Credits Allocated (CA) Counter: This counter tracks the total Flow Control credits that have been made available. It is initialized to reflect the total size of the Flow Control buffer. As the device’s core logic processes and removes transactions from the buffer, the CA counter increments to reflect the newly available space.
  • Credits Received Counter (Optional): While optional, this is highly recommended for error checking. It tracks the total credits of all TLPs that have been received. By continuously checking that the Credits Received count is equal to or less than the Credits Allocated count, the receiver can instantly detect a buffer overflow error.

Part 3: The Math – Can the TLP be sent?

When a transmitter has a Pending TLP (PTLP) ready to go, the Flow Control Gating Logic must calculate if it is safe to transmit. Because counters continuously increment and eventually roll over back to zero, the logic uses unsigned (2’s complement) arithmetic to perform the check safely.

Here is the step-by-step calculation:

  1. Calculate Credits Required (CR): The logic first adds the current Credits Consumed (CC) count to the number of credits required by the Pending TLP (PTLP).
  2. Perform the Credit Check: Next, the logic subtracts the calculated Credits Required (CR) from the current Credit Limit (CL).
  3. Evaluate the Modulo Result: Because the counters are designed to roll over, the result is checked using modulo arithmetic. If the result of the subtraction (CL – CR) is less than or equal to half of the maximum counter value (for example, <= 80h for an 8-bit header counter that tracks modulo 256), the test passes.

If the condition is met, there is sufficient space in the receiver buffer, and the packet is officially allowed to be transmitted! If the result is greater than half the maximum value, the channel is blocked, and the packet must wait in the pending buffer until a new Flow Control Update packet arrives with a higher Credit Limit.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top