Word Size – How Does Word Size Impact Virtual Address Space?

bitword

So, I should really know this stuff already, but I am starting to learn more about the lower levels of software development. I am currently reading Computer Systems: A Programmer's Perspective. by Bryant O'Hallaron.

I am on chapter 2 and he is talking about the way data is represented internally.

I am having trouble understanding something conceptually and I am sure that I'm about to make my ignorance lucid here.

I understand that a "word" is just a set of bytes and that the word size is just how many bits wide the system bus is. But, he also says: "the most important system parameter determined by the word size is the maximum size of the virtual address space. That is, for a machine with a w-bit word size, the virtual addresses can range from 0 to (2^w)-1, giving the program access to at most 2^w bytes"

I am both confused on the general relationship between the word size and the amount of addresses in the system and how the specific formula is w-bit word size=2^w bytes of memory available.

I am really scratching my head here, can some one help me out?

EDIT: I actually misinterpreted his definition of a word and consequently the definition of word size. What he really said was:

Busses are typically designed to transfer fixed-sized chunks of bytes
known as words. The number of bytes in a word (the word size) is a
fundamental system parameter that varies across systems. most machines
today have word sizes of either 4 bytes(32 bits) or 8 bytes(64 bits).
For the sake of our discussion here, we will assume a word size of 4
bytes, and we will assume that buses transfer only one word at a
time.

which is pretty much a catch-all for the cases discussed in the answers without having to go into detail. He also said he would be oversimplifying some things, perhaps in later sections he will go into more detail.

Best Answer

The idea is that one word of memory can be used as an address in the address space (i.e., a word is wide enough to hold a pointer). If an address were larger than a word, addressing would require multiple sequential words. That's not impossible, but is unreasonably complicated (and likely slow).

So, given an w-bit word, how many values can that word represent? How may addresses can it denote? Since any bit can take on two values, we end up with 2·2·2·…·2 = 2w addresses. Addresses are counted starting by zero, so the highest address is 2w - 1.

Example using a three-bit word: There are 23=8 possible addresses:

bin: 000 001 010 011 100 101 110 111
dec:   0   1   2   3   4   5   6   7

The highest address is 23-1 = 8 - 1 = 7. If the memory is an array of bytes and the address is an index to this array, then using a three-bit word we can only address eight bytes. Even if the array physically holds more bytes, we cannot reach them with a restricted index. Therefore, the amount of virtual memory is restricted by the word size.