Electronic – Why aren’t pins on microcontroller grouped together, close to each other

microcontrollerpinsstm32

Simple question, the curiosity is killing me.
Why do microcontrollers (and other IC also, like RAMs) have pins not grouped together?

Like in STM32, for example you have portA and it has 8 bits on one side of IC and the other 8 bits at the opposite corner of IC… Why? It make routing PCB much harder. What is the reason or purpose of such alignment? Why couldn't they put it next to each other?
And why do 32-bit uCs (like STM32) have 16-bit wide ports, when they could have 32-bit wide?

The same goes with RAMs – address pins and data pins are scattered almost randomly over the IC. Why?

Inside the IC there are plenty of routing layers, so what's the reason they couldn't add one more to group pins in some logical order?

Best Answer

In RAM chips, you often want all address/data lines to have the same length (the shorter the better), so that the signals travel along simultaneously and the clock frequency could be higher. Address and Data lines have to cover the entire area of the chip, so they are grouped by the physical location of the storage cells they feed, not by logical function.

Heterogeneous devices like micro-controllers have different kind of constraints. Some signals could interfere with each other (like a clock and a sensitive ADC) and cannot go to adjacent pins. Furthermore, distributing similar pins of both sides of the chip can actually improve routing of the PCB. Chances are, the chip will sit in the middle and have to talk to neighbors on both sides. Having all similar pins on one side would make PCB routing a nightmare.