Why n is always a power of 2?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Why n is always a power of 2?

aexpert999
When we say that registers and memory chips represent numbers of
n-bit length,why n must always be a power of 2?(8,16,32 an so on).
Maybe it s a simple question and I guess it has something to do with the
flexibility of the system,but,being and trying to implement the chips of chapter 2,the answer to this
question is not clear to me yet.I would appreciate an answer and an example,
thank you in advance.

Andreas,
Greece.
Reply | Threaded
Open this post in threaded view
|

Re: Why n is always a power of 2?

cadet1620
Administrator
aexpert999 wrote
When we say that registers and memory chips represent numbers of
n-bit length,why n must always be a power of 2?(8,16,32 an so on).
It's not a hard requirement, just very convenient. For example, if an instruction wants to address individual bits in a word, it can efficiently encode the bit number if the word is 2^n bits long. If we had a "bitset n" instruction on a 16-bit computer, 4 bits in the instruction will tell which bit to set. Although not as important now since hardware is so highly integrated, hardware used to come in parts that were commonly 4 and 8 bits wide.

The strangest computer I ever worked with had 6-bit bytes arranged in 48-bit rectangular words.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: Why n is always a power of 2?

virote328
In reply to this post by aexpert999
it is a tradition that has to do with byte addressability.

[byte 0][byte 1][byte 2][byte 3]
[byte 4][byte 5][byte 6][byte 7]
.....
[byte C][byte D][byte E][byte F]

Hack seems to be a word addressable plat form
so when you go from ROM[0] to ROM[1], you literally are going from 0 to 1

but in a byte addressable system, going from ROM[0] to ROM[1] actually is ROM[0] to ROM[4]
The word size in my example is 4 bytes, so when it reads it takes 4 bytes at a time starting
at the current byte address.  

even though I made it look nice and neat up there....to the computer it looks more like
[byte 0]
[byte 1]
[byte 2]
[byte 3]
[byte 4]
[byte 5]
[byte 6]
[byte 7]
....

yeah, its a bit confusing...I know