Saturday, August 7, 2021

The amazing design of PCI Express

The IBM PC computer architecture (like many other similar architectures) was designed with expandability in mind, meaning that the base computer (motherboard + CPU) can be expanded with external third-party modules, in the form of expansion cards that can be attached (usually directly to the motherboard). During the long history of the architecture there have been numerous and diverse expansion bus protocol standards, including ISA, AGP, PCI and, what has now become the ubiquitous (and often sole) standard, PCI Express (which shouldn't be confused with the older PCI standard. While similar, the connection slots are physically incompatible.)

The current standard, PCI Express, could arguably be called the "ultimate" expansion bus standard in its perfection. Indeed, PCI Express is an absolute marvel of computer engineering.

One of the most notable and important features of PCI Express is its incredible compatibility with different versions of itself. I like to describe PCI Express as being "compatible forwards, backwards and sideways".

What do I mean by this?

As of writing this there are now 6 different generations ("versions", if you will) of the PCI Express standard, although the vast majority of current motherboards only implement generation 4. The main difference between the different generations is data transfer speed.

However, all these versions are fully compatible with each other. You can take a generation 1 PCI Express expansion card and connect it to a motherboard supporting generation 4, and it will work (ie. the standard is backwards compatible). More prominently, however, you can take a Generation 4 PCI Express expansion card and connect it to a motherboard that has only support for the generation 1 standard, and it will work (which could be called "forwards compatibility", in other words, older generations of the standard are forwards-compatible with newer generations).

The same goes, of course, with any other combination of the six possible generations.

Moreover, and rather amazingly, the standard is also "sideways-compatible" with itself, as I like to call it. What do I mean by this?

PCI Express slots come in different widths, which directly correspond to data transfer speed. Most typical widths are x1, x2, x4, x8 and x16 (although x2 and x8 tend to be rare in motherboards). These multipliers do not indicate merely data transfer speeds, but in fact indicate directly how many physical connectors there are in the expansion slots. (In other words, the multiplier is not, for example, some kind of clock speed multiplier, but directly indicates how many physical connectors and wires there are in the expansion slot.)

Remarkably, you can take any PCI Express expansion card, of any width, and connect it to any PCI Express slot, no matter what its width may be (as long as the physical design of the slot allows it).

In other words, it's perfectly possible to take an x1 card and connect it to a full-length x16 slot, and it will work. Likewise it's possible (at least in theory) to take an x16 card and connect it to an x1 slot, and it will work correctly. (And, of course, any other combination of lengths will work.)

This is the reason why it's perfectly possible to take an x16 GPU and connect it to an x4 slot, and it will work. (The only drawback of doing this is the reduced data transfer rate between the CPU and the GPU.)

(In practice x1 slots in motherboards have a physical barrier at the end that stops a longer card from being inserted. There's no technical reason to stop this from being possible, at least from the point of view of the PCI Express standard. In fact, if you were to physically cut out that barrier, you could insert an x16 card into the x1 slot, and it will work. The main reason why manufacturers put the barrier there is to stop very large cards from being inserted, which would cause a lot of sag due to gravity, very possibly physically bending and damaging the slot, the motherboard, and possibly the card itself.)

This is what I call "sideways compatibility".