Professional Documents
Culture Documents
Unit 1 MPUOrganization
Unit 1 MPUOrganization
2 MGRJ,ECE,RVCE
Block diagram of a
computer system
MP
IC
4 MGRJ,ECE,RVCE
Processor
A processor unit is that part of a computer system or digital system
that implements the operations in the system.
A Processor IC interfaced with many other components to realize
computer system.
The user is expected to give instructions to the processor by writing a
program in assembly or high level language.
5 MGRJ,ECE,RVCE
Functional units
of a Microprocessor
6 MGRJ,ECE,RVCE
Source: T.L Floyd, “Digital Fundamentals”, 9e
CPU: Block diagram
Processor
Control Unit
Logic Unit
7 MGRJ,ECE,RVCE
Processor Logic Unit(PLU)
In most of the processors, the different operations are implemented by
means of arithmetic & logical operations.
Processor logic unit consists of circuits to implement Arithmetic &
Logic operations. These circuits are called as Arithmetic & Logic
Unit(ALU).
The ALU receives the information(operands) from the registers and
performs a given operation as specified by control unit.
8 MGRJ,ECE,RVCE
Simple PLU:
Bus Organization
9 MGRJ,ECE,RVCE
Bus Organization
Different units are connected by buses: Bus organization
Each register is connected to two multiplexers( MUX) to form
input buses A & B.
The input buses A & B are applied to a ALU.
The function selected in the ALU determines the particular
operation that is to be performed.
The result of the operation goes through the output bus S into the
inputs of all registers.
The shift operation is implemented in the shifter.
10 MGRJ,ECE,RVCE
Bus Organization: An Example
Operands:
- MUX A selector: One among 4 registers is to be connected to input bus A
& B , hence at least two select line(bits) are required.
MUX –A MUX-B
Select lines Register
Select lines Register
A1 A0 Selected
B1 B0 Selected
0 0 R0
00 R0
0 1 R1
01 R1
1 0 R2
10 R2
1 1 R3
11 R3
11 MGRJ,ECE,RVCE
Number of multiplexers
One MUX is required to connect a bit of register to ALU, the number MUXs required is
equal number of bits(size of ALU).
E.g: Size of ALU=4 bits => Register Size=4 bits
0 0 0 0
12
MGRJ,ECE,RVCE
Bus Organization: An Example
ALU
Assume ALU performs 8 different operations.
Hence, requires at least 3 bits of input to differentiate the operation.
The ALU performs different operations according to table shown below.
13 MGRJ,ECE,RVCE
Bus Organization: An Example
Shifter
Assume if Shift select=1, shift the data,
shift select=0, no shift
Decoder
Decoder select a register to store data after operation.
Assume decoder generate load signal to different register according to table shown
below. Destination Register
select Selected
D1 D0
00 R0
01 R1
10 R2
11 R3
14 MGRJ,ECE,RVCE
So the control unit is …..
Operation and
Operands
Control Signals
15 MGRJ,ECE,RVCE
Example:
Assume: Operation to be performed is addition (by user).
R1 R1+R2
Operation is called as an instruction.
R2 is source operand & R1 is source as well as destination.
16 MGRJ,ECE,RVCE
Example contd…
The macro operation(operation/Instruction) addition involves
many micro operations.
Micro operations
- Place contents of R1 onto bus A
- Place contents of R2 onto bus B
- Perform Addition in ALU
- No shifting of data(transfer data)
- Select Destination register
17 MGRJ,ECE,RVCE
Example contd…
So, for the operation assumed, the control signals to be generated are,
The processor(Control unit & PLU) understands instructions in binary format called
as Machine(Processor) level language.
It is not possible for the user to give instructions in binary format.
Hence, we have assembly language & high level language.
18 MGRJ,ECE,RVCE
So,
how to write
instructions?
Mnemonics
19 MGRJ,ECE,RVCE
Machine Independent High level languages
MGRJ,ECE,RVCE
Source: T.L Floyd, “Digital Fundamentals”, 9e
20
Example contd…
Compiler & assembler generates machine codes, based on instruction format of the
processor.
Instruction format or control word of the PLU considered:
21 MGRJ,ECE,RVCE
Timing Sequence
Each micro operation assumed takes some time for completion.
The control signals are expected to generate in a sequence starting from source operand
selection.
Assume, different successive times instants during which control signals generated to
complete the operation.
T0 is time instant during which control signals for register selection are generated.
T0: Register selection (MUX A Sel=01, MUX B Sel= 10)
T1: Addition (Opcode=000)
T2: Shift( Shift Select=0)
T3: Destination Selection(Decoder input=01)
To complete all micro operations, at least 4 time instants are required.
The sequence of time instants form timing sequence.
22 MGRJ,ECE,RVCE
Timing sequence…
To generate timing sequence, a counter can be used by control unit.
It is required to generate 4 time instants, a counter with at least 4 states is
required.
A Simple 2 bit up counter with outputs Q1Q0 with AND gate decoding according
to table shown below.
2-bit counter
Q1
Q0 T3
23 MGRJ,ECE,RVCE
Control unit modified
Operation and
Operands
Clock
24 MGRJ,ECE,RVCE
Questions?
What is instruction code?
What is micro and macro instruction?
What is control signal?
What is mnemonics?
What is an ALU size?
What is bus?
25 MGRJ,ECE,RVCE
Control Unit(CU) Basics
CU generates different control signals needed to perform different operations in data path.
2 ways to implement: Hardwired & Micro programmed
E.g: Consider a assembly program as follows for the PLU Considered.(Note: Instructions & Mnemonics assumed are
arbitrary.)
Begin
SUB R2,R1
CPL R3
Assembler Directives
AND R2,R3
OR R2,R3
end Instructions
Assembler directives are used to give information to assembler only, no machine codes are generated, hence called
as pseudo instructions in the program.
(Assembler directives are similar to pre processor directives of high level languages).
26 MGRJ,ECE,RVCE
Assembly Program with machine codes
If the sequence of machine codes to be generated are known, then a digital circuit can
be designed to generate the machine codes => “Hardwired” Control Unit
So, hardwired control unit is predesigned hardware capable of generating one
sequence of machine codes.
27 MGRJ,ECE,RVCE
Control unit: Micro programmed
28 MGRJ,ECE,RVCE
Micro programmed Control unit: Stored Program Concept
Execute
Decode
Fetch
29 MGRJ,ECE,RVCE
Questions
1. Mention different functional units of a computer.
2. What is a processor?
3. What is Processor unit & Control unit ?
4. What is address bus, data bus, control bus?
5. What is address space of the processor?
6. What is the size of the memory supported by processor?
30 MGRJ,ECE,RVCE
Questions
1. What is required in a processor to support memory?
2. What is data memory?
3. What is program memory?
4. What is chip select signal?
5. How many memory chips of size 4k x 4 are required to realize 8k x 8 memory?
31 MGRJ,ECE,RVCE
Instruction Set Architectures(ISAs)
An instruction set or instruction set architecture (ISA), is the part of the
processor architecture related to programming.
All processors are supported by instruction set /instructions (Assembly
instructions) which are dependent on organization of different components in PLU.
Depending upon the way of supporting different instructions, the ISA is majorly
divided into:
-Reduced Instruction Set Computer(RISC)
-Complex Instruction Set Computer(CISC)
Other types of ISAs:
-Very Long Instruction Word(VLIW), etc….
32 MGRJ,ECE,RVCE
CISC & RISC Design Philosophy: CISC Vs RISC
CISC RISC
More number of instructions Lesser no. of instructions.
Instructions are complex to Instructions are Easier to
understand. understand.
• Hardware support for many • Software support for many
instructions (More silicon Usage) instructions/operations.
A programmer can achieve the desired (Less silicon usage)
functionality with a single instruction Programmer needs to write more code
which in turn provides the effect of using to execute a task since the instructions
more simpler single instructions in RISC. are simpler ones.
• Clock cycles per instruction(CPI) is
Clock cycles per instruction(CPI)
more. is less.
33 MGRJ,ECE,RVCE
CISC & RISC Design Philosophy: CISC Vs RISC
CISC RISC
Code density is more. Code density is less.
Less number of registers. More number of registers.
Memory to memory operations are No memory to memory operations
supported. are supported.
Load & store operations in an instruction Load & store operations not in a
instruction (So called as, load-store
architecture)
• More number of addressing • Less number of addressing modes.
modes.
• Variable length instructions. • Fixed length instructions.
• Design of Pipelining is Complex. • Design of Pipelining is easier.
34 MGRJ,ECE,RVCE
CISC & RISC Design Philosophy: CISC Vs RISC
CISC RISC
Non Orthogonal Instruction Set Orthogonal Instruction Set
All instructions are not allowed to operate Allows each instruction to operate on any
on any register and use any addressing register and use any addressing mode.
mode. It is instruction specific. • Examples: ARM, MSP 430, PIC MCUs,
• Examples: 8086
POWERPC
NOTE: The fact is, the designers are not worried about the
architecture(CISC/RISC). So, the features from both the architectures are mixed up
to increase the performance(Increase speed & reduce memory consumption).
35 MGRJ,ECE,RVCE
Questions
What is code density?
What is an orthogonal instruction set?
Why CPI is less in RISC architecture?
Which is the preferable control unit to support complex operations ?
What is the advantage/disadvantage of fixed length instructions?
What is hardware support for an instructions?
36 MGRJ,ECE,RVCE
Von Neumann & Harvard Architecture
This classification is based on processor architecture design to support
memory.
Address Space:
- No. of locations a processor/controller can address.
E.g: 8086: Address bus=20 bits, so address space is 1 Mb
(00000H-FFFFFH)
8051: Address bus=16 bits, so address space is 64 Kb
(0000h-FFFFh)
37 MGRJ,ECE,RVCE
Von Neumann/Princeton Architecture
In this architecture, address space is shared between program memory & data memory.
E.g: 8086
-Total Address space is 1Mb
- The address space is segmented(shared) in to code segment(Program memory) and
data segment (data memory).
Common memory for program & data.
Single shared bus(Address, data & control: System bus) for Instruction and Data fetching.
Pgm /data
memory
39 MGRJ,ECE,RVCE
Von Neumann & Harvard Architecture
What is the meaning of common memory for program & data?
- Is it possible to use RAM as program memory(Basic need: Permanent storage)?
- Is it possible to use ROM as data memory?(Basic need:
Read/write during program execution)
Case 1: Microcontrollers
-The flash (EEPROM) is used as a program memory & RAM(SRAM) is used as a data
memory(Integrated into chip).
- Usually based on Harvard architecture.
So, the question is invalid!
(Note: Some microcontrollers are based on Von Neumann also)
40 MGRJ,ECE,RVCE
Von Neumann & Harvard Architecture
Case 2: Microprocessor
-The block diagram shows 8086 MPU connected to memory.
41 MGRJ,ECE,RVCE
Von Neumann & Harvard Architecture
Case 3: Modern Microprocessors/ Computers
- The block diagram shows MPU connected to memory
42 MGRJ,ECE,RVCE
Von Neumann & Harvard Architecture
Case 4: Modern Microprocessors/ Computers
44 MGRJ,ECE,RVCE
Von Neumann/Princeton Architecture
Note: The separate bus for program memory & data memory is applicable
only to on chip memory.
45 MGRJ,ECE,RVCE
Questions
What is an address space?
Why execution is faster in a processor based on Harvard architecture?
What is a cache?
46 MGRJ,ECE,RVCE
Fixed point and Floating point Processors
Processing can be separated into two categories: fixed point and
floating point.
These designations refer to the format used to store and manipulate
numeric representations of float data.
Fixed-point CPUs are designed to represent and manipulate rational
numbers using integer notation.
Floating-point CPUs represent and manipulate rational numbers in a
manner similar to scientific notation IEEE 754 (Sign, mantissa and an
exponent).
47 MGRJ,ECE,RVCE
The term ‘fixed point’ refers to a fixed number of digits after the
decimal point.
E.g. 123.45, 1234.56, 12345.67(two digits after decimal point)
With ‘floating-point’ representation, the placement of the decimal
point can ‘float’ relative to the significant digits of the number.
E.g.1.234567,123456.7,0.00001234567, 1234567000000000
The floating-point computation assures a much larger dynamic range -
the largest and smallest numbers that can be represented.
Floating-point processing yields much greater precision(accuracy)
than fixed-point processing.
48 MGRJ,ECE,RVCE
Question
The following declarations are appeared in a C program to be executed on floating
point and fixed-point processors.
char cIvalue= ‘a’; unsigned char ucMyvalue= 234;
int iTemp=0x1234; float fSample=0.0004
float fBalance=123.456 double ldTemp=1234.0000678
The floating-point processor is supported with single precision and double precision
accuracy. Similarly, the fixed-point processor is supported with precision of 2
decimal digits after point. Identify the format used to represent the declared
variables by the compiler to execute on fixed point and floating-point processors.
49 MGRJ,ECE,RVCE
Endianness
• Endianness refers to the sequential order in which bytes are arranged into larger
numerical values when stored in memory.
-Wiki
• Little-endian Operation
50 MGRJ,ECE,RVCE
Endianness…
Big-endian Operation
51 MGRJ,ECE,RVCE
8086 Features
16 bit micro processor (ALU is designed to work with 16 bit data).
16 bit data bus.
20 bit address bus, so it can access 220 or 1048576(1 MB) memory
locations of byte wide each. Therefore, a sixteen bit words are stored
in two consecutive memory locations (Von Neumann).
Support memory segmentation
The 8086 has time multiplexed address and data bus which reduces
number of pins required.
52 MGRJ,ECE,RVCE
8086 Features…
The 8086 requires clock with a 33% duty cycle.(no on chip oscillator,
requires clock generator 8284).
clock speed: 5 MHz- 8086
8 MHz - 8086-2
10 MHz – 8086-1
Two modes of operation:
Minimum Mode: CPU is connected to memory and I/O devices.
Maximum Mode: CPU is connected to another processor
(Multiprocessor Mode) in addition to memory and
I/O devices.
53 MGRJ,ECE,RVCE
8086 Features …
The 8086 can generate 16 bit I/O addresses.
The 8086 provides fourteen 16 bit registers (SFR+ GPR)
Micro-programmed control unit.
16-Bit flag register (Control + Status)
6 bytes instruction queue(Pipelining)
Interrupts
- NMI & INTR (Hardware)
- INT instruction(Software)
54 MGRJ,ECE,RVCE
8086 Internal Configuration
55
MGRJ,ECE,RVCE
Architecture of 8086
The 8086 CPU is divided into independent functional parts:
-Bus Interface Unit(BIU)
- Execution Unit(EU)
BIU sends out addresses, fetches instructions from memory,
reads data from ports and memory and writes data to ports and
memory.
58 MGRJ,ECE,RVCE
Architecture of 8086…
The EU tells the BIU where to fetch instructions and data from, decodes
instructions and executes instructions.
Dividing work between these two units, speeds up the execution.
59 MGRJ,ECE,RVCE
8086 Internal Diagram
61 MGRJ,ECE,RVCE
BIU-Instruction Queue…
62 MGRJ,ECE,RVCE
BIU…
Segment Registers
The BIU sends out the 20-bit address, so it can address any location of 1048576
bytes(1 MB).
Memory Segmentation
-At any time, 8086 works with only four segments of 64KB with in 1 MB.
-The 4 segment registers of 16 bits wide in the BIU are used to hold 16 bits
of the starting address of 4 segments.
63 MGRJ,ECE,RVCE
BIU...
Four segment registers:
-Code segment (CS) register for code segment:
Used for program storage(Instruction codes)
- Data Segment (DS) register for data segment:
Used for data storage
- Extra Segment (ES)register for extra segment:
Used for data storage
- Stack Segment (SS) register for stack segment:
Used to store address & data while subprogram executes
64 MGRJ,ECE,RVCE
Memory Segmentation
65 MGRJ,ECE,RVCE
Generation of 20 bit address
The index registers or pointer registers contain displacement or offset, used to
point to a particular location is called offset or effective address.
Index registers/ Pointer registers
IP (Instruction Pointer) for Code segment
SI(source Index) for Data segment(default)
16
DI(Destination Index) for Data Segment (ES for string instruction)
bit
SP(Stack Pointer) for stack segment
BX register for DS(default), CS,ES,SS(Alternate)
BP(Base Pointer) for SS(default), CS,ES,DS(Alternate)
66 MGRJ,ECE,RVCE
20 bit address…
The address put on address bus called as physical address must contain 20 bits.
The physical address is calculated as follows:
67 MGRJ,ECE,RVCE
Advantages of memory segmentation
1. Allow the memory capacity of 1 MB even though index
registers & pointer registers used to access memory are 16 bits
wide.
2. Allow the instruction or data of a program to be more than 64K
bytes long using more than one code and data segment.
3. Facilitate the use of separate memory areas for a program, its
data and the stack.
68 MGRJ,ECE,RVCE
Questions
1. If CS=1000H, IP= 1234H what is effective address & physical address?
2. What is the operation of following instruction? MOV AL,[BP]
3. What is the operation of following instruction? MOV CX, [BX]
4. What is the operation of following instruction? MOV DS:[BP], AL
5. What is synchronous & Asynchronous interrupt?
6. If BX=0adech ,DS= 2000h and SI= 55h, find the effective address and physical
address of the instruction MOV AL,[BX][SI].
7. What is the IO capability of 8086 in IO mapped IO method?
69 MGRJ,ECE,RVCE
Execution Unit(EU)
The EU tells the BIU where to fetch instructions and data from, decodes
instructions & executes instructions.
It contains,
- Control Circuitry
- Instruction decoder
- ALU
-Flags
- General Purpose registers
-Pointers & index registers
71 MGRJ,ECE,RVCE
The STATUS register(Flag register)
Indication/Status Bits
only for status: Bits are set or cleared based on the result
of any Arithmetic or Logic operation.
Control Bits
Used for control: Bits may be affected indirectly (by the execution of an
instruction) or directly by an instruction designed to access the status word
x x x x OF DF IF TF SF ZF x AF x PF x CF
72 MGRJ,ECE,RVCE
The STATUS register(Flag register)
x x x x OF DF IF TF SF ZF x AF x PF x CF
73 MGRJ,ECE,RVCE
Auxiliary Carry Flag(AF): This is set when there is an carry out from lower nibble
to higher nibble (D3 to D4).(used in BCD operations)
Zero Flag(ZF): This flag is set if the result of ALU operation is zero.
Sign Flag(SF): After ALU operation, if the MSB of the result is 1, sign bit is set.
Overflow Flag(OF): If result is out of range.
This bit is set if there is a carry into MSB and no carry out of it or vice versa for
addition.
Subtraction: set to 1 when MSB needs borrow & no borrow from the MSB.
74 MGRJ,ECE,RVCE
Question
Give the contents of flag register after execution of following addition.
65D1H+2359H = 892A H
0110 0101 1101 0001
0010 0011 0101 1001
1000 1001 0010 1010
SF=1,ZF=0,PF=0, CF=0,AF=0,OF=1
75 MGRJ,ECE,RVCE
Control Bits
Trap Flag (TF): Trap flag is used for single stepping.
A system will stop after it executes each instruction and performs
trap interrupt.
Interrupt Flag(IF): If set, maskable interrupts are enabled.
Direction Flag(DF): It used to auto increment/decrement pointers
(DI & SI) made to point to string.
DF=0 =>Increment
DF=1=>Decrement
76 MGRJ,ECE,RVCE
Questions
Differentiate between control bits & status bits of flag register.
What is the importance of overflow flag?
What for segment registers are used?
How 20 bit physical address is generated?
Differentiate between maximum mode & minimum mode.
What is the use .model small directive?
Give an example for an instruction which supports memory to memory
operation.
77 MGRJ,ECE,RVCE
8086 Pin diagram
78 MGRJ,ECE,RVCE
8086 Pin Description
79 MGRJ,ECE,RVCE
Common Pins
GND: Ground(2 pins)
Vcc : Supply voltage of 5 V with ± 10%
AD15-AD0 : Bidirectional in nature, during first part of the bus cycle, processor
outputs address and during later part of the bus cycle, processor reads (input) or
write (output) data.
NMI: Non Maskable Interrupt request pin. It is positive edge triggered.
INTR : Maskable interrupt request. If INTR pin is held active high when IF=1,
8086 enters into interrupt acknowledge cycle(INTA becomes active) after the
current instruction execution completion.
80 MGRJ,ECE,RVCE
Common pins…
CLK : Input Clock frequency
The 8284 clock generator is used to obtain the clock.
- The crystal is connected to 8284 chip, which divides crystal frequency by
three internally.
- Maximum CPU operation
8086 :5 MHz( Crystal frequency:15 MHz)
8086-2 :8 MHz(Crystal Frequency:24 MHz)
8086-1 : 10 MHz (Crystal Frequency: 30 MHz)
RESET: Active high signal, when maintained for atleast 4 clock cycle, reset is
initiated.
- Reset clears PSW(Flag register), IP,DS, SS,ES and instruction queue.
- The CS register set to FFFFh.
- Processing begins at FFFF0H.
81 MGRJ,ECE,RVCE
Common pins…
Tw T3
One wait state
2 wait states Tw T3
83 MGRJ,ECE,RVCE
Common pins…
84 MGRJ,ECE,RVCE
Common pins…
BHE /S7: Byte High Enable, Active low signal
- Used to enable most significant data bus bits (D15- D8) during read or
write operation.
- Generated during first part of the machine cycle(bus cycle).
524KB 524KB
85 MGRJ,ECE,RVCE
BHE & A0 pin together indicate various data transfer as indicated below.
87 MGRJ,ECE,RVCE
Minimum Mode pins
INTA: Acknowledgement given by CPU to interrupt request.
ALE(Address Latch Enable):This shows that the 8086 address/data bus contain
address information.
- The address can be memory address or I/O port address.
DT/R: Data Transmit/Receive signal shows that microprocessor data bus
is transmitting(DT/R=1) or receiving(DT/R=0).
- This signal is used to control direction of data bus buffers.
- This is output signal issued by microprocessor.
WR: Whenever this signal is low it indicates memory or I/O write operation
is to be performed.
88 MGRJ,ECE,RVCE
DEN: The data bus enable is an output signal given by µP, during later part of the
cycle to inform the transceivers that CPU is ready to send or receive data.
M/IO : This pin selects memory or I/O.
HOLD, HLDA
➢when HOLD line goes High – it indicates the processor that another
master(DMA: Direct Memory access) is requesting the bus access.
➢In-turn the processor
➢issues acknowledge on HLDA pin, in the middle of the next clock cycle after
completing the current bus cycle.
➢Processor enters into hold state(releases bus/ not executing) until hold
release signal.
➢ Asynchronous input
89 MGRJ,ECE,RVCE
Maximum mode pins
S2, S1, S0
Indicates the type of operation carried out by the processor.
Becomes active in the previous T4 and remains till T1,T2 of current cycle.
Return to 'Passive State' during T3 – so that they may again become active for the next cycle
during T4.
These output signals are used by 8288 bus controller to generate all memory & IO access
control signals
S2’ S1’ S0’ Indication
0 0 0 Interrupt Acknowledgement
0 0 1 Read I/O port
0 1 0 Write I/O port
0 1 1 Halt
1 0 0 Code Access
1 0 1 Read Memory
1 1 0 Write Memory
1 1 1 Passive (Inactive)
90 MGRJ,ECE,RVCE
LOCK
Prevents the other system bus master from gaining the system bus.
Activated by the 'LOCK' prefix instruction and remains active until the completion
of the next instruction.
QS1, QS0
Queue status – informs the status of the code-pre fetch queue
QS1 QS0 Indication
0 0 No operation
0 1 1st byte of opcode from the queue
1 0 Empty queue
1 1 Subsequent byte of the opcode
91 MGRJ,ECE,RVCE
RQ/GT0, RQ/GT1 (Request/grant)
➢Used by other local bus masters – to force the processor to release the
local bus at the end of the processor's current bus cycle.
➢RQ/GT0 has the highest priority than RQ/GT1
➢These lines are bidirectional and are used to both request and grant a
DMA operation.
92 MGRJ,ECE,RVCE
Questions
93 MGRJ,ECE,RVCE