Memory Interfacing
Memory Interfacing
INTERFACING OF
8085
1
Introduction to 8085
3
Types of Semiconductor Memory
Devices
Read Only Memory (ROM) Random Access Memory (RAM)
A memory device that maintains its data • A memory device that can be
permanently (or until the device is read and written.
reprogrammed). – Volatile: It looses its data when
◦ Non-volatile: It maintains its data the power supply is switched-off
even without power supply. – When the supply is switched-on it
Used to store contains random data
◦ Programs such as the BIOS. • Used to store
◦ Data such as look tables – User programs that are loaded
e.g. the bit pattern of the from a secondary memory (disk)
characters in a dot matrix printer. – Temporary data used by programs
A ROM device can be such as variables and arrays.
1. Masked ROM (Programmed by the • A RAM device can be
manufacturer) 1. Static
2. Programmable ROM (can be 2. dynamic
program-erased-reprogrammed
many times
4
RAM Cells
Static RAM (SRAM): Dynamic RAM (DRAM):
The basic element of a static RAM cell is the D- • DRAM stores data in the form of
Latch. electric charges in capacitors.
Data remains stored in the cell until it is • Charges leak out, thus need to refresh
intentionally modified.
data every few ms.
SRAM is fast (Access time: 1ns).
• DRAM is slow (Access time: 60ns).
SRAM needs more space on the semiconductor
chip than DRAM. • DRAM needs less space on the
◦ SRAM more expensive than DRAM semiconductor chip than SRAM.
◦ SRAM needs more space than DRAM – DRAM less expensive than SRAM
SRAM consumes power only when accessed. – DRAM needs less space than SRAM
SRAM is used as a Cache • DRAM needs to be refreshed
• DRAM is used as the main memory
Write En
5
RAM Cell DRAM Cell
Basic Concepts
• A memory device can be viewed as a
single column table. Memory Address Memory
• Table index (row number) refers to the Binary Hex Contents
address of the memory. 00-0000-0000 000 10011001
• Table entries refer to the memory 00-0000-0001 001 00111000
contents or data. 00-0000-0010 002 11001001
• Each table entry is referred as a 00-0000-0011 003 00111011
memory location or as a word.
• Both the memory address and the
memory contents are binary numbers,
expressed in most cases in Hex format. 11-1111-1100 3FC 01101000
• The size of a memory device is specified 11-1111-1101 3FD 10111001
as the number of memory locations X 11-1111-1110 3FE 00110100
width or word size (in bits). 11-1111-1111 3FF 00011000
• For example a 1K X 8 memory device
has 1024 memory locations, with a 1024 X 8 (or 1KX8) Memory
width of 8 bits.
6
Address Lines
A memory device or memory chip must have three
Y00 Location 000
types of lines or connections: Address, Data, and Y01 Location 001
Control.
Y02 Location 002
Address Lines: The input lines that select a A00 Y03 Location 003
memory location within the memory device. A01
Decoders are used, inside the memory chip, to
select a specific location An-2
The number of address pins on a memory chip An-1 YFC Location 0FC
specifies the number of memory locations. YFD Location 0FD
If a memory chip has 13 address pins YFE Location 0FE
YFF Location 0FF
(A0..A12), then it has:
213 = 23 X 210 = 8K locations.
If a memory chip has 4K locations, then it
should have N pins:
2N = 4K = 22 X 210 = 212 N=12
address pins (A0..A11)
7
Data Lines
Data Connections: All memory devices have a set of data output pins
(for ROM devices), or input/output pins (for RAM devices).
Most RAM chips have common bi-directional I/O connections.
Most memory devices have 1, 8 or 16 data lines.
8
Control Lines
Enable Connections:
All memory devices have at least one Chip Select (CS) or Chip
Enable (CE) input, used to select or enable the memory device.
If a device is not selected or enabled then no data can be read
from, or written into it.
The CS or CE input is usually controlled by the microprocessor
through the higher address lines via an address decoding circuit.
Control Connections:
RAM chips have two control input signals that specify the type of
memory operation: the Read (RD) and the Write (WR) signals.
Some RAM chips have a common Read/ Write (R/W) signal.
ROM chips can perform only memory read operations, thus there is
no need for a Write (WR) signal.
In most real ROM devices the Read signal is called the Output
Enable (OE) signal.
9
Requirement and structure of memory
10
Interfacing Memory
• Accessing memory can be summarized into the following three steps:
• Select the chip.
• Identify the memory register.
• Enable the appropriate buffer.
11
Address decoding
12
Memory Map
Maninder Kaur 13
Design a minimum system to interface the following specification.
1.32K of RAM using 2x16kb RAM Ic
2.32kB of RAM using 2x16kb ROM ic
Maninder Kaur 14
Memory Read operation
15
Memory Read operation
16
Memory Write operation
The following sequence of event occurs when
microprocessor writes into a particular memory location.
The memory device will store the data stored into MBR
into the location whose address is in MAR.
17
18
19
TIMING DIAGRAM
Timing Diagram is a graphical
representation.
It represents the execution time taken by
T-states.
CONTROL SIGNALS
INSTRUCTION CYCLE
The time required to execute an
instruction is called instruction cycle.
MACHINE CYCLE
The time required to access the memory
or input/output devices is called machine
cycle.
T-STATE
The machine cycle and instruction cycle
takes multiple clock periods.
A portion of an operation carried out in
2.Single Line Signal:-The status of single line will be either LOW or HIGH. But the
change from one state to another state is not possible in zero time.
Tri-
change Valid state Valid
27
Representation of signals in
Timing Diagram
4. Single line and single effect single:- because of single line the other signal also
changes. A changes cause change in other signal it is shown with an arrow.
5. Multiple line and single effect single:- if changes in multiple lines cause change
in other signal it is shown with an arrow.
28
Op code fetching Machine cycle
29
Op-code fetching Machine
cycle
In T1 state, the 8085 places the contents of program counter on the address bus.
The high-order byte of the PC is placed on the A8-A15 lines. The low-order byte of
the PC is placed on the AD0 – AD7 lines which stays on only during T1.
Microprocessor activates ALE (Address Latch Enable) which is used to latch the
low-order byte of the address in external latch before it disappears.
In T1, 8085 also sends status signals IO/M, S1, and S0. IO/M specifies whether it is
a memory or I/O operation,
In T2, low-order address disappears from the AD0 – AD7 lines. (However Ao –
A7remain available as they were latched during T1). In T2, 8085 sends RD signal
low to enable the addressed memory location. The memory device then places the
contents of addressed memory location on the data bus (ADo – AD7).
During T3, 8085 loads the data from the data bus in its Instruction Register and
raises RD to high which disables the memory device.
In T4, microprocessor decodes the opcode, and on the basis of the instruction
received, it decides whether to enter state T5 or to enter state T1 of the next
machine cycle One byte instructions those operate on eight bit data (8 bit
operand) are executed in T4.
30
Memory read Machine cycle
31
Memory read Machine cycle
33
Memory Write Machine cycle
In T1 state, the 8085 places the address on the address lines from stack pointer or
general purpose register pair and activates ALE signal in order to latch low-order
byte of address. During T1, 8085 sends status signals : IO/M = 0, S1 = 0 and S0 = 1
for memory write machine cycle.
In T2, 8085 places data on the data bus and sends WR signal low for writing into
the addressed memory location.
During T3, WR signal goes high, which disables the memory device and
terminates the write operation.
34
Interfacing I/O devices with
8085
I/O I/O
Interface Devices
System Bus
8085
Memory Memory
Interface Devices
Classification of I/O devices
Maninder Kaur 44
Techniques for I/O
Interfacing
• Memory-mapped I/O
• Peripheral-mapped I/O
Memory-mapped I/O
8085 uses its 16-bit address bus to identify a
memory location
Memory address space: 0000H to FFFFH
8085 needs to identify I/O devices also
I/O devices can be interfaced using addresses from
memory space
8085 treats such an I/O device as a memory
location
This is called Memory-mapped I/O
Peripheral-mapped I/O
• OUT Instruction
• Outputs the contents of accumulator to an
output device
• It is a 2-byte instruction
• Format: OUT 8-bit port address
• Example: OUT 02H
----------Example
Program----------
• WAP to read a number from input port (port address 01H)
and display it on ASCII display connected to output port
(port address 02H)
IN 01H ;reads data value 03H (example)into
;accumulator, A = 03H
MVI B, 30H ;loads register B with 30H
ADD B ;A = 33H, ASCII code for 3
OUT 02H ;display 3 on ASCII display
Memory-mapped I/O
Instructions
• I/O devices are identified by 16-bit addresses
• 8085 communicates with an I/O device as if it were one of
the memory locations
• Memory related instructions are used
• For e.g. LDA, STA
• LDA 8000H
• Loads A with data read from input device with 16-bit
address 8000H
• STA 8001H
• Stores (Outputs) contents of A to output device with 16-
bit address 8001H
----------Example
Program----------
• WAP to read a number from input port (port address
8000H) and display it on ASCII display connected to output
port (port address 8001H)
LDA 8000H ;reads data value 03H (example)into
;accumulator, A = 03H
MVI B, 30H ;loads register B with 30H
ADD B ;A = 33H, ASCII code for 3
STA 8001H ;display 3 on ASCII display
I/O read/write Machine cycle
55
I/O read Machine cycle
56
I/O Write Machine cycle
57
IN 8-bit port address
Maninder Kaur 58
Out 8bit port address
Maninder Kaur 59
I/O device selection
the 8085 gives 8 bit I/O address. This means it can select one of the 256 I/O ports. To
select an appropriate I/O device, it is necessary to do following things.
1. Decode the address to generate unique signal corresponding to the device address
on the bus.
2. When device address signal and control signal (IOR or IOW) both are low, generate
device select signal.
3. Use device select signal to activate the Input Output Interfacing Techniques.
Maninder Kaur 60
Input device
Maninder Kaur 61
Output device
Maninder Kaur 62
Memory mapped I/O
Maninder Kaur 63
Maninder Kaur 64
Th
an
k
Yo
65
u