G27
Self-checkedTier 1 11 min readcoa.memory-interfacing

Memory interfacing and address decoding

Connecting memory chips to a processor: address, data and control lines, chip select from a decoder, building a memory from smaller chips in width and in depth, the address map, partial decoding and aliasing, memory-mapped I/O and interleaving.

Why it exists

A processor has an address bus, a data bus and a few control lines. Memory comes as chips of a fixed size and width, and a system needs more words (a larger address space), more bits per word (a wider data bus), and often a mixture of RAM, ROM and I/O devices. Memory interfacing is the wiring and the small amount of logic that makes a set of chips look like one memory at the right addresses. The central tool is the address decoder, which turns the high-order address bits into a chip select for exactly one chip. GATE asks for the number of chips, the address lines of each chip, the address range of each chip, the decoder, and what happens when the decoding is incomplete.

Prerequisites

You need the decoder with its enable input.

Precise definitions

Buses. The address bus carries the address from the processor to the memory (nn lines address 2n2^n locations). The data bus carries data in both directions (ww lines give ww-bit words). The control bus carries signals such as read, write and a clock or ready line.

Memory chip. A chip of 2k2^k words of bb bits has kk address lines Ak−1…A0A_{k-1} \ldots A_0, bb data lines, a chip select (CS or enable) input that makes the chip respond (otherwise its data lines are disconnected), and read/write control. A 16K×816\text{K} \times 8 chip has 14 address lines and 8 data lines.

Building a bigger memory.

  • More bits per word (wider). Put chips side by side: all chips receive the same address and chip select, and each supplies a different slice of the data bus. Two 16K×816\text{K} \times 8 chips make 16K×1616\text{K} \times 16.
  • More words (deeper). Chips share the low address lines, the data lines and the read/write lines, and each has its own chip select, driven by a decoder from the high-order address bits. Four 16K×816\text{K} \times 8 chips make 64K×864\text{K} \times 8.
  • Number of chips for a memory of WW words ×\times BB bits from chips of w×bw \times b: Ww×Bb\dfrac{W}{w} \times \dfrac{B}{b} (the depth factor times the width factor). Example: 64K×1664\text{K} \times 16 from 16K×816\text{K} \times 8 chips needs 4×2=84 \times 2 = 8 chips.

Address decoding. The address lines split into two parts: the low-order lines, as many as the chip has, go to every chip and select the location inside it; the remaining high-order lines go to a decoder whose outputs are the chip selects. For a 64K64\text{K} space (16 address lines) built from four 16K16\text{K} chips, A13…A0A_{13} \ldots A_0 go to the chips and A15A14A_{15}A_{14} go to a 2-to-4 decoder: chip 0 covers 0000160000_{16} to 3FFF163\text{FFF}_{16}, chip 1 40004000 to 7FFF7\text{FFF}, chip 2 80008000 to BFFF\text{BFFF}, chip 3 C000\text{C000} to FFFF\text{FFFF}.

Address map. The table of which address range belongs to which chip or device. A device's range must not overlap another's.

Full and partial decoding. In full decoding every address line is used, so each location has exactly one address. In partial decoding some high-order lines are not connected to the decoder; a location then responds to several addresses (aliases or foldback), 2d2^d of them if dd lines are ignored. It needs fewer gates but wastes address space and the unused combinations cannot be given to other devices.

Memory-mapped I/O and isolated I/O. With memory-mapped I/O the device registers occupy addresses of the ordinary memory address space, read and written by ordinary load and store instructions; the address decoder produces a device select for their range. With isolated (port-mapped) I/O there is a separate I/O address space and special IN and OUT instructions with their own control signal (I/O interface).

Interleaving. To let several memory modules work at once, consecutive addresses are spread across banks. With low-order interleaving the bank number is the low address bits (bank=address mod m\text{bank} = \text{address} \bmod m for mm banks), so a run of consecutive words hits each bank in turn and the accesses overlap; with high-order interleaving each bank holds a contiguous block (this is just the deep construction above).

How it works

The animation decodes five addresses in a 64 KB space made of four 16 KB chips: the two high bits select the chip and the remaining 14 bits go to the chip. The last step shows partial decoding, where A15A_{15} is not connected: the same chip and location answer to the address and to the address 0x8000 below it.

Address decoding: 64 KB from four 16 KB chips: The first address of the memory

Computed exactly, not typed

Working

chip select = A15 A14   (2-to-4 decoder)
chip address lines = A13 .. A0

Value, format and bits (changed bits in amber)

address A15..A0 = 0x0000unsigned= 0
00000000
00000000
decoder inputs A15 A14pattern= 0
00
address inside the chip A13..A0unsigned= 0
00000000
000000
selected chip= chip 0

Step 1

The 64 KB address space is built from four chips of 16 KB. A 16 KB chip has 14 address lines, so address bits A13 to A0 go to every chip, and the top two bits A15 and A14 go to a 2-to-4 decoder that selects exactly one chip. Address 0 selects chip 0, location 0.

1 / 6
computed by script: a simulation of the machine, one register transfer per step. Python 3.15.1, darwin arm64. python3 scripts/gen-coa-traces.py

Worked examples

EX 1Decoding a whole address space in a program

Easy
#include <stdio.h>
 
/* a 64 KB space built from 16 KB chips: A15 A14 go to a 2-to-4 decoder, A13..A0 go to every chip */
static int chip_of(unsigned a) { return (int)(a >> 14); }
static unsigned inside(unsigned a) { return a & 0x3FFF; }
/* partial decoding: only A14 is used, A15 is ignored */
static int chip_partial(unsigned a) { return (int)((a >> 14) & 1); }
 
int main(void) {
    int count[4] = {0, 0, 0, 0}, ok = 1;
    for (unsigned a = 0; a < 65536; a++) {
        int c = chip_of(a);
        count[c]++;
        ok = ok && a >= (unsigned)c * 16384u && a < ((unsigned)c + 1) * 16384u && inside(a) == a - (unsigned)c * 16384u;
    }
    printf("full decoding: addresses per chip %d %d %d %d, ranges consistent: %d\n", count[0], count[1], count[2], count[3], ok);
    printf("chip 2 covers 0x%04X to 0x%04X\n", 2 * 16384, 3 * 16384 - 1);
    int c2[2] = {0, 0}, alias = 0;
    for (unsigned a = 0; a < 65536; a++) {
        c2[chip_partial(a)]++;
        alias += chip_partial(a) == chip_partial(a ^ 0x8000) && inside(a) == inside(a ^ 0x8000);
    }
    printf("partial decoding (A15 ignored): chips seen %d and %d times; %d of 65536 addresses have an alias 0x8000 away\n", c2[0], c2[1], alias);
    /* how many chips and which address lines */
    long total_words = 64 * 1024, chip_words = 16 * 1024;
    int width = 16, chip_width = 8;
    printf("64K x 16 from 16K x 8 chips: %ld chips (%ld deep x %d wide), %d address lines per chip\n", (total_words / chip_words) * (width / chip_width), total_words / chip_words, width / chip_width, 14);
    return 0;
}
full decoding: addresses per chip 16384 16384 16384 16384, ranges consistent: 1
chip 2 covers 0x8000 to 0xBFFF
partial decoding (A15 ignored): chips seen 32768 and 32768 times; 65536 of 65536 addresses have an alias 0x8000 away
64K x 16 from 16K x 8 chips: 8 chips (4 deep x 2 wide), 14 address lines per chip

Reading it. Every one of the 65536 addresses selects exactly one chip (16384 addresses each). Chip 2 covers 8000168000_{16} to BFFF16\text{BFFF}_{16}. With A15A_{15} ignored, every address has an alias exactly 8000168000_{16} away: the 64 KB of address space contains only 32 KB of distinct locations, each chip seen from two address ranges.

EX 2Count the chips

Easy

A 1M×321\text{M} \times 32 memory is built from 256K×4256\text{K} \times 4 chips. Depth: 1M/256K=41\text{M} / 256\text{K} = 4; width: 32/4=832 / 4 = 8. Chips: 4×8=324 \times 8 = 32. Each chip has log⁡2256K=18\log_2 256\text{K} = 18 address lines. The memory has 20 address lines (for 2202^{20} words), so the 2 highest lines drive a 2-to-4 decoder. A 4K×84\text{K} \times 8 memory from 1K×81\text{K} \times 8 chips needs 4 chips, 10 address lines per chip and 2 lines for the decoder.

EX 3Mixed RAM and ROM in an address map

Medium

A 16-bit address space holds a 2 KB ROM starting at address 0 and 4 KB of RAM right after it, and a device with 16 registers at F00016F000_{16}. The ROM uses 11 address lines (211=20482^{11} = 2048) and occupies 00000000 to 07FF07\text{FF}. The RAM occupies 08000800 to 17FF17\text{FF} (4096 addresses). The device occupies F000F000 to F00FF00F. Each needs its own chip select: the ROM when A15…A11=00000A_{15} \ldots A_{11} = 00000; the RAM needs a range that does not align to a power of two (08000800 to 17FF17\text{FF} straddles 10001000), which shows why designers usually align each chip to a multiple of its own size (the RAM would better start at 10001000). An address map with aligned ranges needs only a simple decoder on the top bits.

EX 4Which address lines go where

Medium

For a 64K64\text{K} space with 8K×88\text{K} \times 8 chips: each chip has 13 address lines (A12…A0A_{12} \ldots A_0) connected to every chip; the remaining 3 lines A15A14A13A_{15} A_{14} A_{13} go to a 3-to-8 decoder with 8 outputs for the 8 chips. Chip 5 (101101) covers A000A000 to BFFFBFFF. If only A15A14A_{15} A_{14} are connected, the decoder has 4 outputs and each 16 KB range (two chips) answers together, which is a conflict unless one chip is simply not installed.

EX 5Partial decoding

GATE level

A system uses a 2-to-4 decoder on A15A14A_{15} A_{14} for four 16 KB chips but the designer leaves A15A_{15} unconnected (the decoder sees A14A_{14} and a constant). Then two chips are visible, each at two addresses: location 0123160123_{16} and location 8123168123_{16} reach the same cell. The number of aliases of each location is 21=22^{1} = 2 (one ignored line). In the animation's last step, address 0x8123 is the same cell as 0x0123. The effect on software: writing at one address changes the value read at the other.

EX 6Interleaving

GATE level

A memory has 4 banks, low-order interleaved: address aa is in bank a mod 4a \bmod 4. The 8 consecutive words 0…70 \ldots 7 occupy banks 0, 1, 2, 3, 0, 1, 2, 3, so a burst of consecutive accesses starts a new bank every cycle and the banks work in an overlapped way. With high-order interleaving the 8 words would sit in the same bank (a contiguous block) and have to be accessed one after the other.

Cheat box

Cheat box

  • nn address lines: 2n2^n locations. A 2k×b2^k \times b chip has kk address lines.
  • Wider: same address, different data bits. Deeper: same low lines, separate chip selects from a decoder on the high lines.
  • Chips =(W/w)×(B/b)= (W / w) \times (B / b). Decoder inputs =log⁡2(number of chips in depth)= \log_2(\text{number of chips in depth}).
  • Chip ii of size ss covers i si\,s to (i+1) s−1(i + 1)\,s - 1 (aligned).
  • Full decoding: one address per location. Partial: 2d2^d aliases when dd high lines are ignored.
  • Memory-mapped I/O uses memory addresses; isolated I/O has its own space and instructions.
  • Low-order interleaving: bank =a mod m= a \bmod m.

Traps and GATE patterns

Connections

The chip select decoder is a decoder with enable. The memory it builds is the main-memory level of the hierarchy, made from the chip types of RAM and ROM. Device registers placed in the address map are reached by programmed I/O, and DMA lets a device master the same buses.

PYQs

8 previous year questions from your book. I re-solved each one myself (8 by running or simulating, 0 by reasoning only); the book's key is shown next to my answer. All PYQs

GATE 2023 · MCQ · 2 marksQ1 · page 451 of the book
A 4 kilobyte (KB) byte-addressable memory is
realized using four 1 KB memory blocks. Two
input address lines (IA4 and IA3) are connected
to the chip select (CS) port of these memory
blocks through a decoder as shown in the figure.
The remaining ten input address lines from IA11-
IA0 are connected to the address port of these
blocks. The chip select (CS) is active high.

The input memory addresses (IA11-IA0), in
decimal, for the starting locations (Addr = 0 ) of
each block (indicated as X1, X2, X3, X4 in the
figure) are among the options given below.
Which one of the following options is
CORRECT?
  • (a)(0,1,2,3)
  • (b)(0,1024,2048,3072)
  • (c)(0,8,16,24)
  • (d)(0,0,0,0)
GATE 2019 · MCQ · 1 markQ3 · page 451 of the book
The chip select logic for a certain DRAM chip in a
memory system design is shown below. Assume that
the memory system has 16 address lines denoted by
A15 to A0. What is the range of address (in
hexadecimal) of the memory system that can get
enabled by the chip select (CS) signal?
  • (a)C800 to CFFF
  • (b)CA00 to CAFF
  • (c)C800 to C8FF
  • (d)DA00 to DFFF
GATE 2018 · NATQ4 · page 451 of the book
A 32 -bit wide main memory unit with a capacity of
1 GB is built using 256M × 4-bit DRAM chips.
The number of rows of memory cells in the DRAM
chip is 214 .The time taken to perform one refresh
operation is 50 nanoseconds.The refresh period is 2
milliseconds.The percentage(rounded to the
closest integer)of the time available for performing
the memory read/write operations in the main
memory unit is   .
Computer Organization and Architecture
GATE 2016 · NAT · 1 markQ5 · page 452 of the book
A processor can support a maximum memory of 4
GB, where the memory is word-addressable (a
word consists of two bytes). The size of address bus
of the processor is at least   bits.
GATE 2009 · MCQ · 1 markQ6 · page 452 of the book
How many 32k × 1 RAM chips are needed to
provide a memory capacity of 256 K-bytes?
  • (a)8
  • (b)32
  • (c)64
  • (d)128
GATE 2014 · NATQ36 · page 500 of the book
Consider a main memory system that consists of 8
memory modules attached to the system bus, which
is one word wide. When a write request is made, the
bus is occupied for 100 nanoseconds (ns) by the
data, address, and control signals. During the same
100 ns, and for 500 ns thereafter, the addressed
memory module executes one cycle accepting and
storing the data. The (internal) operation of different
memory modules may overlap in time, but only one
request can be on the bus at any time. The maximum
number of stores (of one word each) that can be
initiated in 1 millisecond is
.
GATE 2020 · NATQ6 · page 175 of the book
If there are m input lines and n output lines for a
decoder that is used to uniquely address a byte
addressable 1 KB RAM, then the minimum value of
m + n is ____.
GATE 2014 · NATQ31 · page 344 of the book
Consider the main memory system that consists of 8
memory modules attached to the system bus, which is
one word wide. When a write request is made, the bus
is occupied for 100 ns by the data, address, and
control signals. During the same 100 ns, and for 500
ns thereafter, the addressed memory module executes
one cycle accepting and storing the data. The internal
operation of different memory modules may overlap
in time, but only one request can be on the bus at any
time. The maximum number of stores (of one word
each) that can be initiated in 1 millisecond is ______

OPERATING SYSTEMS

Self-check

Question 1

How many 2K×82\text{K} \times 8 chips make a 16K×1616\text{K} \times 16 memory, and how many address lines go to the decoder?

Show answer

Depth 16K/2K=816\text{K}/2\text{K} = 8, width 16/8=216/8 = 2: 16 chips. The memory has 14 address lines; each chip has 11; the 3 remaining lines go to a 3-to-8 decoder.

Question 2

What address range does chip 3 of four 16K16\text{K} chips cover in a 64 KB space?

Show answer

C00016C000_{16} to FFFF16FFFF_{16}.

Question 3

Two high-order address lines are ignored by the decoder. How many addresses select each memory location?

Show answer

22=42^2 = 4.

Question 4

With 8-way low-order interleaving, which bank holds address 100?

Show answer

100 mod 8=4100 \bmod 8 = 4: bank 4.

Revision card

One-screen revision

  • Low address lines to the chips, high lines to the decoder; chip selects from the decoder outputs.
  • Chips =(W/w)(B/b)= (W/w)(B/b); chip range [i w,(i+1) w−1][i\,w, (i+1)\,w - 1].
  • Partial decoding: 2d2^d aliases. Memory-mapped I/O shares the address space.
  • Low-order interleaving: bank =a mod m= a \bmod m.

References

  • ·Hamacher, Vranesic, Zaky, Computer Organization, 5th ed., Chapter 8 The Memory System (memory chips, memory system considerations, interleaving)
  • ·Morris Mano, Computer System Architecture, 3rd ed., Chapter 12 Memory Organization (memory address map, memory connection to CPU)
  • ·Hennessy and Patterson, Computer Organization and Design, Chapter 5 and Appendix (memory chips and buses)

Verification

The chip-select decoding, the address ranges, the aliasing of the partially decoded case, and the chip counts are checked for every address of the 64 KB space in scripts/enum-checks/coa_mem.py and by the C program (npm run verify:c); the animation's chip number and in-chip address are re-derived from the address bits in tests/coa-traces.test.ts. The memory chips are idealised (one chip-select input, address and data lines) and real parts add output-enable, write-enable and timing details. Textbook chapter titles are from memory. SECOND PASS (2026-11-02, done by the assistant, not a human check): every Self-check question was solved before the printed answer was read and all agreed; the definitions, worked examples, cheat box and traps were read claim by claim and the numbers re-derived by hand (long C programs were not re-read line by line: they are compiled and compared by npm run verify:c, and their printed outputs were checked against the prose). No defect found. Status raised to self-checked; verified needs a textbook or human check.

last verified: never