Unit 1 Foundation of Microprocessor
Unit 1 Foundation of Microprocessor
Microprocessor
Sr. Lec. Sujan Shrestha
9801104103
[email protected]
Why Microprocessor????
• Which device got micro-processor??
- Fan , television, computer, bulb, remote, traffic light, router?????
- Any device which need programming got a processor.
• First Generation – 1946-1959
• Vacuum tube based
• Second Generation – 1959-1965
• Transistor based
• Third Generation – 1965-1971
• Integrated Circuit based
• Fourth Generation – 1971-1980
• VLSI microprocessor based
• Fifth Generation -1980-onwards
• ULSI microprocessor based or bio-chip
Stored Program Concept
• The term Stored Program Control Concept refers to the storage of
instructions in computer memory to enable it to perform a variety of tasks
in sequence or intermittently.
• The idea was introduced in the late 1940s by John von Neumann who
proposed that a program be electronically stored in the binary-number
format in a memory device so that instructions could be modified by the
computer as determined by intermediate computational results.
• ENIAC (Electronic Numerical Integrator and Computer) was the first
computing system designed in the early 1940s. It was based on Stored
Program Concept in which machine use memory for processing data.
Stored Program Concept
• Stored program concept - a program must be in main memory in
order for it to be executed. The instructions are fetched, decoded and
executed one at a time.
Von-Neumann Architecture vs Harvard Architecture
Harvard Architecture
Instruction The processing unit would require two clock cycles to The processing unit can complete an instruction
Processing complete an instruction. in one cycle if appropriate pipelining plans have
been set.
Use Von Neumann architecture is usually used literally in all Harvard architecture is a new concept used
machines from desktop computers, notebooks, high specifically in microcontrollers and digital signal
performance computers to workstations. processing (DSP).
Cost Instructions and data use the same bus system therefore Complex kind of architecture because it employs
the design and development of control unit is simplified, two buses for instruction and data, a factor that
hence the cost of production becomes minimum. makes development of the control unit
comparatively more expensive.
Power of 2
• 20 = 1, 21 = 2 , 22 = 4 , 23 = 8 , 24 = 16 , 25 = 32 , 26 = 64 , 27 = 128 ,
28 = 256 , 29 = 512 , 210 = 1024 or 1 K
• 212 = 22 * 210 = 4 K, 217 = 27 * 210 = 128 K, 220 = 210 * 210 = 1 M
• 223 = 23 * 220 = 8 M, 226 = 26 * 220 = 64 M, 230 = 220 * 210 = 1 G
• 234 = 24 * 230 = 16 G, 235 = 25 * 230 = 32 G, 240 = 230 * 210 = 1 T
• 248 = 28 * 240 = 256 T
Evolution of Microprocessors (Intel series)
What is Microprocessor?
• Microprocessor is an electronic circuit that functions as the central
processing unit (CPU) of a computer, providing computational control.
In short, processor as a chip.
What is a Microprocessor?
Definition:
“The Microprocessor is a
Can perform Multipurpose, Can be instructed
multiple tasks to perform
Programmable, specific task
Provides
Synchronization
Clock Driven, Store
Intermediate
Form of an
Register Based, Processing data
Integrated Digital-Integrated Circuit
circuit (IC) which accepts binary data as input,
processes it according to instructions stored in its memory, and provides
results as output.”
12
A computer System
Stores Programs
Memory , address and
data
Process
data and CPU
programs
Interface to give
I/O Devices
input and output
Data vs program
• Data – text, audio, image
• Programs – applications, messaging app, mp4 player, image viewer,
VLC player
• How data are stored? Are they stored in the same form as video or
songs, photos??
• Each and everything are stored in the form of 0 and 1
An image example
• Divided into millions of pixels, each pixel represents color.
• 1 bit can store 2 color, 2 bit can 4 colors, 3 bit can represent 8 and
current system is of 24 bit which can represent 16,777,216 colors
• Every thing on the form of 0,1 either it is data or programs.
• 8 bit is equivalent to 1 byte and 16 bit is equivalent to 2 byte which
also means word
• If we are saying memory then it mean primary memory as secondary
memory didn’t exist at that time.
• ROM - Read only memory (used to store data permanently)
• RAM – Random access memory (volatile, which is we are talking here
as memory). Everything happens in RAM.
• RAM is made up of either flip-flop(S-RAM) or transistor(D-RAM). Flip-flop
works on the principle of set and reset and transistor works on the principle
of charging and discharging.
We use hexa-decimal numbering in Microprocessor, Why?
• We, human being are familiar with decimal but computer keeps data
as binary numbers.
• For decimal representation 4 binary bits are required from 0000 to
1010.
• It looks 1011,1100,….., 1111 looks redundant. Though it looks just 6
numbers but can you distinguish between 9999 and FFFF.
• FFFF means 65535
Binary to hexa-decimal conversion
• First decimal to binary Binary Hexa-decimal
•8 4 2 1 1010 AH
1011 B
1100 C
• 9 means 10012 1101 D
Microprocessor
Registers
Control
Logic
ALU
19
Basic concepts of Micro-controller
Computer as a chip
Silicon chip which includes
Microcontroller microprocessor, memory & I/O in a
single package.
Microcontroller
RAM
Micro
ROM
Processor
I/O
20
Microprocessor vs
Microcontroller
Micro-processor Micro-controller
21
Microprocessor vs Microcontroller
Microprocessor Microcontroller
It is vital part of computer system. It is vital part of embedded system.
It contain CPU inside it but does not It has CPU, fixed size of RAM, ROM and
contain on chip RAM, ROM and other peripherals mounted on a single chip.
peripherals.
It is multipurpose device which performs It is designed for specific task with fixed
several tasks. input, processing and output.
E.g. Software development, word E.g. Operating a washing machine,
processing, playing games, surfing etc. handling mouse click event etc.
It operates at high speed compared to It operates at comparatively lower speed
microcontroller. than microprocessor.
E.g. Clock speed of latest microprocessor is E.g. Clock speed is measured in MHz.
measured in GHz.
Application: Application:
Desktop PC’s, Laptops, notepads etc. Microwave oven, washing machine,
remote control, Mouse etc.
22
Basic concepts of Microprocessors
A small computer with a
Microcomputer microprocessor as its CPU.
Includes memory, I/O etc.
Microcomputer
RAM
Micro
Keyboard ROM Display
processor
I/O
23
Components of Microprocessor
Small additional
• Performs memory location,
Arithmetic and which are used to
Logical operations
Arithmetic store and transfer
and Register data.
Logical Array
Unit (ALU)
Control Unit
25
Features of Microprocessor
• Cost-effective − The microprocessor chips are available at low prices
and results its low cost.
• Size − The microprocessor is of small size chip, hence is portable.
• Low Power Consumption − Microprocessors are manufactured by
using metal-oxide semiconductor technology, which has low power
consumption.
• Versatility − The microprocessors are versatile as we can use the same
chip in a number of applications by configuring the software program.
• Reliability − The failure rate of an IC in microprocessors is very low,
hence it is reliable.
System Bus
27
System bus
• The network of wires or electronic pathways is known as 'Bus'.
• Classification
1. Address Bus - Transfer Address
2. Data Bus - Transfer Data
3. Control Bus - Transfer Control Signal
28
System bus
CPU Memory Input/Output
Control Bus
Address Bus
Data Bus
System Bus
29
Address Bus
CPU Memory Input/Output
Control Bus
Address Bus
Data Bus
System Bus
30
Address Bus
• Transfers the addresses of Memory or I/O devices.
31
Data bus
CPU Memory Input/Output
Control Bus
Address Bus
Data Bus
System Bus
32
Data Bus
• It is used to transfer data within Microprocessor and Memory/IO
devices.
• Data Bus is bidirectional as Microprocessor requires to send and
receive data.
• Each wire of data bus is used to transfer the data corresponding to a
single bit of binary data.
E.g. 8085 has 8 - data lines
33
System bus
CPU Memory Input/Output
Control Bus
Address Bus
Data Bus
System Bus
34
Control Bus
• Microprocessor uses control bus to process data.
i.e. what to do with the selected memory location.
• Some control signals are Read, Write and Opcode fetch etc.
• Control Bus is bidirectional.
• This is a dedicated bus, because all timing signals are generated
according to control signal.
35
Microprocessor systems with
bus organization
36
Microprocessor systems with bus organization
Input/Output
Arithmetic
and Register
Logical Array System Bus
Unit (ALU)
37
Micro-processor Architecture and Operation
Memory
Address Data
location
1000 3E
1001 22
……… …..
2000 …
2001 6C
Micro-processor
I/O Devices
Read Operation
Memory
Address Data
location
Step One
Select address 1000 3E
1001 22
Address Bus ……… ….. Data Bus
2000 …
Step two
2001 6C
Micro-processor Bus carry data
Step three
Triger read Control bus
signal
Control Unit I/O Devices
Write Operation
Memory
Address Data
location
1000 3E
Step 1
1001 22 Data Bus
Select the
address ……… …..
2000 …
Step 3
Address Bus 2001 6C Carry
Micro-processor
Data
Step 2
Trigger the Control
write signal Bus
Performing the
operation -
Execute I/O Devices
Micro-processor
Address Data
It takes the address 1000 1A
PC
1001 1001 4C
PC -->1002 Address Bus
1002 23
Now, Instruction is Data Bus 1003 E2
decoded i.e.
………
understanding the Instruction
opcode side by Register 4C Control Bus
side PC is Read
incremented
CPU
Address Memory
PC 0003H Instruction 4
0002H Instruction 3
IR 0001H Instruction 2
0000H Instruction 1
49
INR/DCR
• Increment Register helps to increment the value of Program Counter
• INR/ DCR used for stack. We will discuss it later.
Timing and Control Circuit
• It is analogy to human brain. It instruct what other field to do.
• It’s input is instruction from instruction decoder and output is control
signal.
Data Bus
5
Accumulator Temp
(A)=2 Register 3
B=3
5
ALU 2+3=5
AAALU
a=2
b=3
2
a+b
ADD B
Value of A added with value of
B and stored in A
A is accumulating the result so
it is called accumulator
Accumulator and ALU ADD enable signal from control bus
• Temporary register : Store the data for temporary from register or
input devices. It is unidirectional
• Accumulator – store the result from ALU. It is bidirectional
• ALU – operates arithmetic and logical operation by getting the signal
from timing and Control circuit.
Flag registers
Flags tells the status of the current result from the ALU.
It is unidirectional for data bus but bidirectional for ALU
Sign flag
Carry Flag
4. Auxiliary Carry Flag (AC) – This flag is used in BCD number system(0-9). If after any arithmetic or
logical operation D(3) generates any carry and passes on to B(4) this flag becomes set i.e. 1,
otherwise it becomes reset i.e. 0. This is the only flag register which is not accessible by the
programmer
1-carry out from bit 3 on addition or borrow into bit 3 on subtraction
0-otherwise
Example:
MVI A, 2B (load 2BH in register A)
MVI B, 39 (load 39H in register B)
ADD B (A = A + B)
These set of instructions will set the auxiliary carry flag to 1, as on adding 2B and 39, addition of lower
order nibbles B and 9 will generate a carry.
5.Carry Flag (CY) – Carry is generated when performing n bit operations and the result is
more than n bits, then this flag becomes set i.e. 1, otherwise it becomes reset i.e. 0.
During subtraction (A-B), if A>B it becomes reset and if (A<B) it becomes set.
Carry flag is also called borrow flag.
1-carry out from MSB bit on addition or borrow into MSB bit on subtraction
0-no carry out or borrow into MSB bit
Example:
MVI A 30 (load 30H in register A)
MVI B 40 (load 40H in register B)
SUB B (A = A – B)
These set of instructions will set the carry flag to 1 as 30 – 40 generates a carry/borrow.
MVI A 40 (load 40H in register A)
MVI B 30 (load 30H in register B)
SUB B (A = A – B)
These set of instructions will reset the sign flag to 0 as 40 – 30 does not generate any
carry/borrow.
Flag Register
D7 D6 D5 D4 D3 D2 D1 D0
S Z AC P CY
63
What will be the result of flag registers if we perform
33
+A6
4002 04
4003 03
Value of Top of stack = 04 4004 02
Address of Top of stack = 4002 4005 01
Value of stack Pointer = 4002
4001 1A
4002 04
PUSH 1A
4003 03
POP 4002 04
4003 03
Pop operation increments the value of address 4004 02
SP = 4003 4005 01
INTA RST6.5 TRAP
INTR RST5.5 RST7.5 SID SOD
Instruction
Accumulator (8) Temp. Reg. (8) Multiplexer
Reg. (8)
W (8) Z (8)
Temp. Reg. Temp. Reg.
Instruction B (8) C (8)
Decoder Reg. Reg.
Register Select
Flag (5) and D (8) E (8)
Flip-Flops Machine Reg. Reg.
Cycle H (8) L (8)
Encoding Reg. Reg.
Arithmetic Stack Pointer (16)
Logic Unit
Power +5 V (ALU) (8) Program Counter (16)
Supply GND
Increment/Decrement
Address Latch (16)
X1 CLK
Timing and Control Reset
X2 GEN Address Buffer Data/Address Buffer
Control Status DMA
(8) (8)
Register Select
Flip-Flops Machine
InstructionD decoder
(8) Edecodes
(8)
Reg. Reg.
Cycle the information
H (8) present
L (8) in the
Encoding InstructionReg.
register.Reg.
Arithmetic Stack Pointer (16)
Logic Unit
(ALU) (8) Program Counter (16)
Increment/Decrement
Address Latch (16)
X1 CLK
Timing and Control Reset
GEN
• Performs
Control Computing
Status Functions.
DMA Address Buffer Data/Address Buffer
(8) (8)
• Accumulator, Temporary Register
CLK RD WR S0 S1 HLDA RESET OUT
OUT
and Flag Registers
ALE
are part of ALU. A15 - A8 AD7 – AD0
HOLD RESET IN Address
READY Address/Data70
Bus Bus
INTA RST6.5 TRAP
INTR RST5.5 RST7.5 SID SOD
A multiplexer pulls out the right group
Interrupt Control of bits, depending on the instruction.
Serial I/O Control
Instruction
Accumulator (8) Temp. Reg. (8) Multiplexer
Reg. (8)
W (8) Z (8)
• • Two additional 8-bit register,
Each register can hold 8-bit data. which holds Temp. Reg. Temp. Reg.
• the
Thesetemporary datawork
registers can during execution
in pairInstruction
to hold
Decoder
of
16- B (8) C (8)
some instructions.
bit data and Flag
their (5)
pairing combination
and is
Reg. Reg.
Register Select
D (8) E (8)
• They are used
like B-C, D-E & H-L.internally,
Flip-Flops so they are
Machine not Reg. Reg.
available to the programmer. Cycle H (8) L (8)
It increments the program counter as Encoding Reg. Reg.
instructions
16-bit
It register
is a 16-bit execute,
used
register works
Arithmetic increments
to store the which
like stack, and is
memory Stack Pointer (16)
decrements
address
always the stack
location
Logic pointer
of
Unit
the
incremented/decrementednext as needed,
instruction
by 2 andbe
to
during
(ALU) (8) Program Counter (16)
supports
executed. the 16-bit
push & pop operations. increment and decrement
Increment/Decrement
instructions. Address Latch (16)
• The content stored in the SP and PC is
X1 CLK
loaded
Timing and into the Address BufferResetand
Control
GEN Address Buffer Data/Address Buffer
Data/Address
Control Buffer.
Status DMA
(8) (8)
• The memory and I/O chips are connected
CLK RD WR S0 S1 HLDA RESET OUT
to
OUT
these buses
ALE
that can exchange the A15 - A8 AD7 – AD0
HOLD RESET IN
data.
READY Address Address/Data71
Bus Bus
INTA RST6.5 TRAP
INTR RST5.5 RST7.5 SID SOD
A multiplexer pulls out the right group
Interrupt Control of bits, depending on the instruction.
Serial I/O Control
Instruction
Accumulator (8) Temp. Reg. (8) Multiplexer
Reg. (8)
W (8) Z (8)
• • Two additional 8-bit register,
Each register can hold 8-bit data. which holds Temp. Reg. Temp. Reg.
• the
Thesetemporary datawork
registers can during execution
in pairInstruction
to hold
Decoder
of
16- B (8) C (8)
some instructions.
bit data and Flag
their (5)
pairing combination
and is
Reg. Reg.
Register Select
D (8) E (8)
• They are used
like B-C, D-E & H-L.internally,
Flip-Flops so they are
Machine not Reg. Reg.
available to the programmer. Cycle H (8) L (8)
It increments the program counter as Encoding Reg. Reg.
instructions
16-bit
It register
is a 16-bit execute,
used
register works
Arithmetic increments
to store the which
like stack, and is
memory Stack Pointer (16)
decrements
address
always the stack
location
Logic pointer
of
Unit
the
incremented/decrementednext as needed,
instruction
by 2 andbe
to
during
(ALU) (8) Program Counter (16)
supports
executed. the 16-bit
push & pop operations. increment and decrement
Increment/Decrement
instructions. Address Latch (16)
• The content stored in the SP and PC is
X1 CLK
loaded
Timing and into the Address BufferResetand
Control
GEN Address Buffer Data/Address Buffer
Data/Address
Control Buffer.
Status DMA
(8) (8)
• The memory and I/O chips are connected
CLK RD WR S0 S1 HLDA RESET OUT
to
OUT
these buses
ALE
that can exchange the A15 - A8 AD7 – AD0
HOLD RESET IN
data.
READY Address Address/Data72
Bus Bus
INTA RST6.5 TRAP
INTR RST5.5 RST7.5 SID SOD
Instruction
Accumulator (8) Temp. Reg. (8) Multiplexer
Reg. (8)
W (8) Z (8)
Temp. Reg. Temp. Reg.
Instruction B (8) C (8)
Decoder Reg. Reg.
Flag (5) and
Register Select
D (8) E (8)
Flip-Flops Machine Reg. Reg.
Cycle H (8) L (8)
Encoding Reg. Reg.
This unit synchronizes all the microprocessor operations
Arithmetic with the
Stack Pointer (16)
clock and generates control signal necessary for communication
Logic Unit
betweenInput
Perform signal to synchronize
(ALU)
microprocessor microprocessor
(8) & peripheral.
synchronization Program Counter (16)
Frequency Control
Read/write Signals
either to/from memory orsignal
peripherals.
with with peripheral
peripheral
Address device.
device.
Shows DMA control
read/write
Latch status
Enable controlto/from
Increment/Decrement
signalmemoryAddress
or I/O.Latch (16)
X1 CLK
Signal to RESET microprocessor
Timing and Control Reset and other devicesData/Address
connected to
X2 GEN Address Buffer Buffer
Control Status DMA
it. (8) (8)
Instruction
Accumulator (8) Temp. Reg. (8) Multiplexer
Reg. (8)
W (8) Z (8)
Temp. Reg. Temp. Reg.
Instruction B (8) C (8)
Decoder Reg. Reg.
Flag (5) and
Register Select
D (8) E (8)
Flip-Flops Machine Reg. Reg.
Cycle H (8) L (8)
Encoding Reg. Reg.
Arithmetic Stack Pointer (16)
Logic Unit
(ALU) (8) Program Counter (16)
Increment/Decrement
Address Latch (16)
X1 CLK
Timing and Control Reset
X2 GEN Address Buffer Data/Address Buffer
Control Status DMA
(8) (8)
Instruction
Accumulator (8) Temp. Reg. (8) It controls
Reg. (8) the serial data communication by
Multiplexer
using two instructions:
W (8) Z (8)
Temp. Reg. Temp. Reg.
i.
Instruction SID (Serial input
B (8)
data)C (8)
ii. SOD (Serial output
Decoder Reg. data)
Reg.
Flag (5) and
Register Select
D (8) E (8)
Flip-Flops Machine Reg. Reg.
Cycle H (8) L (8)
• It controls the Encoding
interrupts Reg. Reg.
during aArithmetic
process. Stack Pointer (16)
• There areLogic Unit
5 interrupt signals
(ALU) (8) Program Counter (16)
in 8085 microprocessor:
Increment/Decrement
TRAP, RST 7.5, RST 6.5, RST Address Latch (16)
X1 CLK
5.5, INTR.
Timing and Control Reset
X2 GEN Address Buffer Data/Address Buffer
Control Status DMA
(8) (8)
Instruction
Accumulator (8) Temp. Reg. (8) Multiplexer
Reg. (8)
W (8) Z (8)
Temp. Reg. Temp. Reg.
Instruction B (8) C (8)
Decoder Reg. Reg.
Register Select
Flag (5) and D (8) E (8)
Flip-Flops Machine Reg. Reg.
Cycle H (8) L (8)
Encoding Reg. Reg.
Arithmetic Stack Pointer (16)
Logic Unit
Power +5 V (ALU) (8) Program Counter (16)
Supply GND
Increment/Decrement
Address Latch (16)
X1 CLK
Timing and Control Reset
X2 GEN Address Buffer Data/Address Buffer
Control Status DMA
(8) (8)