## Tuesday, 31 July 2012

### Bitness of a CPU

For yet another time, I've started asking questions to some local geeks about what defines the number of bits of a CPU. I was puzzled again because I have read different answers about the definition and unexpected values for specific CPUs. Then I decided to investigate this matter more, aka doing my homework (I won't sleep tonight :P).

The most common two opposing metrics are:

• The size of the registers define the bits of a CPU
• No, not only the size, but also the data bus width

Some considerations:

• Is a Z80 a 16bit processor then? It has 16bit registers! No,. those are "fake" regs created by the 8bit pairs. Ok,. so it's the size of "true" registers. Question: How to realize that they are not real regs? More cycles needed? Very few arithmetic operations on the pseudo 16bit regs? 8bit internal bus?
• When we say data bus what do we mean? In the second metric above, most people mean the external data bus which means communication between CPU and memory. When that argument arises they mean that one.

The chaos of terminology:

• I tried to research into this by reading what are the definitions of terms like data bus, internal/external data bus, etc in wikipedia. I need to know the terminology so that I can understand the different arguments better.
• In wikipedia article about data bus in the definition of internal and external bus I read this:  "Internal bus, also known as Internal data bus, memory bus or system bus or front-Side-Bus, connects all the internal components of a computer, such as CPU and memory, to the motherboard"  and  "The external bus, also known as expansion bus, is made up of the electronic pathways that connect the different external devices, such as monitor, printer etc, to the computer.".  Might be correct (what do you say?) but totally inconsistent with the way this terminology is used on the bitness arguments.
• Although in the usual CPU arguments about bitness, people always mean by the external data bus, the CPU<=>Memory communication and the internal data bus probably the internal communication inside the CPU (between regs and ALU and who knows what other stuff). Also the same meaning is used in wikipedia articles describing every CPU. But in the data bus article, internal bus is all those stuff together and external bus is something probably irrelevant with the bitness of the CPU.
• To make things more confusing, sometimes when arguments arise the don't even specify whether it's internal or external, for example "You are not right, this CPU is not a 32bit but it is a 16bit because the data bus is 16bit only". Which one? (I can only deduce that most of the time they mean the CPU<=>memory one, because in the vast majority of CPUs it happens that Regs size ==  internal data bus)

Other less common metrics I have heard:

• ALU bits. It can mean many things (I haven't understood entirely yet)
• Internal communication speed between CPU and ALU. In few words, our classic internal data bus definition (by people on the argument, not the wikipedia article I linked). Usually it occurs to be at the same bits as your CPU regs.
• Do most standard arithmetic operations exist for those bits too? Example: Z80 with it's pseudo 16bit regs can just do ADD HL,DE/BC but not most of the other logical or other operations, so it's not 16bit.
• Calculation bits per cycle! Is Z80 spending one cycle in ALU to do 8bit arithmetic calculations? I just found from two different random sources (just forum discussions though but nothing more official yet :P) that the ALU of Z80 worked at 4bits, that means 2 cycles are spent for a single 8bit add. Someone joked that if taken this metric in account, Z80 would be a 4bit processor and that made me wonder WTF?
• Address bus width. Of course this is absurd and nobody brings it into argument. Yes, the Z80 and 6502 have 16bit address because they need to address 65536 bytes of memory but are they 16bit? Of course not! The classic PC segment/offset style was 20bit, does it make the 8086 an 20bit processor? Nope! Though, classic wikipedia articles on bits, like for example the 32 bit article say this:  "Also, 32-bit CPU and ALU architectures are those that are based on registers, address buses, or data buses of that size."  Of course you could say that it says that they could be based, not should be based, though it could be misleading for someone. Anyway, I am just mentioning this term too to exclude it from the bitness argument.
• Another confusing thing is the bitness of the machine. Of course this doesn't make sense today and it was a marketing gimmick sometimes. For example Atari Jaguar. They said that it was 64bit and yet I know it had an 68000 as main CPU. Though I recently read in the Jaguar wiki page that among the 68000 it also houses several programmable graphics chips with 64bit architecture (does not define which CPUs) and the 68000 is just the chip that manages all these. Even the external databus between  those chips is 64bit I read now. Pretty strange architecture I'd say. But anyway, the bitness of a machine is a different and more subjective and not our current subject which is bitness of CPU.

• The 68000. I always thought of this as an 16bit CPU (maybe because people associated the Amiga or the Mega Drive as 16bit, you know the next generation/marketing confusion (counter argument: but why not market them as 32bit and be more impressive then?)) but some people refer it as 32bit. I read that it certainly has 32bit registers and possibly(?) 32bit ALU but surely the external data bus (CPU<=>memory) is 16bit and in one wikipedia source I've read that even it's internal data bus was 16bit. Most sources I've found distinguish it as a 16bit/32bit processor because of that (the 68000 wiki article cites this to the Motorola MC68000 Family Programmer's Reference Manual).
• In contrast, the 386SX  is fully 32bit internally and with 16bit external data bus  (which is the crippled down version of the 386DX that was 32bit in that aspect too) yet I haven't heard anyone consider it a 16bit. In that sense we have another metric which says: Bitness of a CPU = Regs size & Internal Data Bus (and external data bus doesn't count).
• Same happens with the 8088, which is a crippled down version of 8086. All is 16bit except the external data bus again which is 8bit. At most places I have heard it's a 16bit CPU except from few where I see the 8bit/16bit distinction.
And to finish my little big post, I'd like to say that I just wanted to put things in perspective, so that I can collect all these conflicting thoughts together in this post for a better overall view and maybe also read what other people have to say (if anyone ever reads this and decides to post anyway). I am not a maniac about the number of bits, I don't want to defend my favorite CPUs or something, it's only that sometimes I get too obsessive about discovering whether I can extract few certain facts from tons of conflicting opinions on the internet. If you go and read a single forum where they discuss bitness, you are never sure about the right definition, but if you search more sources and more discussion forums you start creating a more spherical view which might still be conflicting but at least you can collect these things together and try to make sense of them. I am just obsessing about making sense.

Anyway, even the CPU metric is sometimes subjective and as someone said, who cares about bits? Just program the damn thing! Z80 with it's fake 16bit regs is still an 8bit CPU (I never doubted it) yet you can do miracles with those additional opcodes (8-8 fixed point additions with quite less effort and cycles than on 6502) so it's still an advantage. And maybe instead of labeling a CPU with single bits, describing that it has 32bit regs, 32bit ALU, 32bit internal bus and 16bit external bus is a better way to decide for yourself. Or the more complete 16/32bit labeling would suffice. Or in words say: This CPU is 32bit internally but 16bit externally. Makes more sense.

1. Thanks so much for this post. I hate this argument, mainly because the dissenting opinions against the obvious are made by people who like to argue, not like to be right.

Most people define bit-ness as the size of the internal registers, myself included. Some go a little more die-hard and restrict bit-ness to the maximum width of a single ALU operation, and I can mostly get behind that too. For example, on 8088, INC AX is a single instruction that performs a single 16-bit +1. Done and done. MUL is the same, it's a single opcode that multiplies two 16-bit numbers. The end result of the MUL is obviously more than 16 bits, stored in DX:AX, but that does not make it a 32-bit CPU!

2. I envy you, having time to do all these things. I also like computers and all that.. Sounds like you learned so much. :)
Thanks.

3. I just don't try to distill any kind of 'logical' definition of bitness. Clearly it's been used for various marketing strategies over the years, so companies have defined the 'bitness' of their CPUs to whatever suited their product at the time.
For most CPUs there is some consensus on what the most 'correct' bitness is... My experience is slightly different from yours though. To me, these are the most common:
6502/Z80/8088: 8-bit
8086/80286/68000: 16-bit
80386+/68020+: 32-bit (yes, also the 386SX)

I think it's a similar situation as people trying to capture the performance of a CPU into a single metric (be that MIPS, SpecINT/SpecFP or whatever other benchmark).
The concept is wrong from the outset since it depends on various parameters, and as such cannot be expressed in just a single number.
As you said, 'bitness' applies to ALUs, registers, addressing and databus. You can have a CPU with 16-bit registers with 8-bit ALUs, 20-bit addressing, and whatnot.
So bitness of a CPU is nonsense.