7

Essentially, how does 4Gb turn into 4GB? If the memory is addressing Bytes, should not the possibilities be 2(32/8)?

phuclv
  • 37,963
  • 15
  • 156
  • 475
mkatt
  • 433
  • 1
  • 4
  • 11
  • 3
    Confusing question (perhaps with typo: 23 should be 32). Read more about computer architecture. Most common processors are addressing bytes, not bits. – Basile Starynkevitch Sep 13 '14 at 07:30
  • 5
    "2^32" is (an expression representing) a number *without* an implicit unit; that was added arbitrarily and is the core confusion here. Try with something else .. "2^32 melon-flavored ice cream cones", yummy! – user2864740 Sep 13 '14 at 07:39
  • 2
    Each one of the 4 billion addresses actually addresses a byte. If you want to access an individual bit, you need to read the whole byte, do some `bit twiddling` with AND/OR/XOR and then write back the entire containing byte. – Mark Setchell Sep 13 '14 at 07:39

4 Answers4

11

It depends on how you address the data.

If you use 32 bits to address each bit, you can address 232 bits or 4Gb = 512MB. If you address bytes like most current architectures it will give you 4GB.

But if you address much larger blocks you will need less bits to address 4GB. For example if you address each 512-byte block (29 bytes) you can address 4GB with 23 bits. FAT16 uses 16 bits to address (maximum) 64KB clusters and therefore can address a maximum 4GB volume. The same is used in Java Compressed Oops where you can address 32GB of memory with 32-bit reference.

Some older architectures even use word-addressable memory instead of byte like most do nowadays. Modern architectures that have a minimum addressable unit bigger than an octet are mainly found in DSPs. There also a few architectures with bit-addressable memory like Intel 8051

phuclv
  • 37,963
  • 15
  • 156
  • 475
3

Most modern computers are byte-addressable, with each address identifying a single eight bit byte of storage; data too large to be stored in a single byte may reside in multiple bytes occupying a sequence of consecutive addresses.

There exist word-addressable computers, where minimal addressable storage unit is exactly the processor's word. For example, the Data General Nova minicomputer, and the Texas Instruments TMS9900 and National Semiconductor IMP-16 microcomputers used 16 bit words, and there were many 36-bit mainframe computers (e.g., PDP-10) which used 18-bit word addressing, not byte addressing, giving an address space of 218 36-bit words, approximately 1 megabyte of storage.

The efficiency of addressing of memory depends on the bit size of the bus used for addresses – the more bits used, the more addresses are available to the computer. For example, an 8-bit-byte-addressable machine with a 20-bit address bus (e.g. Intel 8086) can address 220 (1,048,576) memory locations, or one MiB of memory, while a 32-bit bus (e.g. Intel 80386) addresses 232 (4,294,967,296) locations, or a 4 GiB address space.

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
Ruslan Gerasimov
  • 1,752
  • 1
  • 13
  • 20
1

The electrical interface on the chip consists (extremely simplified) of a wires for the address (e.g. 32 address lines) and wires for the data (e.g. 8 wires for read data coming from the RAM, 8 wires for write data going to the RAM). In this case you have 232 words of 8 bits, so you can address 232*8 bits of data.

If you had a RAM with a word width of 16-bit instead (much more likely than 8-bit) you would be able to address twice as much RAM with the same number of address bits. On a modern system, you cannot really "read one byte" but instead the CPU fetches a whole cache line from the RAM and then gives you back just the byte that you asked for.

phuclv
  • 37,963
  • 15
  • 156
  • 475
maxy
  • 4,971
  • 1
  • 23
  • 25
0

You can address 2 fields in memory with 1 bits. You can address 4 fields in memory with 2 bits. 00, 01, 10, 11 So we can address memory by 2^n. For 32bit memory that each address holds 1byte can address 4GB data.

2^32 = 4.294.967.296 address can hold 4GByte data.

Mustafa
  • 87
  • 1
  • 8
  • It was never 4Gbit in the first place, though. It's 2^32 bytes = 4 GiB, since bytes are the addressable unit. Also, the dimensions of your formula don't make sense: you can't multiply a bit and a byte to get bytes. Just like area is meters times meters to get m^2, `4 Gbit * 1 byte` would have units `4 G bit * byte` which makes no sense. – Peter Cordes Dec 14 '22 at 06:44
  • Also, your edit broke the image link for no reason; I rolled it back. If you have a new image, upload it to Stack Overflow's imgur via the normal editor interface. – Peter Cordes Dec 14 '22 at 06:45
  • A dimensionally-correct way to express what you're trying to would be `2^32 addressable units * 1 B / unit = 2^32 bytes` or just `2^32 * 1 byte`. Never 2^32 bits. Like you said in the new first paragraph you added. The old text, and the image, both seem only sort of helpful, and misleading at the same time. – Peter Cordes Dec 14 '22 at 07:01
  • Also, why does the diagram have rows 10 bytes wide? What's that supposed to indicate? With 0xffffffff at the top labeling a whole row, it's very weird. That's not the address of the first byte of the row, it's the address of the last. But 0x00000000 is the address of the first byte in its row. (At least it's *not* 8 blocks per row, so people aren't confused about each address holding 8 bytes or something, or that a bit is the same as a byte.) – Peter Cordes Dec 14 '22 at 07:02