## 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.