0

From the materials (edit: including the links referred to) I have studied, 32 bit MIPS programming address space seems to have a total address space of 4 GB (giga bytes). But from my calculations, it should be greater - around 17 GB (giga bytes).

I have tried googling, but this 4GB number keeps popping up everywhere.

If each word in memory is 32 bits (4 bytes), then we can have 2^32 such permutations. Each of these numbers is 4 bytes, therefore, total (virtual) memory should be at least 4*(2^32) bytes = 17 GB?

Musa Khan
  • 21
  • 4
  • 2
    MIPS is byte-addressable; the size of the unique memory for every address is 1 byte. Also, 4 * 4 = 16 GiB, not 17. – Peter Cordes Aug 19 '19 at 06:00
  • I don't understand. I am not disputing that 4*4 = 16GiB. But, 4*(2^32) = 17GB. The post you referred to as a possible duplicate doesn't answer my specific question. I can see that MIPS provides 2^32 addresses, but why is that 4GB? Isn't each address equivalent to 4 bytes? Can you please tell me what error I made in my calculation? – Musa Khan Aug 19 '19 at 06:09
  • Did you look at all 3 Q&As? I found other duplicates about MIPS being byte-addressable, not word-addressable. – Peter Cordes Aug 19 '19 at 06:23
  • 1
    `2^34` is exactly 16.000 GiB. For RAM sizes, we always use power-of-2 unit prefixes (2^10 = kiB, 2^20 = MiB, 2^30 = GiB), not decimal prefixes (10^3 = kB, 10^6 = MB, 10^9 = GB). Many people don't bother with GiB vs. GB and just write 17179869184 = 16GB. It's not *exactly* 17.0GB so it makes no sense to write it that way. https://en.wikipedia.org/wiki/Binary_prefix explains, and shows the IEC prefixes, and that JEDEC (the DRAM standards body) endorses Giga = 2^30. TL:DR: Computer RAM sizes are always in binary units. Hard drive space is often in decimal units, but not RAM. – Peter Cordes Aug 19 '19 at 06:26
  • Ok, so is program address space 16 GiB? Apart from the wrong units that I am using, is my logic of total space being 2^34 correct? If that is the case, why do people say its 4 GB? – Musa Khan Aug 19 '19 at 06:40
  • No, it's 4GiB. Read the linked duplicates. MIPS is byte-addressable, and has 2^32 unique addresses. – Peter Cordes Aug 19 '19 at 06:43
  • I appreciate that you are responding. I have carefully gone through all the links. I understand that MIPS is byte addressable and that there are 2^32 addresses. My question is, how much space does each of those 32 unique addresses take, in bytes? – Musa Khan Aug 19 '19 at 06:58
  • You said its 1 byte previously (your first comment). But isn't each address 32 bits? – Musa Khan Aug 19 '19 at 07:06
  • The address value itself is 32 bits, that's why there are 2^32 of them. But the memory it points to is only 1 byte wide. That's what being byte-addressable means. Consider an 8-bit machine like 8080, with 16-bit addresses (that take 2 registers). It can address 64kiB of memory. It might be able to do 16-bit loads into a pair of registers treated as one 16-bit location, but the "normal" thing is always to load 1 byte at a time. Address width and data width are orthogonal. See also [Difference between word addressable and byte addressable](//stackoverflow.com/q/2724449) – Peter Cordes Aug 19 '19 at 07:16
  • Maybe it would help if you think this way: MIPS `lw` (a 4-byte load) requires the low 2 address bits to be zero. So there are only 2^30 valid aligned word addresses. If you allow unaligned word loads on the byte-addressable memory, then every byte is part of 4 mostly-overlapping unaligned words. – Peter Cordes Aug 19 '19 at 07:23
  • I think I kind of get it now! I was conflating 32 bit addresses with 32 bits of data. Thank you so much for your patience! :) – Musa Khan Aug 19 '19 at 08:24

0 Answers0