Memory Interface
Memory Interface
Address decoding is the process of identifying which specific memory chip or I/O device should
respond to a given address sent by the CPU.
When the CPU wants to read from or write to memory or a device, it puts an address on the
address bus. But there might be many devices or memory chips connected. So we need a way
to ensure only the correct one responds — this is the job of address decoding.
How It Works
We use logic gates or decoders to check specific bits of the address. Based on those bits, the
decoder activates an enable signal for just one memory or I/O device.
• Full decoding: All address lines are used to make every address unique.
• Partial decoding: Only some address lines are used, which can save hardware but may
cause conflicts if not designed carefully.
Simple Flow:
Let’s say you want to place the 2716 at address 0x0000 to 0x07FF in your system.
So:
• If all those inputs are 1, the output of the NAND gate will be 0.
• we need CE = 0 to activate the EPROM.
• If there’s no 1 then we need to put the inverter on that specific address line before nand
gate.
.
Step 4: Connect Other Pins
Q: now design an address decoder using NAND gates to enable a 2716 EPROM (2 KB)
placed at the top 2 KB of memory, i.e., address range 0xFF800 to 0xFFFFF.
The 8086 microprocessor has a 20-bit address bus, so address range is:
0x00000 to 0xFFFFF (1 MB total)
Start: 0xFF800
= 1111 1111 1000 0000 0000
A19...A0
End: 0xFFFFF
= 1111 1111 1111 1111 1111
So:
So:
• Connect A19, A18, A17, A16, A15, A14, A13, A12, A11 (9 lines) to a 9-input NAND
gate.
• NAND of all 1s = 0
Now:
Q: now go through the case of placing a 2716 EPROM (2 KB) in the address range:
• This range is 2 KB wide → needs 11 address lines (A0–A10) for internal access in the
2716.
• So we will decode the higher address lines A11–A19 to enable the chip.
Step 2: Write Binary of Start and End Addresses
Start: 0xFF000
= 1111 1111 0000 0000 0000
End: 0xFF7FF
= 1111 1111 0111 1111 111
It takes 3 binary input bits and activates one of 8 outputs, depending on the input combination.
Enable Conditions
• G1 = 1
• G2A = 0
• G2B = 0
How It Works
You can use A13, A14, A15 (or any 3 address lines) as inputs C, B, A.
Each output line (Y0–Y7) can then be connected to the CE (chip enable) pin of a memory or I/O
device.
This way:
For example:
GOAL
Map the EPROMs into the top 64 KB of the 8088's memory space:
COMPONENTS INVOLVED
• 8088 microprocessor: 20-bit address bus (A0–A19), 1MB addressable range.
• 74138 decoder: 3-to-8 active-LOW outputs.
• 2764 EPROMs: 8KB per chip × 8 chips = 64 KB total.
• 64 KB / 8 = 8 blocks.
• Use A13, A14, A15 as inputs (C, B, A) to 74138 for block selection.
OBJECTIVE
You want to map 8 EPROMs (8 KB each, total 64 KB) into the address range:
MEMORY BREAKDOWN
Each EPROM is 8 KB. So split the 64 KB range: 64/8;
DECODING STRATEGY USING 74138
Use 74138 to select 1 of the 8 EPROMs based on address lines A13, A14, A15:
Enable 74138 only when A16–A19 = 0110 (i.e., addresses between 60000H–
6FFFFH):
Q: Let’s now explain how to interface a 74138 decoder with the 8088 microprocessor and 8
× 27128 EPROMs to map into the address space A0000H to BFFFFH, step by step.
GOAL
You want to map 8 × 27128 EPROMs (16 KB each) into the address range:
74138 Decoder
27128 EPROM
→ Connect:
Use logic:
• G1 = HIGH
• G2A̅ = A18 (must be LOW → A18 = 0)
• G2B̅ = NOT A19 (must be LOW → A19 = 1)
CONNECTION SUMMARY
Signal Connected To
A0–A13 (8088) A0–A13 of all EPROMs
A14–A16 74138 inputs (A, B, C)
A17–A19 Used to generate enable logic for 74138
74138 Y0–Y7 Connect to CE̅ of each EPROM
OE̅ (EPROMs) Connect to RD̅ of 8088
Data bus D0–D7 Shared between EPROMs and 8088
74139 DECODER (DUAL 2 T0 4 LINE DECODER)
The 74139 is an integrated circuit (IC) that contains two independent 2-to-4 line decoders or
demultiplexers. It is widely used in digital systems to decode binary inputs into one of several
outputs. Here's a breakdown to help you understand it clearly:
What is a Decoder?
A decoder is a digital circuit that converts binary input into a single active output line. In a 2-to-
4 line decoder, you have:
This range covers 64 KB of memory, just like your previous example but at a different segment.
So the top nibble (A19 to A16) is fixed at 1101 (that is D in hex) for the entire 64 KB block.
Perfect — your total address range (256 KB) matches the total size of all 8 EPROMs combined.
Each block = 32 KB = 2^15 bytes, so the lower 15 address bits (A0–A14) will be used inside
each EPROM.
• BHE (Bus High Enable): Selects the high bank (odd addresses)
• A0 (Address bit 0): Selects the low bank (even addresses)
BHE A0 Meaning
0 0 Both banks enabled (16-bit access)
0 1 High bank enabled only (odd address, upper byte)
1 0 Low bank enabled only (even address, lower byte)
1 1 No bank enabled (no operation)
• The low bank RAM stores all even addresses (like 00000h, 00002h, 00004h, ...)
• The high bank RAM stores all odd addresses (like 00001h, 00003h, 00005h, ...)
This means:
PA1=0000h∗10h+0000h=00000h
PA2=0000h∗10h+0001h=00001h
A19 A18 A17 A16 A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
• 00001h in binary:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
This is the normal and most efficient case: 16-bit word aligned at an even address, where low
and high bytes lie in two adjacent physical memory locations split between low and high banks.
• Here, DS = 0000h
• We want to load the 16-bit word starting at offset 0001h.
PA1=0000h∗10h+0001h=
PA2=0000h∗10h+0002h=00002
Binary Address Representation:
CopyEdit
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
• 00002h in binary:
CopyEdit
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
• Lower byte at odd address 00001h, so A0=1 → High bank RAM enabled.
• Higher byte at even address 00002h, so A0=0 → Low bank RAM enabled.
• Here the 16-bit word is split across the boundary of the two banks in reverse order:
o AL (lower byte) from high bank (odd address)
o AH (higher byte) from low bank (even address)
Important Notes:
• Accessing 16-bit data at an odd address is not aligned and may cause performance
penalties.
• The 8086 must perform two memory accesses (or bus cycles):
o One to read the byte from high bank at 00001h
o One to read the byte from low bank at 00002h
• This is because the 16-bit word spans two different memory banks, and the address
crosses the boundary.
Summary Table
Lower Byte Higher Byte
Case Bank Bank Comment
Address Address
16-bit access at Low High
00000h 00001h Aligned, efficient
even addr bank bank
16-bit access at High Low Unaligned, crosses bank
00001h 00002h
odd addr bank bank boundary
Bank Selection in 8086 Memory Interface
The 8086 CPU has a 16-bit data bus, but it is internally split into two 8-bit banks:
When the CPU reads or writes data, it uses signals to select which bank(s) to activate:
• BHE (Bus High Enable): Controls the high bank (odd bytes)
• A0 (Address bit 0): Controls the low bank (even bytes)
Q: memory interface design where the 8086 microprocessor is connected to two RAM chips
(62256) using the Separate Bank Decoders method.
1. Basic Setup
• The 8086 has a 16-bit data bus (D0-D15) but needs to work with 8-bit RAM
chips (62256).
• Solution: Use two 62256 RAM chips (32KB each):
How It Works
1. Address Lines:
How It Works
1. Address Lines:
o LWR (Low Write) = A0' AND WR → Writes to low bank (even addresses).
o HWR (High Write) = BHE' AND WR → Writes to high bank (odd
addresses).
o OE (Output Enable) → Connected to RD (Read).
3. No Decoder Needed: