0
votes

Im trying to learn about memory addressing (this is for Uni) and im unsure about the effect that a word addressable memory would have when i need to calculate number of address bits.

I will explain what (i think) I understand first.

To calculate the number of address bits I use : log2(n) where n is the number of bits of the memory.I.e for 1gb (1024mb * 1024 * 1024)= 1073741824 bits so therefore log2(1073741824 ) = 30 meaning a 1gb memory would require 30 address bits. I think im understanding that correctly.

The part im not sure about is byte addressable memory versus word addressable memory and how it might effect the number of address bits.

THE QUESTION: Is it that the above example is correct ONLY for byte addressable and if for instance a memory was word addressable and using 16 bit or 32 bit words then the number of address bits required would be less (1/2 or 1/4 in the case of 16 and 32 bit words)??

My thinking is that if a cel holds 8 bits in a byte addressable machine then a cel in word addressable memory would hold 16bits or 32bits and therefore the address bits required should be less.

Further notes - I am aware that most memory nowadays is byte addressable and that word size in a computer is specific to the processor / bus , but the problems im working on do not mention and just ask about the effect byte /word addressable would have.

I have searched for other questions on this and not found one that answers it (or that i understand to answer it) . This for examplehttps://stackguides.com/questions/19528750/byte-word-addressable actually seems to be asking a similar thing but the OP seems to have posted the question incorrectly by specifying that the memory is 4M x 16 (instead of 4mb x 16bit) leading people to calculate the memory as 64mb.

1

1 Answers

1
votes

First off, you need to be careful with you bits and bytes, the original example you have seems to deal with bits, each you really seem to want to know about bytes. It does matter when we are dealing with a bit addressable memory or a byte addressable memory. So, lets talk about things in terms of byte addressable or word addressable memory.

As stated, your analysis of how to get the number of bits needed to address a memory is correct; but it can be generalized. In order to get the minimum number of bits we need to fully address a memory, we need to know how many unit-size things we can address. In your case, you were calculating the number of addresses need to address a 1 Gb (giga-bit) memory. We can just as easily do it in bytes, in order to byte address a 1 GB (giga-byte) memory, you need to know the number of addressable things (bytes) there are and then take the log2 of it. So, number of things there are is easy to get, (1 GB has 1024^3 or 1 G bytes in it) so we just need to log2 that; log2(1 G) = log2(1024*1024*1024) = 3*log2(1024) = 3 * 10 = 30. So, we need 30 bits to fully address that space.

Now lets talk in words. First is knowing the word size. Word size is not strictly 32 or 16 bits, it can be a range of values, typically dependent on whatever the processor decides to call a word (or the spec that is). Lets deal in 32-bit words for our example.

Now that we have a word size, we need to know the memory size. Lets assume the same 1 GB from before, but now we are word addressing it (its a word addressable memory now and the word size is 32 bits or 4 bytes). So, just as before, we need to know the number of addressable things (now its words) that there are in the memory size. Well, this time it isnt 1 G, because our addressable thing is now 4 B in size instead of 1 B. So we need to take our 1 GB memory size and divide it by the word size (1 GB / 4 B = 0.25 G). Just as before, now that we have the number of addressable things (0.25 G), we just need to that the log2 of it; log2(0.25G) = log2 (256*1024*1024) = log2(256) + 2*log2(1024) = 8 + 2 * 10 = 28.

It all some down to the number of the addressable things (words, bytes, bits) in a given memory. As we typically give memory sizes in bytes, byte addressable calculations are easy, but the others just take a little manipulation to get something from a dimensional value (1 GB) into dimensionless value (1 G, ie 1024^3).