Skip to content
Advanced Microprocessor

Memory Mapping, 74LS138 Decoding & I/O Schemes

64 KB address space, absolute vs partial decoding, foldback memory, and Memory-Mapped I/O vs I/O-Mapped I/O comparison.

Knova editors11 min readQuick checkSources

Memory Mapping and Interfacing in 8085

The 8085 microprocessor features a 16-bit address bus (A15−A0A_{15}-A_0). Because each address bit can take the value of 00 or 11, the total number of unique byte addresses generated is:

Naddresses=216=65,536 locations=64 Kilobytes (KB)N_{\text{addresses}} = 2^{16} = 65,536\text{ locations} = 64\text{ Kilobytes (KB)}

Every unique address points to an 8-bit (1-byte) storage register in memory or an I/O device.

Memory Chip Capacity and Line Requirements

Semiconductor memory chips are organized as an array of words, where each word is 8 bits (1 byte) wide. To select any individual word inside a chip of size MM bytes, the chip requires kk address pins, where:

M=2k  ⟹  k=log⁡2(M)M = 2^k \implies k = \log_2(M)
  • A 2 KB2\text{ KB} EPROM (e.g., Intel 2716) contains 20482048 bytes. It requires k=log⁡2(2048)=11k = \log_2(2048) = 11 address lines (A0−A10A_0-A_{10}).
  • An 8 KB8\text{ KB} SRAM (e.g., Intel 6264) contains 81928192 bytes. It requires k=log⁡2(8192)=13k = \log_2(8192) = 13 address lines (A0−A12A_0-A_{12}).

When interfacing a 2 KB2\text{ KB} chip to the 8085's 16 address lines, the lower 11 lines (A0−A10A_0-A_{10}) connect directly to the memory chip to select internal cells. The remaining higher-order lines (A11−A15A_{11}-A_{15}) connect to decoding logic to generate the active-low Chip Select (CS‾\overline{CS}) strobe.

Address Decoding Schemes

Two primary decoding techniques are used in microprocessor systems:

  1. Absolute (Full) Decoding: All unused high-order address lines are decoded using logic gates or a decoder IC (such as the 74LS138 3-to-8 decoder). Each memory location has one, and only one, unique address. No shadow or foldback addresses exist.
  2. Partial (Linear) Decoding: Only a subset of higher-order address lines are decoded, or individual address lines are connected directly to chip select inputs. While this saves decoder hardware in small systems, it produces shadow addresses (foldback memory), where the same physical memory cell appears at multiple logical addresses.

Address Decoding with the 74LS138 Decoder

The 74LS138 is a 3-line-to-8-line active-low decoder. It features three enable inputs (G1G_1 active-high, G2A‾\overline{G_{2A}} and G2B‾\overline{G_{2B}} active-low) and three select inputs (A,B,CA, B, C):

  • Inputs A,B,CA, B, C are tied to address lines A11,A12,A13A_{11}, A_{12}, A_{13}.
  • Enable G2A‾\overline{G_{2A}} and G2B‾\overline{G_{2B}} connect to A14A_{14} and A15A_{15} through invert/NOR gating.
  • Output lines Y0‾\overline{Y_0} through Y7‾\overline{Y_7} go low one at a time to drive the CS‾\overline{CS} pins of up to eight 2 KB2\text{ KB} memory blocks:
Fig 3.1: Complete Memory Interfacing Scheme using 74LS138 3-to-8 Line Decoder
Fig 3.1: Complete Memory Interfacing Scheme using 74LS138 3-to-8 Line Decoder
Decoder OutputBinary Range (A15−A0)\text{Binary Range } (A_{15}-A_0)Hexadecimal Address Range
Y0‾\overline{Y_0}0000 0000 0000 0000 to 0000 0111 1111 11110000\,0000\,0000\,0000 \text{ to } 0000\,0111\,1111\,11110000H−07FFH (2 KB EPROM)0000\text{H} - 07\text{FFH } (2\text{ KB EPROM})
Y1‾\overline{Y_1}0000 1000 0000 0000 to 0000 1111 1111 11110000\,1000\,0000\,0000 \text{ to } 0000\,1111\,1111\,11110800H−0FFFH (2 KB RAM)0800\text{H} - 0\text{FFFH } (2\text{ KB RAM})
Y2‾\overline{Y_2}0001 0000 0000 0000 to 0001 0111 1111 11110001\,0000\,0000\,0000 \text{ to } 0001\,0111\,1111\,11111000H−17FFH1000\text{H} - 17\text{FFH}
Y3‾\overline{Y_3}0001 1000 0000 0000 to 0001 1111 1111 11110001\,1000\,0000\,0000 \text{ to } 0001\,1111\,1111\,11111800H−1FFFH1800\text{H} - 1\text{FFFH}
74LS138 3-to-8 Address Decoder

8085 Memory Interfacing & Address Space Mapping

Explore how the 3 highest address lines (A15–A13) partition the 64 KB memory space into eight 8 KB slots with zero address collisions.

Presets:
Address Bus Decoding Logic
16-Bit Address (A15–A0):2500H
Bin: 0010010100000000bDec: 9472
Decoder Inputs (C, B, A)
A15(C)=0, A14(B)=0, A13(A)=1
Binary code: 001 (Index 1)
Chip Offset (A12–A0)
0500H
Offset within selected 8 KB IC
74LS138 Output Lines (/Y0 to /Y7)
/Y0
5V
/Y1
0V
/Y2
5V
/Y3
5V
/Y4
5V
/Y5
5V
/Y6
5V
/Y7
5V
64 Kilobyte System Memory Map
8KB EPROM 2764
Select: /Y0 (CBA=000)
0000H
to 1FFFH
8KB SRAM 6264 (Primary RAM)
Select: /Y1 (CBA=001)
2000H
to 3FFFH
8KB SRAM 6264 (Secondary RAM)
Select: /Y2 (CBA=010)
4000H
to 5FFFH
8KB Peripheral Memory Space
Select: /Y3 (CBA=011)
6000H
to 7FFFH
Active Chip: 8KB SRAM 6264 (Primary RAM)

System stack (SP), variables, lookup tables, and user assembly lab program storage.

Physical Pin /CS = 0V (Active) · Offset = 0500H

Memory-Mapped I/O vs. I/O-Mapped I/O

The 8085 supports two distinct architectures for communicating with peripheral interface devices:

FeatureMemory-Mapped I/OI/O-Mapped I/O (Peripheral-Mapped)
Address Bus Width16-bit address (A15−A0)16\text{-bit address } (A_{15}-A_0)8-bit address (A7−A0 duplicated on A15−A8)8\text{-bit address } (A_7-A_0 \text{ duplicated on } A_{15}-A_8)
Maximum DevicesShared with 64 KB memory space\text{Shared with } 64\text{ KB memory space}28=256 input ports and 256 output ports2^8 = 256\text{ input ports and } 256\text{ output ports}
Control SignalsMEMR‾ and MEMW‾\overline{MEMR} \text{ and } \overline{MEMW}IOR‾ and IOW‾ (qualified by IO/M‾=1)\overline{IOR} \text{ and } \overline{IOW} \text{ (qualified by } IO/\overline{M}=1)
Instructions UsedAny memory instruction: MOV, LDA, STA, ADD M\text{Any memory instruction: } \texttt{MOV, LDA, STA, ADD M}Dedicated instructions only: IN port and OUT port\text{Dedicated instructions only: } \texttt{IN port} \text{ and } \texttt{OUT port}
Data TransferBetween any register and deviceExclusively through Accumulator (A)\text{Exclusively through Accumulator } (A)
Execution CyclesTypically 10 to 13 clock states\text{Typically } 10\text{ to } 13\text{ clock states}Strictly 10 clock states (3 machine cycles)\text{Strictly } 10\text{ clock states } (3 \text{ machine cycles})
Hardware CostMore decoding gates (16 lines)Fewer decoding gates (8 lines)

Design Case Study: Interfacing 1 KB EPROM and 2 KB RAM to 8085

A complete memory subsystem requires interfacing both non-volatile program memory (EPROM) and volatile data memory (SRAM) to the demultiplexed system bus.

1. Specifications and Address Allocation

  • 1 KB EPROM (2708/27162708 / 2716): Memory range allocated: 2000H−23FFH2000\text{H}-23\text{FFH}.
    • Capacity: 1024×8 bits=210 bytes1024 \times 8 \text{ bits} = 2^{10} \text{ bytes}.
    • Address lines required for internal selection: 1010 lines (A9−A0A_9-A_0).
    • Address lines available for chip selection (CS‾\overline{CS}): 66 lines (A15−A10A_{15}-A_{10}).
  • 2 KB RAM (61166116): Memory range allocated: 0000H−07FFH0000\text{H}-07\text{FFH}.
    • Capacity: 2048×8 bits=211 bytes2048 \times 8 \text{ bits} = 2^{11} \text{ bytes}.
    • Address lines required for internal selection: 1111 lines (A10−A0A_{10}-A_0).
    • Address lines available for chip selection (CS‾\overline{CS}): 55 lines (A15−A11A_{15}-A_{11}).

2. Memory Address Map and Decoding Truth Table

DeviceA15A_{15}A14A_{14}A13A_{13}A12A_{12}A11A_{11}A10A_{10}A9A_9A8A_8A7A_7A6A_6A5A_5A4A_4A3A_3A2A_2A1A_1A0A_0
RAM Start (0000H)0000000000000000
RAM End (07FFH)0000011111111111
EPROM Start (2000H)0010000000000000
EPROM End (23FFH)0010001111111111

3. Chip Select Boolean Logic

  • For the 2 KB RAM, active when A15=0,A14=0,A13=0,A12=0,A11=0A_{15}=0, A_{14}=0, A_{13}=0, A_{12}=0, A_{11}=0.
    CS‾RAM=A15+A14+A13+A12+A11\overline{CS}_{\text{RAM}} = A_{15} + A_{14} + A_{13} + A_{12} + A_{11}
  • For the 1 KB EPROM, active when A15=0,A14=0,A13=1,A12=0,A11=0,A10=0A_{15}=0, A_{14}=0, A_{13}=1, A_{12}=0, A_{11}=0, A_{10}=0.
    CS‾EPROM=A15+A14+A13‾+A12+A11+A10\overline{CS}_{\text{EPROM}} = A_{15} + A_{14} + \overline{A_{13}} + A_{12} + A_{11} + A_{10}

4. Bus Demultiplexing and Control Signal Generation

  1. 74LS373 Octal Latch: Inputs 1D−8D1D-8D connect to AD7−AD0AD_7-AD_0. The latch enable (GG) connects to ALE. When ALE is high, AD7−AD0AD_7-AD_0 contains address information; on the falling edge of ALE, lines A7−A0A_7-A_0 are latched for the remainder of the machine cycle.
  2. Control Signal Logic (using 74LS138 or OR gates):
    • MEMR‾=IO/M‾+RD‾\overline{\text{MEMR}} = IO/\overline{M} + \overline{RD} (connected to OE‾\overline{OE} of EPROM and RAM)
    • MEMW‾=IO/M‾+WR‾\overline{\text{MEMW}} = IO/\overline{M} + \overline{WR} (connected to WE‾\overline{WE} of RAM)
    • IOR‾=IO/M‾‾+RD‾\overline{\text{IOR}} = \overline{IO/\overline{M}} + \overline{RD}
    • IOW‾=IO/M‾‾+WR‾\overline{\text{IOW}} = \overline{IO/\overline{M}} + \overline{WR}
Try it
Address Line Calculation: A microprocessor system uses an 8 KB8\text{ KB} SRAM chip mapped starting at address 8000H8000\text{H}. What is its ending hexadecimal address?

Sources

  1. 1.Microprocessor Interfacing Notes · Intel · technical (opens in a new tab)

Was this chapter useful?

Editors read every answer.

Star this chapter

Each star goes once to every reader who improved this chapter.

Finished reading?

Mark it to keep your place in the course.