# Memory access on byte/word addressable memory [duplicate]

I'm doing a question on architecture and I've come across this question which I do not understand how to answer the question.

Q. How many bits are required to address 4G x 32-bit main memory if

a) Main memory is word addressable b) Main memory is byte addressable

I have read this question Word- or byte-addressable? Correct terminology but it did not clear up my understanding of the question as I am NOT asking what is the difference between byte and word addressable, more specifically I want to understand this question I've written.

The answer given says we need 34 bits for byte addressable memory and 32 bits for word addressable memory. I have thought about this for a while and have come to this conclusion which I do not know if it is correct or not:

Each row in the main memory is 32 bits in width and if it is byte addressable then we have 4 bytes in each row. To select a byte from the row requires log2(4) = 2 bits. Row width + 2 = 34 bits? Similiar concept for 32 bits. Is this correct logic?

• I have edited my post now, please re read it. Thank you. – Nubcake Apr 22 '15 at 11:56

The error in your solution comes where you say "Row width + 2?" To select a byte in memory, you must (a) select a row, and (b) select a column.

Let's see how this works out for the byte-addressable case. As you say, selecting a column takes 2 bits, since there are 4 columns. However, the number of bits to select a row is log2(number of rows), not the row width [the row width is irrelevant]. So, figure out how many rows there are, then take the binary logarithm of that, and add 2 to it -- you'll get the correct number of bits needed to address byte-addressable memory.

The same methodology can be applied for the word-addressable case. Just count the number of bits needed to select a row, and the number of bits needed to select a column.

• I see! Thank you very much, I understood completely. I knew that there was something wrong with my intuition because it did not sit right with me; I thought something was odd when I said we select a byte within a row then why would we need 34 bits I thought. Now you mention a we need to select a column (byte) within the row, it all makes perfect sense to me. – Nubcake Apr 22 '15 at 16:38