0

The following is an excerpt from DTS file. linux/arch/powerpc/boot/dts/[board_name].dts

memory {
    device_type = "memory";
    reg = <0x00000000 0x40000000>;  // 1GB at 0
};

The embedded device has 1 GB of memory.

0x40000000=1073741824 in decimal.

The only way i get 1 GB is when i calculate 1073741824 as bytes.

Which means 1073741824 bytes = 1GB.

So does this mean 0x00000000 points to a byte of data in RAM? In other words, every byte in RAM has an address.

Why is that so? What do we read a block of 8 bits? Why not a word?

New to Rails
  • 2,824
  • 5
  • 27
  • 43

2 Answers2

7

TL;DR : RAM accesses are NOT in byte sized chunks even though each byte is independently addressable(has its own address) in RAM.


The first really successful microprocessors, that took the "digital revolution" mainstream, were 8bit and hence the legacy of the basic chunk of data being 8bit continues till this day. In the first generation of microprocessors with 8bit CPUs, each byte from RAM was read/written to individually.

The next generation was developed with internal CPU registers that were larger than 8bits. They were usually multiples of 8bits(16/32/64) as this allowed them to read multiple complete bytes at once from RAM. Any attempt to read address X from RAM would result in fetching 2/4/8bytes(on 16/32/64bit CPUs) i.e. the word in RAM that contained the address X and only the appropriate byte was retained and stored into the internal CPU registers as required.

Next, with the advent of CPU-caches, RAM started being read from (and written to) in blocks of cacheline size. These are even larger than the size of the register. This would reduce the latency in reading data from RAM due to data locality.

For details, checkout this comprehensive article on CPU and memory by Ulrich Drepper.

TheCodeArtist
  • 21,479
  • 4
  • 69
  • 130
  • Thanks TheCodeArtist for clarification. So each byte is independently addressable but multiple bytes can be read when accessing an address and the appropriate byte is retained in CPU register. Thanks for additional details and beautiful explanation. – New to Rails Aug 11 '13 at 07:58
  • You are just amazing. – New to Rails Aug 11 '13 at 07:59
  • I would not say that the first processors were 8-bit - they weren't as there were examples with both smaller and larger word sizes. But what is true is that **micro** processor designs which really took off were the 8-bit ones, and that helped establish some of the language. You do see a bit less of the 8-bit heritage in a clean-sheet architecture like ARM than in something with backwards compatibility such as x86 (ARM tending to lack support unaligned word access). – Chris Stratton Aug 11 '13 at 13:29
  • Hmmm. True that. Updated my answer to stress that. – TheCodeArtist Aug 11 '13 at 13:35
  • Re Drepper's paper: There was a time when all computers and processors didn't have "network interfaces" because such devices had not yet been invented (i.e pre-1970s). Minicomputers of the 1970s & 80s (which first introduced the concept of low-cost computers and laid the groundwork for microprocessors & microcomputers & PCs) had word sizes that addressed 12 or 16 bits (e.g. DEC PDP8 and DG Nova). @TheCodeArtist - your use of *"CPU"* (and *"processor"*) seems to really mean only "microprocessor". Those are not interchangeable terms. – sawdust Aug 11 '13 at 22:03
  • @sawdust Point taken. Modified my answer to eliminate any confusion. – TheCodeArtist Aug 12 '13 at 00:45
0

You might also note that addresses for memory (Arm DDR, PRU DDR, Shared PRU DDR, etc.) plus memory offsets are all in terms bytes, not processor instructions. Bit Pusher

bit_pusher
  • 158
  • 1
  • 5