5. Microprocessor

44
Indian Institute for Production Management 1 Microprocessors

Transcript of 5. Microprocessor

Page 1: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 1/44

Indian Institute for Production Management 1

Microprocessors

Page 2: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 2/44

Indian Institute for Production Management 2

History

Microprocessors became possible with the advent of LSI

technology. INTEL 4004 was the first 4 bit programmable

device which was primarily used in calculators. This chip

became known as the 4 bit microprocessor.Next chip by

INTEL were 8 bit 8008, and in mid 1970 came 8080.

After 8080 came Motorola 6800, Zilog Z80 and 8085.

Currently we have 32 bit and 64 bit processors for PCs.However for industrial applications the 8 bit processors are

still predominantly used.

Page 3: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 3/44

Indian Institute for Production Management 3

Recapitulation

Number Systems:

• Decimal

• Binary• Hexadecimal

• Octal

Decimal Binary Hexadecimal Octal

1 0001 1 1

2 0010 2 2

3 0011 3 34 0100 4 4

5 0101 5 5

6 0110 6 6

7 0111 7 7

8 1000 8 109 1001 9 11

10 1010 A 12

11 1011 B 13

12 1100 C 14

13 1101 D 15

14 1110 E 16

15 1111 F 17

16 10000 10 20

Page 4: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 4/44

Indian Institute for Production Management 4

The ASCII Code

American Standard Code for Information Interchange 

This is a 7 bit code with 128 (27 ) combinations. Each combination from0 to 127 is assigned a letter or a number or a

special character.

Page 5: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 5/44

Indian Institute for Production Management 5

Binary Addition

0 + 0 = 00 + 1 = 1

1 + 1 = 10 OR 1 + 1 = 0 and Carry 1

1 + 1 + 1 = 11 OR 1 + 1 + 1 = 1 and Carry 1

11100

+ 11010

10110 (Carry 1)

Page 6: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 6/44

Indian Institute for Production Management 6

Signed Binary Numbers

It is easy to write negative decimal numbers such as – 1, --2, --3 etc. One common method to write binary

equivalents is to convert the magnitude to binary an add a

0 for + sign and add 1 for – sign.

Thus ( – ) 001 1001

( +) 001 0001

Page 7: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 7/44

Indian Institute for Production Management 7

2’s Compliment 

0

0000

1

0001

-2

1110

-1

1111

2

0010

-3

1101

3

0011

Decimal and Binary Number line

1’s complement Change 1 0 and 0 1 2’s complement add 1 to 1’s complement

Thus 1’s complement of 0001 = 1110 

2’s complement of 0001 = 1110 + 1 = 1111 

Thus for microprocessor operations the number system is :

1) Msb. 0 for positive numbers and 1 for negative numbers.

2)  Negative decimal numbers are in 2’s complement form.

Page 8: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 8/44

Indian Institute for Production Management 8

Memory AddressingIn a computer system each peripheral or memory location is

identified by a binary number called address. This is similar to the

postal address of a house. A house can be identified by various

number schemes. The 45th house on a road can be numbered 45 on

two digit scheme or 0045 on a four digit scheme. Two digit

scheme can only identify 100 houses from 00 to 99, but 4 digitscheme can identify 10000 houses from 0000 to 9999. Similarly

8085 has 16 address lines thus it can address 216 = 65,536 address

which is rounded off to 64K. Thus 8 bit microprocessors can have

maximum 64K memory. Though in practice it is often about 4k orless.8088 has 20 address lines whereas Pentium processors have

32 bit address lines.

Page 9: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 9/44

Indian Institute for Production Management 9

0

1

2

3

4

5

6

7

+5V

GND

D3 D1D2 D0

R0

R1

R2

R3

R4

R5

R6

R7

ROM

Page 10: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 10/44

Indian Institute for Production Management 10

Microprocessor System Organization

ALU Registers System Bus

Memory

ROM RAM

Input/Output

Control

Page 11: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 11/44

Indian Institute for Production Management 11

The Three Bus Architecture

Microprocessor

Address Bus

Data Bus

Control Bus

Memory

I/O

Page 12: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 12/44

Indian Institute for Production Management 12

The Bus System

All communication by a microprocessor is carried outby a set of parallel wires called bus. Any operation

inside the microprocessor, with microprocessor and

memory or microprocessor and I/O must use these

buses.The 8085 or similar microprocessors have a three bus

system.

• The Data Bus

•The Address bus

• Control bus

Page 13: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 13/44

Indian Institute for Production Management 13

Tri State Buffer

A digital bus is a path over which digital information is

transferred from several sources o several destinations.Only one transfer can take place at any one time. When a

particular transfer is taking place all other sources of data

must be disabled. This is achieved by Tri state or Three state

buffer devices.

IN OUT

Enable

ENABLE IN OUT

0 X Open

1 0 0

1 1 1

Page 14: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 14/44

Indian Institute for Production Management 14

Data Bus

For a 8 bit microprocessor like 8085 the data bus has 8

lines. Information can flow both ways on the data bus,

i.e.it can be used for reading and writing to the memory

as well as input and output.Although data can move in both direction, it can move in

one direction at a time.

Page 15: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 15/44

Indian Institute for Production Management 15

Address bus

The number of address lines determine the maximum

addressable memory of the microprocessor.

Example:

8 bit microprocessors have a 16 bit addressing system.

Thus these can address memory from 0000 H to FFFF H

Thus total number of memory locations is given by

2

16

= 65,536The address bus is unidirectional.

Page 16: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 16/44

Indian Institute for Production Management 16

Control Bus

The control bus is a set of lines from the microprocessor

by which commands can be issued to and from the

microprocessor. There can be the following typical use.

1. Memory Read (MEMR)

2. Memory Write (MEMW)

3. Input device read (IOR)

4. Out put device Write (IOW)

Page 17: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 17/44

Indian Institute for Production Management 17

Example of Bus Operation

Writing Data to memory

Address Bus

Data Bus

Control Bus

Valid Address

Valid Data

MEM

Write

Time allowed by microprocessor for memoryto decode the address.

Page 18: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 18/44

Indian Institute for Production Management 18

Address & Data Bus Multiplexing

8085 does not use 16 pins for an exclusive

address bus. The low order address byte A0 to A7

is time multiplexed with the data bits. Thus at a

given instant of time the pins will either supply

either address bits A0 to A7 or Data bits D0 to

D7. The address bits A8 to A15 will be carried by

address bus.

Page 19: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 19/44

Indian Institute for Production Management 19

Address & Data Bus Multiplexing

High Address

Address/Data Low Address Data

ALEControl

Address bus

ALE Address latch enable

Latch address

Page 20: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 20/44

Indian Institute for Production Management 20

Parts of a Microprocessor based system

• Clock 

• Arithmetic logic unit (ALU)

• The Register array

• The Control Unit

• Memory

• Input/ Output

• System Bus

Page 21: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 21/44

Indian Institute for Production Management 21

Clock 

Every microprocessor based system uses a clock 

oscillator from which all timing signals are derived.

The clock of 8085 is contained within the

microprocessor and requires only the addition of a

crystal between the pins 1 and 2. The crystal frequency

is twice the system clock frequency.

Page 22: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 22/44

Indian Institute for Production Management 22

Registers Registers are primarily used to store

data temporarily during execution of 

a program. 

E

H L

Accumulator A Flag Register

B C

D

Stack PointerProgram Counter

8085 Registers

• Store data

• Perform arithmetic &

logical operation.

• Test for condition

• Sequence the execution

of instruction

Functions: 

Page 23: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 23/44

Indian Institute for Production Management 23

Register Pairs

All general purpose registers (A,B,C,D,E,H,L) in 8 bit

microprocessors like 8085 are 8 bit long. The range of 

numbers which can be stored in any register is – 127 to +

127. Thus the registers can be used to store only small

integers, two Hex numbers, one ASCII character etc. For

calculation involving larger numbers some registers can

be used in pairs to provide 16 bit operation.

In 8085 this pairs of registers are BC, DE & HL.

Page 24: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 24/44

Indian Institute for Production Management 24

Program Counter

This is a 16 bit register as it deals with memory

addresses which are 16 bit long.

The function of the program counter is to point to thememory address from which the next byte of 

instruction is to be fetched. When a byte is being

fetched the program counter is incremented by one to

point to the next memory location.

Page 25: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 25/44

Indian Institute for Production Management 25

ALU & Flags

This is the area of the microprocessor where various computing

functions are performed on data. ALU can can do addition,subtraction, and logic operation like AND, OR, and Exclusive

OR.

In 8085 the Accumulator sends and receives data from the ALU

during calculations. The result of a calculation is stored back inaccumulator.

Flags are flip flops which are set or reset according to the result

of an operation.Example:

Carry flag is set(1) if the sum of two numbers is more than 8bits.

Zero flag is set if a result is zero.

Sign flag is set if the result becomes negative during operation.

Page 26: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 26/44

Indian Institute for Production Management 26

Flag Flip Flops

S Z AC P CY

D7 D6 D5 D4 D3 D2 D1 D0

• Z Zero• CY Carry• S Sign• P Parity• AC Auxiliary Carry

Page 27: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 27/44

Indian Institute for Production Management 27

Memory

Memory stores instructions and data and provides them to

the processor whenever necessary.

• ROM (Read Only Memory)

Programs stored in the ROM are those which do not need

alterations.Example EPROM, EEPROM, Flash Memory

etc.

• RAM ( Random Access Memory)

This is user memory.Normally RAM stores intermediate

user programs and data. Microprocessor can both readdata from and write data to RAM e.g.Static RAM,

Dynamic RAM.

Page 28: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 28/44

Indian Institute for Production Management 28

How does the microprocessor work?

FetchInstruction

DecodeInstruction

ExecuteInstruction

The microprocessor fetches binary instructions or data

from the memory. It uses registers to store data temporarily.

It performs computing function in the ALU. It sends outresults using the bus lines. The sequence of fetch, decode

and execute is continued until there is an instruction to stop.

Page 29: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 29/44

Indian Institute for Production Management 29

Interrupt control Serial I/ O

Accumulator Temp Flags

ALU

Instruction

Register

Instruction

Decoder

Increment/decrement

Address Latch

B C

D E

H L

Stack Pointer

Program

Counter

CLKGEN

CLK

OutReady

RDWR

ALES0

S1

IO/M HOLD

HLDA

Reset In

Reset Out

AddressBuffer

Address/DataBuffer

INTR

INTA

RST5.5

RST6.5

RST7.5

TRAP

SID

SOD

CONTROL STATUS DMA RESET

Timing and Control

8 Bit Internal Data Bus

Address Bus

A15  – A8Address/Data Bus

AD7  – AD0

+ 5V

GND

X1

X2

8085Schematic

Page 30: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 30/44

Indian Institute for Production Management 30

8085 PINOUT & Signals 

Page 31: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 31/44

Indian Institute for Production Management 31

Input/Output PortsThere can be three kinds of ports.

1. INPUT Port where CPU reads data from port.

2. OUTPUT port where CPU writes data to port.

3. INPUT/OUTPUT Port which are bi-directional ports.

8 bit processors have 16 bit addresses thus theoretically there

can be 65,536 ports. However in practice this is limited as the

computer’s memory also requires the addresses. In actual practice there can be two methods by which I/O devices

can be identified :• I/Os with 8 bit addresses (i.e. 256 inputs and 256 outputs)

• I/Os with 16 bit addresses( Memory mapped I/O)

Page 32: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 32/44

Indian Institute for Production Management 32

8 bit addressed I/O

There can be 256 inputs and 256 outputs with addressesranging from 00 to FF. The input and output devices are

differentiated by the control signals IOR(I/O read) and

IOW(I/O write).

The I/O devices can not be connected directly to the

buses. They are connected through tri state devices and in

case of output devices a latch is also used to hold the data

for more time than the few microseconds given by the

microprocessor data bus.

Page 33: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 33/44

Indian Institute for Production Management 33

Memory Mapped I/O

In this type of I/O device the microprocessor uses 16 bit

address lines to identify an I/O device; an I/O device is

accessed in the same way as a memory location using

the same control signals for Memory Read and

Memory Write.

Motorola 6800 microprocessor uses this technique.

Page 34: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 34/44

Indian Institute for Production Management 34

Control and Status signals of 8085

 ALE

 –

Address Latch enable:This is a positive goingpulse generated every time 8085 begins a machine cycle. Itindicates that AD7  –AD0 are address bits.

  RD  – Read: Read control signal. Active low. It means

that selected I/O or memory to be read and data is availableon the data bus.

 WR  – Write: Write control signal. Data to be written tomemory or I/O location.

 IO/M : The status signal to differentiate between I/O andmemory operation. High status = I/O operation

Low status = Memory operation

Page 35: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 35/44

Indian Institute for Production Management 35

Control and Status signals of 8085

RESET IN: When the the signal to this pin goes low the

program counter is set to zero, the buses are tri stated,

and the microprocessor is reset.

RESET OUT: This signal indicates that the MPUisbeing reset and can be used to reset other devices.

READY (Input): This signal is used to delay the MPU

READ or WRITE cycles until a slow responding

peripheral is ready to send or receive data. When thissignal goes low the MPU waits for an integral number of 

clock cycles until it goes high.

Page 36: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 36/44

Indian Institute for Production Management 36

Direct Memory Access(DMA)

HOLD: This is an active high input signal to the 8085 from

another device requesting the use of the address and the data

buses.After receiving the hold request the microprocessor gives

up the control of the buses for the following machine cycles.And

sends out the HLDA:(Hold acknowledge) signal.

Generally an external peripheral DMA controller sends the

HOLD signal, On getting the HLDA signal it gets control of the

buses. After the data transfer is over the HOLD pin gets a low

signal and MPU gets back control.

Direct Memory Access is the data transfer between MPU memory

and external peripheral device without control of the CPU.

Page 37: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 37/44

Indian Institute for Production Management 37

Interrupts8085 has five interrupt signals that can be used to interrupt aprogram execution.• INTR (Input) : Interrupt Request: This is a general purposeinterrupt which can be enabled or disabled by software.• INTA (Output): Used to acknowledge the interrupt.• RST 7.5• RST 6.5 (Inputs)• RST 5.5 

Restart interrupts. These can transferprogram control to specific memorylocations.

• TRAP (Input) This has the highest priority of all interrupts.

And can not be disabled. This is mainly used for emergencyoperations.

Page 38: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 38/44

Indian Institute for Production Management 38

Programmable Devices with Handshake

Signal

MPU and peripherals operate at different speeds, thussignals are exchanged prior to to data transfer between

fast responding MPU and slow responding peripheral such

as printers and data converters, keyboards etc. These

signals are called Handshake signals.The exchange of handshake signals prevent the MPU from

writing over the previous data before the peripheral has

had a chance to accept it, or reading the same old data

before the peripheral has time to send the new byte. These

handshake signals are generally provided by

programmable peripheral devices. 

Page 39: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 39/44

Indian Institute for Production Management 39

Interfacing device With Handshake

MPU

Programmable

InterfacingDevice8155

or8255

Peripheralsuch as key board

RD

Data

Bus

Data

Lines

STB

IBF

INTR

Page 40: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 40/44

Indian Institute for Production Management 40

Data Input With Handshake

1. A peripheral places a data byte in the input port andinforms the interface device by sending Handshakesignal STB(Strobe)

2. The device informs the peripheral that its input port is full(do not send the next byte) by sending the handshakesignal IBF( Input buffer full)

3. MPU keeps checking the status until a byte is available

or the interfacing device sends an interrupt to MPU toread the new data.

4. MPU reads the data by sending control signal RD

Page 41: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 41/44

Indian Institute for Production Management 41

Stack PointerThe Stack in 8085 microprocessor system can be

described as a set of memory locations in the RAM used

by the program to store information temporarily during

execution of the program.

The beginning of the stack is defined by the statement

LXI SP, which loads a 16 bit address in the stack pointerregister of the microprocessor . Once the stack is defined

the loading of the data bytes begins one address lower

than the stack pointer register. Thus if the stack pointer

register has the address 2099h then the storing of data

bytes will begin at 2098h.Thus normally the highest level

of memory available is given to the stack. 

Page 42: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 42/44

Indian Institute for Production Management 42

Interfacing Devices

TRI STATE DEVICES:

74LS244: Octal Buffer. Commonly Used as driverfor address bus of a microprocessor system.

74LS245: Octal Bidirectional Buffer. Has 16 busdrivers , 8 for each way. Used for Data bus.

Page 43: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 43/44

Indian Institute for Production Management 43

Interfacing DevicesDECODER:Commonly used for interfacing I/O peripherals

and memory. Decoder is a logic circuit that identifies eachcombination of input signals present. Thus a 2 to 4 decoder

will have four combination of input signals that identifies

the 4 output lines.

3 TO 8

Decoder

Examples of Decoders:

74LS138

8205

Page 44: 5. Microprocessor

8/3/2019 5. Microprocessor

http://slidepdf.com/reader/full/5-microprocessor 44/44

44

Interfacing DevicesLATCHES:

A latch is commonly used to interface output devices. Whena microprocessor sends a signal to the output the data is

available for only a few microseconds, the latch is used tohold the data for display or for transmission to slowperipheral devices.

Example: 74LS373 octal D latch. The device has 8 D latches

with Tri State Buffers.