CLOSE

What is Memory Addressing?

Memory addressing is the process of referencing a specific location in a computer's memory. Every byte in a computer's memory has a unique address. These addresses are used by the CPU to read from or write to specific memory locations. Without memory addressing, computers wouldn't be able to store or retrieve data.

How Memory Addressing Works

Memory addressing works on the principle of binary numbers. In a computer's memory, each byte is assigned a unique address, starting from 0 and incrementing sequentially. These addresses are expressed in binary form, which allows computers to represent large numbers using only 0s and 1s.

  • A single address represents one byte.

For example, in a system with 8-bit memory addressing, there are 2^8 or 256 possible memory locations, with addresses ranging from 0 to 255. Each memory location holds one byte of data.

Address     Data
0           Byte 0
1           Byte 1
2           Byte 2
...         ...
255         Byte 255

When the CPU needs to access data in memory, it sends the memory address along with the read or write command to the memory controller. The memory controller then retrieves the data from the specified memory location and sends it back to the CPU.

image-129.png

Addressing Space

The amount of memory that a computer system can address is determined by the number of bits used for memory addressing. The formula for calculating the addressing space is:

Addressing Space = 2^n bytes

where n is the number of bits used for addressing.

For Example:

  • With 8-bit addressing (n = 8), the addressing space is 2^8 = 256 bytes.
  • With 16-bit addressing (n = 16), the addressing space is 2^16  = 65,536 (64 KB).
  • With 32-bit addressing (n = 32), the addressing space is 2^32 = 4,294,967,296 bytes (4 GB).
Memory addresses usually point to 1 byte. The theoretical maximum is 4GB for a 32-bit CPU. In other words, a CPU can point to a maximum of 2^32 - 1 bytes.

As a side note the address bus can be lower than the theoretical maximum. AMD and Intel 64-bit CPUs usually have a 48-bit address bus, not 64-bit.

RAM Access

The CPU's ability to read a specific amount of data from memory in every clock cycle.

It depends on Data Bus Width.

  • Data Bus Width: The width of the data bus determines how many bits of data the CPU can read from memory in a single clock cycle. In a 32-bit system, the data bus is 32 bits wide, allowing the CPU to read 32 bits (4 bytes) of data in one clock cycle.

In a 32-bit system, the CPU typically reads data from memory in units of 4 bytes (32 bits) at a time. This is known as a double word. Each memory access fetches 4 bytes of data.

RAM Access in a 32-bit System

  • Data Width: 32 bits (4 bytes)
  • Memory Access: 4 bytes at a time

Explanation:

In a 32-bit system:

  • Each memory address points to a single byte.
  • However, the CPU accesses data in units of 4 bytes (32 bits) at a time.
  • This means that in every clock cycle, the CPU reads 4 bytes of data from memory.

Example:

Let's say the CPU wants to read data from memory at address 0x1000. In a 32-bit system:

  • The CPU will read 4 bytes of data starting from address 0x1000.
  • It will read bytes at addresses 0x1000, 0x1001, 0x1002, and 0x1003.
  • Each of these bytes is 1 byte wide, so a total of 4 bytes (32 bits) of data is read in a single memory access.

Hexadecimal Memory Address

Memory addresses are often represented in hexadecimal (hex) format because it provides a convenient and compact way to represent large binary numbers. Hexadecimal is a base-16 numbering system that uses 16 symbols: 0-9 and A-F, where A stands for 10, B for 11, up to F for 15.

Why Use Hexadecimal Representation for Memory Addresses?

  1. Compact Representation: Hexadecimal representation allows large binary numbers to be represented using fewer digits compared to binary or decimal representation. This is important for memory addresses, which can be very large numbers.
  2. Easy Conversion: Hexadecimal is easy to convert to and from binary. Each hexadecimal digit corresponds to 4 binary digits (bits), making it easy to represent groups of bits.
  3. Alignment: Memory addresses are often aligned to byte boundaries. Since a byte consists of 8 bits, and 4 bits can be represented by a single hexadecimal digit, memory addresses align neatly with hexadecimal representation.

Example:

Let's consider a memory address in a 32-bit system:

  • Memory Address in Binary: 1100 1010 1111 0011 0000 1101 0101 1010
  • Memory Address in Hexadecimal: CAF30D5A

As you can see, the hexadecimal representation is much shorter and easier to read compared to the binary representation.