You are on page 1of 101

15EM2001

COMPUTER ORGANIZATION AND ARCHITECTURE

© 2016 KL University – The contents of this presentation are an intellectual and


1
copyrighted property of KL University. ALL RIGHTS RESERVED
CPU Design

© 2016 KL University – The contents of this presentation are an intellectual and


2
copyrighted property of KL University. ALL RIGHTS RESERVED
Introduction to CPU
The operation or task that must perform by CPU are:
•Fetch Instruction
•Interprete Instruction
•Fetch Data
•Process data
•Write data

© 2016 KL University – The contents of this presentation are an intellectual and


3
copyrighted property of KL University. ALL RIGHTS RESERVED
•The major components of the CPU are an arithmetic and
logic unit (ALU) and a control unit (CU).
•The ALU does the actual computation or processing of
data.
•The CU controls the movement of data and instruction
into and out of the CPU and controls the operation of the
ALU.
© 2016 KL University – The contents of this presentation are an intellectual and
4
copyrighted property of KL University. ALL RIGHTS RESERVED
CPU system Bus
© 2016 KL University – The contents of this presentation are an intellectual and
5
copyrighted property of KL University. ALL RIGHTS RESERVED
CPU System Bus

The system bus may have three components:


1. Data Bus
2. Address Bus
3. Control Bus

© 2016 KL University – The contents of this presentation are an intellectual and


6
copyrighted property of KL University. ALL RIGHTS RESERVED
Internal Structure of the CPU

© 2016 KL University – The contents of this presentation are an intellectual and


7
copyrighted property of KL University. ALL RIGHTS RESERVED
There are three basic components of CPU:
1. Register bank
2. ALU and
3. Control Unit.

•There are several data movements between these units


and for that an internal CPU bus is used.

© 2016 KL University – The contents of this presentation are an intellectual and


8
copyrighted property of KL University. ALL RIGHTS RESERVED
Register Organization
The registers in the CPU can be categorized into two groups:
•User-visible registers
•Control and status registers
User-visible Registers:
•General Purpose Registers
•Data Registers
•Address Registers
•Condition Codes
© 2016 KL University – The contents of this presentation are an intellectual and
9
copyrighted property of KL University. ALL RIGHTS RESERVED
Address registers:

•Segment pointer
•Index registers
•Stack pointer
Four registers are essential to instruction execution:
1. Program Counter (PC)
2. Instruction Register (IR)
3. Memory Address Register (MAR)
4. Memory Buffer Register (MBR)
© 2016 KL University – The contents of this presentation are an intellectual and
10
copyrighted property of KL University. ALL RIGHTS RESERVED
Processor Status
Word
1. Sign
2. Zero
3. Carry
4. Equal
5. Overflow
6. Interrupt enable/disable
7. Supervisor
© 2016 KL University – The contents of this presentation are an intellectual and
11
copyrighted property of KL University. ALL RIGHTS RESERVED
Concept of Program Execution
1. Fetch the contents of the memory location pointed at by the PC. The
contents of this location are interpreted as an instruction to be executed.
Hence, they are stored in the instruction register (IR). Symbolically this can be
written as:

IR = [ [PC] ]

2. Increment the contents of the PC by 1.

PC = [PC] + 1

3. Carry out the actions specified by the instruction stored in the IR.
© 2016 KL University – The contents of this presentation are an intellectual and
12
copyrighted property of KL University. ALL RIGHTS RESERVED
Single bus organization of the data path
inside the CPU

© 2016 KL University – The contents of this presentation are an intellectual and


13
copyrighted property of KL University. ALL RIGHTS RESERVED
The processor interpretes the instruction and performs the
required action. In general, the actions fall into four categories:

•Processor-memory
•Processor-I/O
•Data processing
•Control
© 2016 KL University – The contents of this presentation are an intellectual and
14
copyrighted property of KL University. ALL RIGHTS RESERVED
Instruction cycle

Basic Instruction cycle

© 2016 KL University – The contents of this presentation are an intellectual and


15
copyrighted property of KL University. ALL RIGHTS RESERVED
An instruction cycle consists of two phase,
1. Fetch cycle
2. Execution cycle
Operation of a CPU:

1. Fetch the contents of a given memory location and load them into a CPU
register.

2. Store a word of data from a CPU register into a given memory location.

3. Transfer a word of data from one CPU register to another or to the ALU.

4. Perform an arithmetic or logic operation, and store the result in a CPU register
© 2016 KL University – The contents of this presentation are an intellectual and
16
copyrighted property of KL University. ALL RIGHTS RESERVED
8086 ARCHITECTURE

© 2016 KL University – The contents of this presentation are an intellectual and


17
copyrighted property of KL University. ALL RIGHTS RESERVED
Addressing Modes
The most common addressing techniques are:
• Immediate
• Direct
• Indirect
• Register
• Register Indirect
• Displacement
• Stack
© 2016 KL University – The contents of this presentation are an intellectual and
18
copyrighted property of KL University. ALL RIGHTS RESERVED
To explain the addressing modes, the following notationis used:

A = contents of an address field in the instruction that refers to a


memory

R = contents of an address field in the instruction that refers to a


register

EA = actual (effective) address of the location containing the referenced


operand

(X) = contents of location X

© 2016 KL University – The contents of this presentation are an intellectual and


19
copyrighted property of KL University. ALL RIGHTS RESERVED
Immediate Addressing

The simplest form of addressing is immediate addressing

OPERAND = A

Instruction
Opcode Operand

© 2016 KL University – The contents of this presentation are an intellectual and


20
copyrighted property of KL University. ALL RIGHTS RESERVED
Direct Addressing

Address field contains address of operand


Effective address (EA) = address field (A)


e.g. ADD A

Add contents of cell A to accumulator


Look in memory at address A for operand


Single memory reference to access data


No additional calculations to work out effective address


Limited address space

© 2016 KL University – The contents of this presentation are an intellectual and


21
copyrighted property of KL University. ALL RIGHTS RESERVED
Direct Addressing Diagram

Instruction

Address A
Memory

Operand

© 2016 KL University – The contents of this presentation are an intellectual and


22
copyrighted property of KL University. ALL RIGHTS RESERVED
Indirect Addressing

Memory cell pointed to by address field contains the address


of (pointer to) the operand

EA = (A)
Look in A, find address (A) and look there for operand

e.g. ADD (A)


Add contents of cell pointed to by contents of A to accumulator

© 2016 KL University – The contents of this presentation are an intellectual and


23
copyrighted property of KL University. ALL RIGHTS RESERVED
Indirect Addressing Diagram
Instruction

Address A
Memory

Pointer to operand

Operand

© 2016 KL University – The contents of this presentation are an intellectual and


24
copyrighted property of KL University. ALL RIGHTS RESERVED
Register Addressing

Operand is held in register named in address filed


EA = R

Limited number of registers


Very small address field needed


Shorter instructions

Faster instruction fetch


© 2016 KL University – The contents of this presentation are an intellectual and


25
copyrighted property of KL University. ALL RIGHTS RESERVED
Register Addressing

No memory access

Very fast execution


Very limited address space


Multiple registers helps performance


Requires good assembly programming or compiler writing

Direct addressing

© 2016 KL University – The contents of this presentation are an intellectual and


26
copyrighted property of KL University. ALL RIGHTS RESERVED
Register Addressing Diagram
Instruction

Register Address R
Registers

Operand

© 2016 KL University – The contents of this presentation are an intellectual and


27
copyrighted property of KL University. ALL RIGHTS RESERVED
Register Indirect Addressing

Indirect addressing

EA = (R)

Operand is in memory cell pointed to by contents of register


R

Large address space (2n)


One fewer memory access than indirect addressing

© 2016 KL University – The contents of this presentation are an intellectual and


28
copyrighted property of KL University. ALL RIGHTS RESERVED
Register Indirect Addressing

Instruction

Opcode Register Address R


Memory

Registers

Pointer to Operand Operand

© 2016 KL University – The contents of this presentation are an intellectual and


29
copyrighted property of KL University. ALL RIGHTS RESERVED
Displacement Addressing

EA = A + (R)

Address field hold two values


A = base value

R = register that holds displacement


or vice versa

© 2016 KL University – The contents of this presentation are an intellectual and


30
copyrighted property of KL University. ALL RIGHTS RESERVED
Displacement Addressing Diagram

© 2016 KL University – The contents of this presentation are an intellectual and


31
copyrighted property of KL University. ALL RIGHTS RESERVED
Displacement Addressing

Relative Addressing

Base-Register Addressing

Indexing
auto-indexing

auto-incrementing

EA = A + (R)

R = (R) + 1

© 2016 KL University – The contents of this presentation are an intellectual and


32
copyrighted property of KL University. ALL RIGHTS RESERVED
Displacement Addressing
auto-decrementing

EA = A + (R)

R = (R) – 1

If indexing is performed after the indirection, it is termed


postindexing
EA = (A) + (R)

With preindexing, the indexing is performed before the


indirection:
EA = ( A + (R) )

© 2016 KL University – The contents of this presentation are an intellectual and


33
copyrighted property of KL University. ALL RIGHTS RESERVED
Stack Addressing

Operand is (implicitly) on top of stack


e.g.
ADD Pop top two items from stack and add

© 2016 KL University – The contents of this presentation are an intellectual and


34
copyrighted property of KL University. ALL RIGHTS RESERVED
Instruction Set

The operation of a CPU is determine by the instruction it


executes, referred to as machine instructions or computer
instructions. The collection of different instructions is referred
as the instruction set of the CPU.

Each instruction must contain the information required by the


CPU for execution.

© 2016 KL University – The contents of this presentation are an intellectual and


35
copyrighted property of KL University. ALL RIGHTS RESERVED
Opcodes are represented by abbreviations, called
mnemonics, that indicate the operations

4-bits 6-bits 6-bits

Opcode Operand1 Operand2

A simple instruction format

© 2016 KL University – The contents of this presentation are an intellectual and


36
copyrighted property of KL University. ALL RIGHTS RESERVED
The instruction set of a CPU can be categorized as follows:
1. Data Processing
2. Data Storage
3. Data Movement
4. Control
Types of Operands
1. Addresses
2. Numbers
3. Characters
4. Logical Data
© 2016 KL University – The contents of this presentation are an intellectual and
37
copyrighted property of KL University. ALL RIGHTS RESERVED
Types of Operations

Data Transfer

Arithmetic

Logical

Conversion

Input Output [ I/O ]


System Control

Transfer Control

© 2016 KL University – The contents of this presentation are an intellectual and


38
copyrighted property of KL University. ALL RIGHTS RESERVED
A. Data Transfer
Move (Transfer) --------Transfer word or block from source to destination

Store ----------------------Transfer word from processor to memory

Load (fetch) -------------Transfer word from memory to processor

Exchange ----------------Swap contents of source and destination

Clear (reset)------------- Transfer word of 0s to destination

Set -------------------------Transfer word of 1s to destination

Push -----------------------Transfer word from source to top of stack

© 2016Pop -------------------------Transfer
KL University word fromaretop
– The contents of this presentation an of stack toand
intellectual destination
39
copyrighted property of KL University. ALL RIGHTS RESERVED
B. Arithmetic
Add --------------Compute sum of two operands

Subtract --------Compute difference of two operands

Multiply ---------Compute product of two operands

Divide -----------Compute quotient of two operands

Absolute --------Replace operand by its absolute value

Negate ----------Change sign of operand

Increment ------Add 1 to operand

Decrement -----Subtract 1 from operand


© 2016 KL University – The contents of this presentation are an intellectual and
40
copyrighted property of KL University. ALL RIGHTS RESERVED
C. Logical
AND -----------------------Performs the logical operation AND bitwise
OR--------------------------Performs the logical operation OR bitwise
NOT -----------------------Performs the logical operation NOT bitwise
Exclusive OR -------------Performs the specified logical operation Exclusive-OR
bitwise
Test --------------------------Test specified condition; set flag(s) based on outcome
Compare -------------------Make logical or arithmetic comparison Set flag(s)
based on outcome
Set Control Variables------Class of instructions to set controls for protection
purposes, interrupt handling, timer control etc.
Shift -----------------------Left (right) shift operand, introducing constant at end
Rotate --------------------Left (right) shift operation, with wraparound end

© 2016 KL University – The contents of this presentation are an intellectual and


41
copyrighted property of KL University. ALL RIGHTS RESERVED
D. Input/output
Input (Read)----- Transfer data from specified I/O port or device to
destination (e.g., main memory or processor register)

Output (Write)----Transfer data from specified source to I/O port or


device.

Start I/O------------ Transfer instructions to I/O processor to initiate


I/O operation.

Test I/O --------------Transfer status information from I/O system to


specified destination
© 2016 KL University – The contents of this presentation are an intellectual and
42
copyrighted property of KL University. ALL RIGHTS RESERVED
E. System Control

System control instructions are those which are


used for system setting and it can be used only in
privileged state.

Typically, these instructions are reserved for the


use of operating systems.

© 2016 KL University – The contents of this presentation are an intellectual and


43
copyrighted property of KL University. ALL RIGHTS RESERVED
F. Transfer of Control

The most common transfer-of-control operations


found in instruction set are:

Branch

Skip

Procedure call.
© 2016 KL University – The contents of this presentation are an intellectual and
44
copyrighted property of KL University. ALL RIGHTS RESERVED
BRP X ----Branch to location X if result is positive
BRN X ---- Branch to location X if result is negative
BRZ X----- Branch to location X is result is zero
BRO X----- Branch to location X if overflow occurs

© 2016 KL University – The contents of this presentation are an intellectual and


45
copyrighted property of KL University. ALL RIGHTS RESERVED
Instruction Format
Opcode Zero Address Instruction

Opcode Address One Address Instruction

Opcode Address1 Address2 Two Address Instruction

Opcode Address1 Address2 Address3


Three Address Instruction
Example: X = (A + B) * (C + D)
© 2016 KL University – The contents of this presentation are an intellectual and
46
copyrighted property of KL University. ALL RIGHTS RESERVED
Three address instructions
ADD R1 , A , B R 1 <--M [ A ] + M [ B ]
ADD R2 , C , D R 2 <--M [ C ] + M [ D ]
MUL X , R1 , R2 M [ X ] <--R 1 * R 2
Two address instructions
MOV R1 , A R 1 <--M [ A ]
ADD R1 , B R 1 <--R 1 + M [ B ]
MOV R2 , C R 2 <--M [ C ]
ADD R2 , D R 2 <--R 2 + M [ D ]
MUL R1 , R2 R 1 <--R 1 * R 2
MOV X , R1 M [ X ] <--R 1
© 2016 KL University – The contents of this presentation are an intellectual and
47
copyrighted property of KL University. ALL RIGHTS RESERVED
One address instructions
LOAD A A C <- M [ A J
ADD B A C <- A C + M [ B ]
STORE T M [ T ] <- A C
LOAD C A C <- M [ C ]
ADD D A C <- A C + M [ D ]
MUL T A C <- A C • M [ T ]
STORE X M [ X ] <- A C

© 2016 KL University – The contents of this presentation are an intellectual and


48
copyrighted property of KL University. ALL RIGHTS RESERVED
Zero address instructions

© 2016 KL University – The contents of this presentation are an intellectual and


49
copyrighted property of KL University. ALL RIGHTS RESERVED
Stack Organization

Block diagram of 64- word stack

© 2016 KL University – The contents of this presentation are an intellectual and


50
copyrighted property of KL University. ALL RIGHTS RESERVED
Subroutine Calls
Requirements
Set PC to arbitrary address

Return PC to instruction after call sequence

Handle nested subroutine calls

Save and restore caller’s registers

Pass an arbitrary number of arguments

Pass and return structures

© 2016 KLAllocate
Universityand de-allocate
– The contents of space for localare
this presentation variables
an intellectual and
51
copyrighted property of KL University. ALL RIGHTS RESERVED
© 2016 KL University – The contents of this presentation are an intellectual and
52
copyrighted property of KL University. ALL RIGHTS RESERVED
Common Micro-Ops
There are 4 types of Micro-Ops:

Transfer: transfers data from one register to another


R0 <- R1

Arithmetic: performs arithmetic on data in registers


R0 <- R1 + R2

Logic/bit manipulation: performs bit (Boolean) operations on data


R0 <- R1 & R2 ; or R0 <- R1 | R2

Shif: shift data in registers by one or more bit positions


R0 <- R1 << 3; or R0 <- R2 >> 2

© 2016 KL University – The contents of this presentation are an intellectual and


53
copyrighted property of KL University. ALL RIGHTS RESERVED
Micro-Ops Transfer
Parallel
Parallel transfer is typically used

for transfers between registers


Ex: Transfer all contents of A

into B on one clock pulse


A <- B
Control function: we can do this

by structuring the RTL expression to


indicate the controlling condition
Ex: P: A<- B

© 2016 KL University – The contents of this presentation are an intellectual and


54
copyrighted property of KL University. ALL RIGHTS RESERVED
Micro-Ops Transfer
Serial 

Serial transfer is used to specify


that a collection of bits are to be
moved, but that the transfer is to
occur one bit at a time

Ex: S: A <- B, B <-B

© 2016 KL University – The contents of this presentation are an intellectual and


55
copyrighted property of KL University. ALL RIGHTS RESERVED
Micro-Ops Transfer
Bus
A bus consists of a set of parallel data lines

To transfer data using a bus: connect the output of the source register to the bus; connect

the input of the target register to the bus; when the clock pulse arrives, the transfer occurs

© 2016 KL University – The contents of this presentation are an intellectual and


56
copyrighted property of KL University. ALL RIGHTS RESERVED
Micro-Ops Transfer
Memory
Memory transfers are similar to register transfers, but…

Memory to register transfers are called read operations, while


register to memory transfers are called write operations


RTL expressions for a read operation, assuming the use of an address registers:

AR <- address
DR <- M[AR]
RTL expressions for a write operation, assuming use of a data register:

AR <- address
DR <- value
M[AR] <- DR

© 2016 KL University – The contents of this presentation are an intellectual and


57
copyrighted property of KL University. ALL RIGHTS RESERVED
MAPPING OF INSTRUCTIONS
Direct Mapping Address
OP-codes of Instructions 0000 ADD Routine
0001 AND Routine
ADD 0000 LDA Routine
. 0010
AND 0001 STA Routine
. 0011
LDA 0010 . 0100 BUN Routine
STA 0011 Control
BUN 0100 Storage
Mapping
10 xxxx 010
Bits Address
10 0000 010 ADD Routine

10 0001 010 AND Routine


10 0010 010 LDA Routine

10 0011 010 STA Routine


10 0100 010 BUN Routine

© 2016 KL University – The contents of this presentation are an intellectual and 58


copyrighted property of KL University. ALL RIGHTS RESERVED
MACHINE INSTRUCTION FORMAT
Machine instruction format
15 14 11 10 0
I Opcode Address

Micro-instruction Format
3 3 3 2 2 7
F1 F2 F3 CD BR AD
F1, F2, F3: Microoperation fields
CD: Condition for branching
BR: Branch field
AD: Address field
© 2016 KL University – The contents of this presentation are an intellectual and
59
copyrighted property of KL University. ALL RIGHTS RESERVED
Sample machine instructions
Symbol Opcode Description

ADD 0000 AC AC + M[EA]

BRANCH 0001 if (AC < 0) then (PC  EA)

STORE 0010 M[EA]  AC

EXCHANGE 0011 AC M[EA], M[EA]  AC

EA is the effective address

© 2016 KL University – The contents of this presentation are an intellectual and


60
copyrighted property of KL University. ALL RIGHTS RESERVED
MICROINSTRUCTION FIELD DESCRIPTIONS
- F1,F2,F3
F1 Micro Symbol F2 Micro Symbol F3 Micro Symbol
operation operation operation
000 None NOP 000 None NOP 000 None NOP

001 AC  AC + DR ADD 001 AC  AC - DR SUB 001 AC  AC XOR


DR

010 AC  0 CLRAC 010 AC  AC  DR OR 010 AC  AC' COM


011 AC  AC + 1 INCAC 011 AC  AC  DR AND 011 AC  shL AC SHL
100 AC  DR DRTAC 100 DR  M[AR] READ 100 AC  shr AC SHR
101 AR  DR(0-10) DRTAR 101 DR  AC ACTDR 101 PC  PC + 1 INCPC
110 AR  PC PCTAR 110 DR  DR + 1 INCDR 110 PC  AR ARTPC
111 M[AR]  DR WRITE 111 DR(0-10)  PC PCTDR 111 RESERVED

© 2016 KL University – The contents of this presentation are an intellectual and


61
copyrighted property of KL University. ALL RIGHTS RESERVED
MICROINSTRUCTION FIELD DESCRIPTIONS - CD, BR
CD Condition Symbol Comments
00 Always = 1 U Unconditional branch
01 DR(15) I Indirect address bit

10 AC(15) S Sign bit of AC

11 AC = 0 Z Zero value in AC

BR Symbol Function
00 JMP CAR  AD if condition = 1
CAR  CAR + 1 if condition = 0
01 CALL CAR  AD, SBR  CAR + 1 if condition = 1
CAR  CAR + 1 if condition = 0
10 RET CAR  SBR (Return from subroutine)
11 MAP CAR(2-5)  DR(11-14), CAR(0,1,6)  0
© 2016 KL University – The contents of this presentation are an intellectual and
62
copyrighted property of KL University. ALL RIGHTS RESERVED
DESIGN OF CONTROL UNIT
DECODING ALU CONTROL INFORMATION -

microoperation fields
F1 F2 F3

3 x 8 decoder 3 x 8 decoder 3 x 8 decoder


7 6 54 3 21 0 7 6 54 3 21 0 7 6 54 3 21 0

AND
ADD Arithmetic AC
DRTAC logic and
shift unit DR
PCTAR

DRTAR

From From
PC DR(0-10) Load
AC
Select 0 1
Multiplexers

Load AR Clock

Decoding of Microoperation Fields


© 2016 KL University – The contents of this presentation are an intellectual and
63
copyrighted property of KL University. ALL RIGHTS RESERVED
Memory
1. Concept of Memory.
2. Cache Memory.
3. Memory Management
4. Virtual memory
The memory of computer is broadly categories into
two categories:

•Internal Memory or Primary Memory

• External Memory or Secondary Memory


© 2016 KL University – The contents of this presentation are an intellectual and
64
copyrighted property of KL University. ALL RIGHTS RESERVED
Primary Memory

RAM: Random Access Memories are volatile in nature. As


soon as the computer is switched off, the contents of
memory are also lost.

Types: SRAM, DRAM

ROM: Read only memories are non volatile in nature. The


storage is permanent, but it is read only memory. We can not
store new information in ROM.

Types: PROM, EPROM, EEPROM, UVPROM

© 2016 KL University – The contents of this presentation are an intellectual and


65
copyrighted property of KL University. ALL RIGHTS RESERVED
Main Memory Organization

16X4 Means 16 Locations & 4 bits in each Location

Read – Retrieve data from memory to CPU registers


Write – Store data to memory from CPU registers

To transfer data we require data bus

To specify or to identify a particular memory location we require


address bus

© 2016 KL University – The contents of this presentation are an intellectual and


66
copyrighted property of KL University. ALL RIGHTS RESERVED
Semiconductor Memory Classification

Non-Volatile
Read-Write Memory Read-Write Read-Only Memory
Memory

Random Non-Random EPROM Mask-Programmed


Access Access
2
E PROM Programmable (PROM)

SRAM FIFO FLASH

DRAM LIFO
Shift Register
Content
Addressable
Memory (CAM)

© 2016 KL University – The contents of this presentation are an intellectual and


67
copyrighted property of KL University. ALL RIGHTS RESERVED
RAM

Random write and read operation for any cell


Volatile data

Most of computer memory


DRAM

Low Cost

High Density

Medium Speed

SRAM

High Speed

Ease of use

Medium Cost
© 2016 KL University – The contents of this presentation are an intellectual and
68
copyrighted property of KL University. ALL RIGHTS RESERVED
ROM

Non-volatile Data

Method of Data Writing


Mask ROM
Data written during chip fabrication

PROM
Fuse ROM: Non-rewritable

EPROM:

Erase data by UV rays


EEPROM: Erase and write through electrical means

Speed 2-3 times slower than RAM


Upper limit on write operations


Flash Memory – High density, Low Cost

© 2016 KL University – The contents of this presentation are an intellectual and


69
copyrighted property of KL University. ALL RIGHTS RESERVED
FLASH

Extension of EEPROM

Same floating gate principle


Same write ability and storage permanence


Fast erase

Large blocks of memory erased at once, rather than one word at a time

Blocks typically several thousand bytes large


Writes to single words may be slower


Entire block must be read, word updated, then entire block written back

Used with embedded microcomputer systems storing large data items in nonvolatile
memory

e.g., digital cameras, MP3, cell phones

© 2016 KL University – The contents of this presentation are an intellectual and


70
copyrighted property of KL University. ALL RIGHTS RESERVED
CPU and Memory

CPU can interact with main memory in two ways:


•It can write a byte/word to a given memory location.
•The previous bits that were in that location are destroyed
•The new bits are saved for future use.
•It can read a byte/word from a given memory location.
•The CPU copies the bits stored at that location and stores them in a CPU register
•The contents of the memory location are NOT changed.

© 2016 KL University – The contents of this presentation are an intellectual and


71
copyrighted property of KL University. ALL RIGHTS RESERVED
Main Memory Characteristics

Very closely connected to the CPU.


Contents are quickly and easily changed.


Holds the programs and data that the processor is actively working
with.

Interacts with the processor millions of times per second.


Nothing permanent is kept in main memory.

© 2016 KL University – The contents of this presentation are an intellectual and


72
copyrighted property of KL University. ALL RIGHTS RESERVED
Secondary Storage Characteristics

Connected to main memory through a bus and a device controller.


Contents are easily changed, but access is very slow compared to


main memory.

Only occasionally interacts with CPU.


Used for long-term storage of programs and data.


Much larger than main memory (GBs vs. MBs).

© 2016 KL University – The contents of this presentation are an intellectual and


73
copyrighted property of KL University. ALL RIGHTS RESERVED

CPU --- Memory Hi Lo


16-bit CPU Byte Organized

Data Size Lower order byte


first or little endian
15-8 7-0 Hi CPU
Lo

Higher order byte


first or Big endian
Lo CPU
Hi

© 2016 KL University – The contents of this presentation are an intellectual and


74
copyrighted property of KL University. ALL RIGHTS RESERVED
The data transfer between main memory and the CPU takes place
through two CPU registers.

MAR : Memory Address Register

MDR : Memory Data Register.

If the MAR is k-bit long, then the total addressable memory


location will be 2k.

If the MDR is n-bit long, then the n bit of data is transferred in one
memory cycle.

© 2016 KL University – The contents of this presentation are an intellectual and


75
copyrighted property of KL University. ALL RIGHTS RESERVED
Binary Storage Cell

© 2016 KL University – The contents of this presentation are an intellectual and


76
copyrighted property of KL University. ALL RIGHTS RESERVED
Depending on the technology used to construct a RAM,
there are two types of RAM –

SRAM: Static Random Access Memory.

DRAM: Dynamic Random Access Memory

SRAM
© 2016 KL University – The contents of this presentation are an intellectual and
77
copyrighted property of KL University. ALL RIGHTS RESERVED
DRAM
SRAM & DRAM both are volatile

DRAM packing density is more & Less expensive

DRAM requires supporting refresh circuitry

SRAM is faster than DRAM


© 2016 KL University – The contents of this presentation are an intellectual and
78
copyrighted property of KL University. ALL RIGHTS RESERVED
© 2016 KL University – The contents of this presentation are an intellectual and
79
copyrighted property of KL University. ALL RIGHTS RESERVED
© 2016 KL University – The contents of this presentation are an intellectual and
80
copyrighted property of KL University. ALL RIGHTS RESERVED
Memory Management

Five State Process Model


© 2016 KL University – The contents of this presentation are an intellectual and
81
copyrighted property of KL University. ALL RIGHTS RESERVED
Memory Management
1. Uni- Program
2. Multi –Program Memory

Operating System
Uni-Program:

Memory split into two User Program


1. For operating system
2. For currently executing program

Uni-Program
© 2016 KL University – The contents of this presentation are an intellectual and
82
copyrighted property of KL University. ALL RIGHTS RESERVED
Memory Management
Memory
Multi-Program:
Operating System

Memory split into multiple


User Program 1
1. For operating system
User Program 2
2. User part of memory is subdivided to ac
commodate multiple processes. User Program 3

Multi-Program

© 2016 KL University – The contents of this presentation are an intellectual and


83
copyrighted property of KL University. ALL RIGHTS RESERVED
Partitioni
ng
1) Fixed size partitions
2) Variable size partitions

© 2016 KL University – The contents of this presentation are an intellectual and


84
copyrighted property of KL University. ALL RIGHTS RESERVED
Paging

The memory is partitioned into equal fixed size chunks that are relatively
small. This chunk of memory is known as frames or page frames.

Each process is also divided into small fixed chunks of same size. The
chunks of a program is known as pages.

At a given point of time some of the frames in memory are in use and some
are free. The list of free frame is maintained by the operating system.

© 2016 KL University – The contents of this presentation are an intellectual and


85
copyrighted property of KL University. ALL RIGHTS RESERVED
© 2016 KL University – The contents of this presentation are an intellectual and
86
copyrighted property of KL University. ALL RIGHTS RESERVED
© 2016 KL University – The contents of this presentation are an intellectual and
87
copyrighted property of KL University. ALL RIGHTS RESERVED
Cache Memory
It is the fact that CPU is a faster device and memory is a relatively
slower device.

Memory access is the main bottleneck for the performance efficiency. If


a faster memory device can be inserted between main memory and
CPU, the efficiency can be increased.

The faster memory that is inserted between CPU and Main Memory is
termed as Cache memory.

© 2016 KL University – The contents of this presentation are an intellectual and


88
copyrighted property of KL University. ALL RIGHTS RESERVED
Cache Memory

High speed (towards CPU speed)


Small size (power & cost)


Miss

Main
CPU Memory
Cache (Slow)
(Fast)  Mem
Hit Cache

95% hit ratio


 Access = 0.95
© 2016 KL University – The contents  Cache + 0.05
of this presentation 
are anMem
intellectual and
89
copyrighted property of KL University. ALL RIGHTS RESERVED
Cache Memory

CPU 30-bit Address


Main
Memory
Cache
1 Gword
1 Mword

Only 20 bits !!!

© 2016 KL University – The contents of this presentation are an intellectual and


90
copyrighted property of KL University. ALL RIGHTS RESERVED
Cache Mapping

1. Direct mapping

2. Associative mapping

3. Block-set-associative mapping

© 2016 KL University – The contents of this presentation are an intellectual and


91
copyrighted property of KL University. ALL RIGHTS RESERVED
Direct Mapping

A particular block of main


memory can be brought to a
particular block of cache
memory.

It is not flexible

© 2016 KL University – The contents of this presentation are an intellectual and


92
copyrighted property of KL University. ALL RIGHTS RESERVED
Associative Mapping

In this mapping function, any


block of Main memory can
potentially reside in any cache
block position.

This is much more flexible


mapping method.

© 2016 KL University – The contents of this presentation are an intellectual and


93
copyrighted property of KL University. ALL RIGHTS RESERVED
Block Set Associative Mapping

In this method, blocks


of cache are grouped
into sets, and the
mapping allows a block
of main memory to
reside in any block of a
specific set. From the
flexibility point of view,
it is in between to the
other two methods

© 2016 KL University – The contents of this presentation are an intellectual and


94
copyrighted property of KL University. ALL RIGHTS RESERVED
Cache Replacement Policies

1. Least Recently Used (LRU) replacement policy

2. First In First Out (FIFO) replacement policy

3. Random replacement policy

© 2016 KL University – The contents of this presentation are an intellectual and


95
copyrighted property of KL University. ALL RIGHTS RESERVED
Virtual Memory
The virtual address space is used to develop a process. The special hardware unit , called
Memory Management Unit (MMU) translates virtual address to physical address. When
the desired data is in the main memory, the CPU can work with these data. If the data are
not in the main memory, the MMU causes the operating system to bring into the memory
from the disk.

© 2016 KL University – The contents of this presentation are an intellectual and


96
copyrighted property of KL University. ALL RIGHTS RESERVED
VIRTUAL MEMORY

Relation between memory space and address in a virtual memory system


© 2016 KL University – The contents of this presentation are an intellectual and
97
copyrighted property of KL University. ALL RIGHTS RESERVED
Memory table for mapping a virtual address

© 2016 KL University – The contents of this presentation are an intellectual and


98
copyrighted property of KL University. ALL RIGHTS RESERVED
Address space and memory space split into groups of lK words.
© 2016 KL University – The contents of this presentation are an intellectual and
99
copyrighted property of KL University. ALL RIGHTS RESERVED
Memory Table in a paged system
© 2016 KL University – The contents of this presentation are an intellectual and
100
copyrighted property of KL University. ALL RIGHTS RESERVED
An associative memory page table.
© 2016 KL University – The contents of this presentation are an intellectual and
101
copyrighted property of KL University. ALL RIGHTS RESERVED

You might also like