Close

Use byte-granularity for pointers.

A project log for PDP - Processor Design Principles

Distilling my experience and wisdom about the architecture, organisation and design choices of my CPUs

yann-guidon-ygdesYann Guidon / YGDES 02/02/2018 at 04:360 Comments

The modern processors are mostly word-oriented. They read and write a whole register at once. It is tempting to make the pointers address a whole register-sized chunk because that increases the actual memory capacity.

But what happens when you want to extend your CPU's register size ? You have to rewrite, or at least recompile your software. Handling of sub-units like bytes become awkward.

Of course, there are a lot of special cases, and dealing with sizeof() has often been misleading. But if your pointers can address individual bytes, your platform and code is a bit more future-proof.

And you don't always have the luxury to have sizeof(char)=1 when your register is 64 bits wide and you store one character per word in memory. I'm looking at you, CRAY. Of course you can pack 8 ASCII chars in one register but that makes your life miserable because you have to recode all your string handling instructions.

The SHARC (by ADi) has special addressing ranges where the data is read/written as different formats. This is pretty neat though it might not be possible on more general processors, for example for reasons of pointer aliasing.

I won't judge you if all your CPU does is brute-force DSP, where word-granularity makes sense. But you'll have to handle mundane management operations elsewhere, or you'll waste your time...

In my designs, the pointers have byte granularity but the LSB are ignored by the Load/Store Unit. They are used however by a discrete shifter that aligns and sign-extends the register. In the #YASEP, this is the IE unit (Inset/Extract)

Discussions