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 ( lines address locations). The data bus carries data in both directions ( lines give -bit words). The control bus carries signals such as read, write and a clock or ready line.
Memory chip. A chip of words of bits has address lines , 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 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 chips make .
- 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 chips make .
- Number of chips for a memory of words bits from chips of : (the depth factor times the width factor). Example: from chips needs 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 space (16 address lines) built from four chips, go to the chips and go to a 2-to-4 decoder: chip 0 covers to , chip 1 to , chip 2 to , chip 3 to .
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), of them if 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 ( for 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 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 typedWorking
chip select = A15 A14 (2-to-4 decoder) chip address lines = A13 .. A0
Value, format and bits (changed bits in amber)
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.
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 chipReading it. Every one of the 65536 addresses selects exactly one chip (16384 addresses each). Chip 2 covers to . With ignored, every address has an alias exactly 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
EasyA memory is built from chips. Depth: ; width: . Chips: . Each chip has address lines. The memory has 20 address lines (for words), so the 2 highest lines drive a 2-to-4 decoder. A memory from chips needs 4 chips, 10 address lines per chip and 2 lines for the decoder.
EX 3Mixed RAM and ROM in an address map
MediumA 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 . The ROM uses 11 address lines () and occupies to . The RAM occupies to (4096 addresses). The device occupies to . Each needs its own chip select: the ROM when ; the RAM needs a range that does not align to a power of two ( to straddles ), which shows why designers usually align each chip to a multiple of its own size (the RAM would better start at ). An address map with aligned ranges needs only a simple decoder on the top bits.
EX 4Which address lines go where
MediumFor a space with chips: each chip has 13 address lines () connected to every chip; the remaining 3 lines go to a 3-to-8 decoder with 8 outputs for the 8 chips. Chip 5 () covers to . If only 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 levelA system uses a 2-to-4 decoder on for four 16 KB chips but the designer leaves unconnected (the decoder sees and a constant). Then two chips are visible, each at two addresses: location and location reach the same cell. The number of aliases of each location is (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 levelA memory has 4 banks, low-order interleaved: address is in bank . The 8 consecutive words 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
- address lines: locations. A chip has address lines.
- Wider: same address, different data bits. Deeper: same low lines, separate chip selects from a decoder on the high lines.
- Chips . Decoder inputs .
- Chip of size covers to (aligned).
- Full decoding: one address per location. Partial: aliases when high lines are ignored.
- Memory-mapped I/O uses memory addresses; isolated I/O has its own space and instructions.
- Low-order interleaving: bank .
Traps and GATE patterns
Connections
Builds on
Across subjects
Within this subject
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
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)
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
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
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.
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
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 .
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 ____.
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 chips make a memory, and how many address lines go to the decoder?
Show answerHide
Depth , width : 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 chips cover in a 64 KB space?
Show answerHide
to .
Question 3
Two high-order address lines are ignored by the decoder. How many addresses select each memory location?
Show answerHide
.
Question 4
With 8-way low-order interleaving, which bank holds address 100?
Show answerHide
: 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 ; chip range .
- Partial decoding: aliases. Memory-mapped I/O shares the address space.
- Low-order interleaving: bank .
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
My notes (saved in this browser)