Introduction

Memory interfacing is the design of the connection between a processor and its main memory: how memory chips of a given size are combined into a memory of the required size and word width, how each address selects exactly one location, and how the memory is organised so that it can deliver words fast enough. The processor sees one linear array of addressable locations; underneath, that array is built from many identical chips, selected by decoders driven by the high-order address bits.

GATE asks for the number of chips and decoders needed, the address lines of each chip, the address range a chip answers, the effect of incomplete decoding, the byte order of a stored word, DRAM refresh overhead, and the speed-up that memory interleaving gives. The time cost of memory inside the hierarchy is the subject of Memory Hierarchy and Performance.

Prerequisites

Core concepts

Memory chips

A chip described as N×wN \times w stores NN words of ww bits. It has:

SignalCountPurpose
Address lineslg⁡N\lg NSelect one of the NN words
Data lineswwCarry the word in or out
Chip select CS‾\overline{CS} (or CE)1The chip responds only when selected
Read/write R/W‾R/\overline{W}1Direction of the transfer
TechnologyCellProperties
SRAMFlip-flop (about 6 transistors)Fast, no refresh, low density; used for caches
DRAMOne transistor and a capacitorDense and cheap, slower, the charge leaks so every row must be refreshed periodically; used for main memory
ROM, PROM, EPROM, EEPROM, flashFixed or electrically programmedNon-volatile; holds firmware and boot code

DRAM addressing. A DRAM chip stores its cells in a square-ish array of rows and columns. To save pins, the row address and the column address share the same pins and are latched one after the other by the row-address strobe (RAS) and the column-address strobe (CAS). A chip with 22m2^{2m} addressable locations then needs only mm address pins.

Building a memory from chips

To build an M×WM \times W memory from N×wN \times w chips:

  • Width expansion (more bits per word): place W/wW/w chips side by side. They share every address line and the chip select; each supplies ww of the WW data bits.
  • Depth expansion (more words): stack M/NM/N rows of chips. The low lg⁡N\lg N address bits go to every chip; the high lg⁡(M/N)\lg(M/N) bits drive a decoder whose outputs select one row.
  • Number of chips =MN×Ww= \dfrac{M}{N} \times \dfrac{W}{w}. Decoder: lg⁡(M/N)\lg(M/N)-to-(M/N)(M/N).

Address decoding

  • Full decoding: every address bit above the chip's own address lines takes part in selecting the chip, so each memory word has exactly one address.
  • Partial (incomplete) decoding: some high-order bits are ignored. The chip then answers at 2u2^u different addresses, where uu is the number of ignored bits (aliases, foldback or mirror images). Cheaper decoders, wasted address space.

Byte order and alignment

In a byte-addressable memory, a multi-byte word occupies consecutive addresses.

  • Big-endian: the most significant byte is at the lowest address.
  • Little-endian: the least significant byte is at the lowest address.
  • Alignment: a ww-byte item is aligned if its address is a multiple of ww. Misaligned accesses may need two memory accesses or may be forbidden.

Interleaving

Main memory is often split into mm independent modules (banks), each with its own address and data registers, so that several accesses can be in progress at once.

SchemeModule of address aaAddress within moduleGood for
High-order interleavingthe top lg⁡m\lg m bits of aathe remaining bitsExpanding memory module by module; a sequential block within one module has no bank overlap; independent requests to different modules can overlap
Low-order interleavinga mod ma \bmod m (the low lg⁡m\lg m bits)⌊a/m⌋\lfloor a/m \rfloorBlock transfers: consecutive words are in different modules, so their accesses overlap

With low-order interleaving, a block of consecutive words keeps all modules busy at once, which is why it cuts the cache miss penalty.

How it works

A 16K x 16 memory built from eight 4K x 8 chips with a 2-to-4 decoder
Figure 1. A 16K × 16 memory from eight 4K × 8 chips in four rows of two: A11 to A0 go to every chip, A13 and A12 drive a 2-to-4 decoder that selects one row, and the two chips of a row supply data bits D15 to D8 and D7 to D0.
High-order and low-order interleaving of 16 words over four modules
Figure 2. Sixteen words over four modules: with high-order interleaving module mm holds words 4m4m to 4m+34m + 3; with low-order interleaving module mm holds words mm, m+4m + 4, m+8m + 8 and m+12m + 12.

Algorithms and pseudocode

Text
DESIGN-MEMORY(M, W, N, w)                  // target M x W, chips N x w
  rows   <- M / N                          // depth expansion
  cols   <- W / w                          // width expansion
  chips  <- rows * cols
  chipAddressBits <- lg N                  // A(lgN - 1) .. A0 to every chip
  decoderInputs   <- lg rows               // next address bits
  return (chips, rows, cols, decoderInputs)

SELECT(address)                            // full decoding
  row    <- floor(address / N)             // decoder output that goes active
  within <- address mod N                  // word inside every chip of that row
  return (row, within)

Every quantity is a power of 2 in practice, so the divisions are bit-field splits of the address.

Mathematical explanation

Address bits. A memory of MM addressable units needs lg⁡M\lg M address bits. A chip of NN words uses lg⁡N\lg N of them; the decoder uses lg⁡(M/N)\lg(M/N); the two add up to lg⁡M\lg M.

Chip address range (full decoding). Row rr answers addresses rNrN to rN+N−1rN + N - 1.

Aliases (partial decoding). If uu address bits are unused, each location appears at 2u2^u addresses.

DRAM refresh overhead. If a chip has RR rows, each row refresh takes trt_r, and every row must be refreshed once per period TT, then the fraction of time unavailable for normal accesses is R tr/TR\,t_r / T.

Interleaved block read. With mm low-order-interleaved modules, memory access latency tat_a before the bus transfer, with each bank remaining occupied until its subsequent tbt_b transfer ends, and a bus that moves one word per tbt_b, a block of mm consecutive words takes about ta+m tbt_a + m\,t_b instead of m (ta+tb)m\,(t_a + t_b).

Worked examples

Example 1: chips and decoder (Figure 1)

Build a 16K×1616\text{K} \times 16 memory (2142^{14} words) from 4K×84\text{K} \times 8 chips.

  • Chips: 16K4K×168=4×2=8\frac{16K}{4K} \times \frac{16}{8} = 4 \times 2 = 8.
  • Address bits: 14 in total. A11 to A0 (12 bits) go to every chip; A13 and A12 drive a 2-to-4 decoder.
  • Address ranges (hexadecimal, word addresses): row 0 0000 to 0FFF, row 1 1000 to 1FFF, row 2 2000 to 2FFF, row 3 3000 to 3FFF.
  • Address 2ABC: A13 A12 =10= 10, so row 2 is selected, word ABC inside both chips of that row.

Example 2: partial decoding

A 1K×81\text{K} \times 8 chip sits in a 16-bit address space. Its select logic checks only A15 =1= 1 and A14 =0= 0; A13 to A10 are ignored and A9 to A0 go to the chip. The chip responds to every address from 8000 to BFFF: 24=162^4 = 16 aliases of each byte, for example 8000, 8400, 8800, ..., BC00 all reach byte 0. Adding A13 to A10 to the select logic (all four 0) would confine the chip to 8000 to 83FF.

Example 3: interleaving speed

Each module needs 80 ns per access, and the bus moves one word in 20 ns; a module stays busy until its word has been transferred. Read 8 consecutive words.

  • One module, or high-order interleaving when the 8 words lie inside the same module: 8×(80+20)=8008 \times (80 + 20) = 800 ns.
  • Four low-order-interleaved modules: words 0 to 3 are ready at 80 ns and leave at 100, 120, 140 and 160 ns; modules 0 to 3 then start words 4 to 7 at 100, 120, 140 and 160 ns, which leave at 200, 220, 240 and 260 ns. Total 260 ns, a speed-up of about 3.1.

Example 4: DRAM refresh

A DRAM has 214=163842^{14} = 16384 rows, each row must be refreshed every 64 ms, and one row refresh takes 50 ns. Refresh time per period: 16384×5016384 \times 50 ns =819.2= 819.2 μ\mus, so 819.2 μs/64819.2\,\mu\text{s} / 64 ms =1.28%= 1.28\% of the time is spent refreshing. Spreading the refreshes evenly means one row every 64 ms/16384≈3.9 μ64\text{ ms}/16384 \approx 3.9\,\mus.

Example 5: byte order

The 32-bit value 0x12345678 is stored at byte address 100.

Address100101102103
Big-endian12345678
Little-endian78563412

Reading the byte at address 100 gives 0x12 on a big-endian machine and 0x78 on a little-endian one; reading the 16-bit half-word at 100 gives 0x1234 and 0x5678.

Example 6: DRAM pins

A 256K×4256\text{K} \times 4 DRAM has 2182^{18} locations, so 18 address bits. With row and column addresses multiplexed on the same pins (9 row bits, then 9 column bits), it needs only 9 address pins and 4 data pins.

Important properties and observations

  • Chips in one row share the address and select lines; chips in one column share the data lines.
  • The decoder uses the high-order bits in depth expansion; the low-order bits go to every chip.
  • Partial decoding saves logic but creates aliases; two devices whose aliases overlap would conflict.
  • Low-order interleaving helps sequential access; high-order interleaving can overlap independent requests to different modules, from one or more request sources, but not a sequential block wholly inside one module.
  • Endianness matters only for multi-byte items. A byte array looks the same on both.
  • DRAM refresh overhead is small but must be included when a question asks for the available bandwidth.
  • Common misconceptions.
    • "Number of chips =M/N= M/N." Width expansion multiplies it by W/wW/w.
    • "A 4K chip needs 4 address lines." It needs lg⁡4096=12\lg 4096 = 12.
    • "Interleaving makes one access faster." Each access still takes the module's full access time; interleaving overlaps accesses.

GATE examination perspective

  • CHIP COUNT. (M/N)×(W/w)(M/N) \times (W/w), after converting both to the same units.
  • DECODER SIZE. lg⁡(rows)\lg(\text{rows})-to-rows; for width expansion only, no decoder is needed.
  • ADDRESS RANGE. Fix the decoder bits for the chosen row; the chip bits run from all 0s to all 1s.
  • ALIASES. Count the address bits that neither the chip nor the decoder uses: 2u2^u copies.
  • INTERLEAVED TIMING. Draw the module timeline; low-order interleaving overlaps consecutive requests; high-order interleaving can overlap independent requests to different modules.
  • REFRESH. Rows times refresh time divided by the refresh period.
  • BYTE ORDER. Write the bytes out address by address before answering.

Summary

Sources

  1. C. Hamacher, Z. Vranesic, S. Zaky, Computer Organization, 5th ed., McGraw-Hill, 2002, Chapter 2, Section 2.2 (Memory Locations and Addresses, including 2.2.2 Big-endian and Little-endian Assignments and 2.2.3 Word Alignment); Chapter 5, Sections 5.2 (Semiconductor RAM Memories, including 5.2.1 Internal Organization of Memory Chips and 5.2.5 Structure of Larger Memories), 5.3 (Read-Only Memories) and 5.6.1 (Interleaving).
  2. W. Stallings, Computer Organization and Architecture, 10th ed., Pearson: Section 5.1 (Semiconductor Main Memory).

Next steps