Lecture9 Memory Organization
Lecture9 Memory Organization
Topics
8086 Memory Organization
8086 Address Decoding Methods
2
Memory Types
ROM (Read Only Memory) : Contents are not erased when power is off.
Used to store programs such as BIOS permanently that does not change.
RAM (Random Access Memory) : Contents are erased when power is off.
Used to store programs and data temporarily.
Smaller,
Faster,
Expensive
(CPU/Memory)
4
Memory Chips
Each row location in a memory chip is called a word.
Each word is composed of M bits (Data bus width).
CPU can access memory at the word level, not at the bit level.
Number of bits in a word can be different for different microprocessors.
Memory is a matrix of NxM bits
N: number of row locations (words)
M: number of columns (bits)
●
N is size of a memory, k is Address bus width. byte
N = 2k
log2(N) = k
6
8086 Memory Organization
●
In 8086-based systems, 8-bit memory chips are used.
●
These chips have 8 bits (1 byte) in each memory location.
●
8086 CPU is a 16-bit microprocessor, it can transfer 16-bit data.
●
In addition to byte (8-bit), word (16-bit) has to be stored in the memory.
●
To allow both byte-level and word-level transfer, the entire memory is
divided into two memory banks: High bank and Low bank.
●
High bank is selected only when A0 line in Address Bus is zero.
●
Low bank is selected only when BHE signal in Control Bus is zero.
00000 h
00001 h
00002 h
Memory 00003 h
8086 (1 MB) 00004 h
CPU 00005 h
:
: 1 MB
:
:
D0 – D15 :
Data Bus lines FFFFB h
(16-bit)
FFFFC h
FFFFD h
FFFFE h
FFFFF h
9
Addresses (20 bit)
Odd Even
Memory Memory
Bank Bank
8086 (512 KB) (512 KB)
CPU
(8-bit) (8-bit)
D8 – D15
D0 – D7
10
8086 Physical Memory Organization
(High and Low Banks)
Data bus : D7–D0 Data bus : D15–D8
8 bits 8 bits
11
BHE A0
(Bus High (First line of Selected Memory Bank
Enable) address bus)
12
CPU Signals for Bank Selection
●
In High bank, the high data bits D15-D8 are selected.)
(Also called as Odd bank, which means addresses are odd : 1, 3, 5, 7, etc.)
●
In Low bank, the low data bits D7-D0 are selected.)
(Also called as Even bank, which means addresses are even : 0, 2, 4, 6, etc.)
●
Each bank is = 512 KB, Total memory is = 512*2 = 1 MB
●
Selection of a memory bank is determined by its CS (Chip Select) input.
13
A0 O0
A1 O1
Address Data
Connections A2 O2 Input / Output
RAM O3
Connections
A3
An On
READ
WRITE
CS
CS : Chip Select
Also called as CE (Chip Enable)
14
General Pin Diagram of ROM chips
A0 O0
A1 O1
Address Data Output
Connections A2 O2 Connections
ROM O3
A3
An On
OE : Output Enable OE
Also called as RD (Read) CS
CS : Chip Select
Also called as CE (Chip Enable)
15
Connections of
ROM and RAM chips
Address connections: All memory devices have address inputs that select a memory
location within the memory device.
●
Address inputs are labeled from A0 to An.
●
Data connections: All memory devices have a set of data outputs or input/outputs.
●
ROM data connections are one-directional.
●
RAM data connections are bi-directional.
Selection connections: Each memory device has an input that selects or enables the
memory device.
●
This kind of input is most often called a Chip Select (CS), or Chip Enable (CE) input.
●
RAM memory generally has at least one CS input.
●
ROM memory has at least one CE input.
●
If the CS , CE input is active, the memory device perform the read or write operation.
●
If it is inactive, the memory device cannot perform read or write operation.
●
If more than one CS connection is present, all most be active to perform read or write.
16
Connections of
ROM and RAM chips
Control connections:
●
ROM usually has only one control input.
●
The control signal most often found on the ROM is the Output Enable (OE),
or the Gate (G) .
●
It allows data to flow out of the output data pins of the ROM.
●
RAM memory device has either one or two control inputs.
●
If there is one control input it is often called R / W .
●
This pin selects a Read operation or a Write operation,
only if the device is selected by the selection input (CS).
17
19
Number of Number of
RAM Bits Maximum address
Address Locations
Chip Name Capacity (Hexadecimal)
Lines and Bits Width
20
Example2 : Memory Chip 6264
(8K x 8 Bit Static RAM)
Pin Assignment
21
Memory Matrix
Row
Decoder 256 Rows
32 Columns
22
Example3 : Static RAM
(256K x 16 Bit)
Pin Configurations
71V416S
CMOS
SRAM
(256X16)
23
24
Example4 : Generic Memory Chip
(2M x 16 SRAM)
●
To initiate a read or write access, the Chip select signal must be made active.
●
For read operation, the Output enable signal must also be activated, that controls
whether or not the data selected by the address is actually driven on the pins.
●
The Output enable is useful for connecting multiple memories to a single-output bus and
using Output enable to determine which memory drives the bus.
●
For write operation, the followings must be supplied:
Data to be written, Address, Control signals to cause the write to occur.
●
When both Write enable and Chip select are true, the data on data input lines is written
into the location cell specified by the address.
25
Topics
8086 Memory Organization
8086 Address Decoding Methods
26
Memory Addressing
Each location in memory has an address.
CPU first identifies the location’s address and then passes the address
on address bus.
Data are transferred between memory and CPU along data bus.
Data Bus
CPU Memory
Address Bus
27
0 0000111
Address Bus 1 0001000
0 0010001
Internal
1 0010011
CPU Decoder
(for row 1 1110000
selection)
0 0001111
1 1000011
1 0011001
:
Memory chip :
28
Memory Chip Selection
Each memory chip has a Chip Select (CS) input Data Bus
(EN=Enable).
The chip will only work if an active signal
(high or low) is applied on CS.
Address Bus
To allow use of multiple memory chips, Memory
some of address lines are used for the Chip
purpose of chip selection.
CS RD WR
29
Using Address Decoder for Memory Chip Selection
The following is a simple memory system made up of 4 memory chips.
Each memory chip has 4x2 bits.
An external Address Decoder (2 to 4) is used for chip selections.
The Decoder outputs are connected to chip selects (CS) of memory chips.
RD
WR
D0 Data
D1
lines
A0 A0 A0 A0
A1 A1 A1 A1
CS CS CS CS
A0
A1
Address
lines External
A2
Address
Decoder
A3
(2 : 4)
31
Decoder
Decoder is a circuit (usually as a chip) that converts binary information from
n-coded inputs to maximum of 2n outputs.
It is also called as Demultiplexer.
Only one output is 1, others are 0.
Address Decoders are used for location (row) selection within a memory
chip. (Internal Decoder)
They are also used to for memory chip selection among multiple memory
chips. (External Decoder)
32
Example : 3-to-8 Decoder
There are 3 input lines.
There are 8 output lines. ( 23 )
Depending on inputs, only one output line will be 1, other
output lines will be 0.
L7
L6
A2 L5 Outputs
Inputs
(Address lines 3 to 8 L4 (To memory chip selections:
A1 Decoder L3 Enable signals)
from CPU)
A0 L2
L1
L0
Used as
External
Decoder
33
INPUTS OUTPUTS
A2 A1 A0 L7 L6 L5 L4 L3 L2 L1 L0
0 0 0 0 0 0 0 0 0 0 1
0 0 1 0 0 0 0 0 0 1 0
0 1 0 0 0 0 0 0 1 0 0
0 1 1 0 0 0 0 1 0 0 0
1 0 0 0 0 0 1 0 0 0 0
1 0 1 0 0 1 0 0 0 0 0
1 1 0 0 1 0 0 0 0 0 0
1 1 1 1 0 0 0 0 0 0 0
34
Example: 2-to-4 Decoder
Block A0 D0
Diagram
2:4 D1
A1 Decoder
D2
D3
Decoder Enable
Inputs Outputs
A1 A0 D3 D2 D1 D0
Truth Table 0 0 0 0 0 1
0 1 0 0 1 0
1 0 0 1 0 0
1 1 1 0 0 0
35
Decoder
used for
Memory Chip
Selections
36
Address Decoder 74138 chip
●
In the Example above, suppose DM74LS138 Address Decoder ch p (3-to-8) s used
for memory ch p select ons.
●
Address nputs A19L , A18L , A17L (L suff x means Latched) of the Decoder are decoded to
produce 8 ndependent Ch p Enable outputs CE0 through CE7.
DM 74 LS 138
DM 74 LS 138 Address Address
Decoder (3-to-8)
Decoder
(3-to-8)
37
PIN NAMES
74 LS 138 Address A0, A1, A2 : Address Inputs
Decoder
E1, E2 : Enable (Active LOW) Inputs
E3 : Enable (Active HIGH) Input
(3-to-8) O0–O7 : Active LOW Outputs
38
Logic Diagram of 74138 Decoder
Select Inputs Enable Inputs
39
Truth Table of
74138 Decoder
40
Address Decoding Methods
for Memory Chip Selections
●
In a 8086 based system, usually at least two memory chips are used
(8-bit High bank chip, and 8-bit Low bank chip).
●
High and Low bank chips should be identical.
●
Alternative : Instead of using two identical 8-bit memory chips,
it is also possible to use one 16-bit memory chip.
●
Some 16-bit memory chips have two internal banks : High Bank and Low Bank.
They support BHE (Bank High Enable) , and BLE (Bank Low Enable) selection inputs.
●
If multiple memory chips (at least two chips) are used, then Address Decoding is
necessary in order to distinguish and select a memory chip from others,
as part of the addressing process.
●
Before Address Decoding, we assume that the Latched address bus,
BHE signal, and Demultiplexed Data bus are readily available for decoder interfacing.
●
There 3 basic decoding methods for memory chip, and I/O chip selection.
1. Absolute Decoding (by using Logic gates)
2. Partial Decoding (by using Logic gates)
3. Block Decoding (by using Address Decoder chip)
41
42
Example: Absolute Decoding
●
A1-A13 address lines are used for memory locations within each bank independently.
●
A0 line is used for Even Bank selection.
●
BHE signal is used for Odd Bank selection.
●
All remaining address lines (A14-A19) are called as Spare Lines.
●
Spare Lines are used to generate a unique (absolute) chip select signal for memory chips.
●
Odd bank is connected to D8-D15 data lines, Even bank is connected to D0-D7 data lines.
High/Odd Low/Even
Bank Bank
D8-D15 D0-D7
External
address line Internal External Internal
numbers address line address line address line
numbers numbers numbers
Spare
Address
Lines
43
44
Example: Partial Decoding
●
A1-A13 address lines are used for memory locations within each bank.
●
A0 address line is used for Even Bank selection.
●
BHE signal is used for Odd Bank selection.
●
A19 address line is used for CS (Chip Select) inputs of both memory chips.
● When A19 is low, both memory chips are selected, otherwise both of them are disabled.
●
The status of A14 thru A18 does not affect the chip selection logic.
(But they cause shadow addresses.)
● Advantage of this method : It reduces cost of decoding circuit.
●
Disadvantage : It causes multiple addresses (shadow addresses).
High/Odd Low/Even
Bank Bank
External data line numbers
External
address line Internal Address External Internal Address
numbers & Data pin numbers address line & Data pin numbers
numbers
High bank
Read,Write Low bank
Read,Write
45
Memory Addresses
A19 A18 A17 A16 A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
Chip (Hexadecimal)
RAM1 Smallest 00000 0 x x x x x 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8Kx8
(Even
bank)
Biggest 03FFE 0 x x x x x 1 1 1 1 1 1 1 1 1 1 1 1 1 0
RAM2 Smallest 00001 0 x x x x x 0 0 0 0 0 0 0 0 0 0 0 0 0 1
8Kx8
(Odd
bank)
Biggest 03FFF 0 x x x x x 1 1 1 1 1 1 1 1 1 1 1 1 1 1
diagram 00000
00001
00002
●
Total= 16 K Byte RAM
●
Two 16Kx8 RAM chips used. 00003
Even and Odd addresses are
00004
drawn as mixed.
00005
00006
03FFE
03FFF
47
00000 00001
00002 00003
00004 00005
00006 00007
8 K Byte 8 K Byte
RAM1 RAM2
8Kx8 8Kx8
03FFE 03FFF
48
3. Block Decoding method
●
In a microcomputer system, the memory array is often consists of
several blocks of memory chips.
●
Each block of memory requires Decoding circuit.
●
To avoid separate decoding logic circuits for each memory block, a special
Address Decoder chip can be used to generate chip select signal for each
memory block.
●
In the following example, total of 32 KB memory system is designed.
●
Two EEPROM chips are used (2764 chips).
●
Each EPROM is 8Kx8 bit
●
Total of EPROM block = 16 KB
●
Two RAM chips are used (6264 chips).
●
Each RAM is 8Kx8 bit
●
Total of RAM block = 16 KB
●
Calculation of number of address lines needed for location selection:
log2(8K) = log2 (213) = 13 lines.
49
74138
Decoder
(3-to-8)
50
General Procedure of
Memory Interfacing with 8086
1) Connect the Address latches and Data Buffers to CPU Address/Data bus and obtain the
demultiplexed (separated) Address bus lines and buffered Data bus lines.
2) Arrange the available memory chips so as to obtain 16-bit data bus width.
5) Connect available memory address lines (up to 20 bit) of memory chips with the
demultiplexed address lines (20 bit).
6) Connect the RD and WR inputs of memory chips to the corresponding processor control
signals.
7) Connect the 16-bit data bus of memory bank with the buffered Data bus lines (16 bit).
8) The remaining address lines of the CPU, BHE and A0 are used for Decoding the required
chip select signals for the odd and even memory banks.
9) The CS (Chip Select) input of memory chips is derived from the output of the Decoding
circuit (either Logic gates, or a Decoder chip.).
51
SOLUTION:
●
In a 8086 CPU based system, the address FFFF0 must lie in the EPROM always.
Because 8086 initializes its Instruction Pointer (IP) register with the value from
the reset address FFFF0.
●
The address of RAM may be selected anywhere in the 1MB address space of 8086 CPU.
●
In general, the RAM address map should be organized as continuous without any gaps.
52
Solution
●
Each memory chip (EPROMs and RAMs) are 4Kx8.
●
Calculation of number of address lines needed for location selection within a memory chip:
log2(4K) = log2(212) = 12 address lines.
●
BHE signal is connected to the A0 pin of Decoder.
●
A0 address line is connected to the A1 pin of Decoder.
●
A13 address line is connected to the A2 pin of Decoder.
●
Address lines A1 - A12 are used for location selection within memory chips.
●
Address lines A14 - A19 (Spare lines) are used as inputs of AND gate
(7430 logic AND chip).
●
The output of the AND gate is used as inputs of E1, E2, E3 pins
(Decoder enable pins) of Decoder.
●
Outputs of the Decoder are used with AND gates, so that the memory chip selection
signals are obtained.
CS1 : Chip select of ROM2 (Odd bank)
CS2 : Chip select of ROM1 (Even bank)
CS3 : Chip select of RAM2 (Odd bank)
CS4 : Chip select of RAM1 (Even bank)
●
Total of four 4K x 8 memory chips are used.
●
Two 4Kx8 RAM chips, and two 4Kx8 ROM chips
are arranged in parallel to obtain 16-bit data bus width. 53
Solution
ROM2 ROM1
High bank Low bank
RAM2 RAM1
High bank Low bank
A14 – A19
NAND gate
(Spare address lines)
(Determines the
smallest beginning
address in memory)
54
Solution
55
Solution
Memory Map Table
Memory Address
A19 A18 A17 A16 A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
Block (Hexadecimal)
RAM1 Smallest FC000 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4Kx8
(Even
Bank) Biggest FDFFE 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0
RAM1 RAM2
4Kx8 4Kx8
(Even Bank) (Odd Bank)
FDFFE FDFFF
FE000 FE001
EEPROM1 EEPROM2
4Kx8 4Kx8
(Even Bank) (Odd Bank)
FFFFE FFFFF
57
Part1: Draw a block diagram with 8086 CPU, Address Latches, Data Transceiver Buffers,
Control Signals Decoder, Address Bus, Data Bus, and Control signal connections.
Part2: Draw a separate block diagram with Address Decoder, Memory chips, and their
connections.
●
Note that two separate Decoders will be used for different purposes.
- In Part1, a Decoder will be used as Control Signals Decoder.
- In Part2, another Decoder will be used as Address Decoder.
●
Also write the Memory Map table, showing the smallest addresses and
biggest addresses for each memory chip (high and low banks).
58
Solution
Memory calculations:
EPROMs:
Total Required Memory = 128 KB
Available Memory chips= 32Kx8
Number of chip required = 128 / 32 = 4 chips
Number of Address Lines required = 15 lines (A15 – A1)
log2 (32K) = log2 (215) = 15 lines
RAMs:
Total Required Memory = 64 KB
Available Memory chips = 16Kx8
Number of chip required = 64 / 16 = 4 chips
Number of Address Lines required = 14 lines (A14 – A1)
log2 (16K) = log2 (214) = 14 lines
59
Solution
Address
Part1: Latches (3)
Data
Buffers (2)
8086
CPU
Decoder
for Control
Signals
60
Odd Even
Solution
Banks Banks
Part2:
4 RAM
chips
Address
8086 Latches
CPU
Address
Decoder
4 EPROM
chips
Solution
RAM Map Table LB: Low Bank, HB: High Bank
62
Example3 : Address Decoding of 8 EPROM chips
●
Each output of the 74LS138 address decoder is attached to an 2764 EPROM ( 8K X 8 ).
●
Number of EPROMs are 8.
●
The total memory of 8 EPROMs are 64 KB.
●
A13 through A15 select a 2764 EPROM chip.
●
A16 through A19 enable the 74138 decoder chip.
●
Physical address space is F0000h – FFFFFh.
Decoder
63