0% found this document useful (0 votes)
42 views52 pages

Chapter 3 - CPU and Memory v2 Latest

Uploaded by

hafizul aliff
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views52 pages

Chapter 3 - CPU and Memory v2 Latest

Uploaded by

hafizul aliff
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 52

CHAPTER 3:

CPU and
Memory
1
Objectiv
es:
To discuss the principal features of a CPU:
 The basic architecture of the CPU
 Register concept
 Instruction formats
 Addressing memory
 Fetch-execute cycle

7-2
Central processing unit
(CPU)
component of a computer's central processing
unit (CPU). It's responsible for managing and
coordinating all activities within the processor.

fundamental component in all computers that


performs arithmetic and logic operations.

The primary function of memory is to store


data.
A memory or storage unit in a computer is an
electronic device that stores data, programs,
and other information.

What are two main types of memory?

7-3
Central processing unit (CPU)
Control Unit (CU)
 A control unit (CU) is a component of a computer's central
processing unit (CPU).

 It controls the operation of the processor.

 The CU directs the computer's memory, arithmetic/logic


unit, and input and output devices on how to respond to a
program's instructions.

 The CU is considered the "brain" of the CPU. It ensures


the efficient operation of the computer system.
Control Unit
(CU)

7-6
Control Unit (CU)
The CU's main functions include:
 Interpreting and executing instructions
The CU retrieves instructions from memory, decodes them, and directs the CPU
to execute them

 Controlling data flow


The CU manages the flow of data within the CPU and between the CPU and
other components

 Handling input and output


The CU handles all input and output to and from the processor

 Regulating timing
The CU controls and regulates timing

 Sending and receiving control signals


The CU sends and receives control signals from other devices
Regist
er
A register is a type of computer memory that stores, accepts,
transfers, and manipulates data and instructions. Registers are built
into the CPU.

Registers are used to:


 Store small amounts of data needed during processing
 Provide faster access to data, instructions, and addresses
 Handle storing and retrieving variables accessed repeatedly
 Enhance program performance
 Optimize memory utilization while executing a program
Regist
er
Registers can hold:
 Instructions
 Storage addresses
 Bit sequences
 Individual characters

Registers have three important functions:


 Fetching
 Decoding
 Execution
Regist
er
Different Classes of CPU Registers

Memory Address Register (MAR) and the Memory Data


Register (MDR) are two different registers.

7-7
Regist
er
Different Classes of CPU Registers

7-7
There are 8 registers in the CPU, which are
designated by their numbers 0-7.
(Give example of 8 types of registers)
Purpose of
Registers
1) General Purpose
Registers
a.k.a User-visible registers
◦Hold intermediate results or data values, e.g., loop counters
◦Equivalent to LMC’s calculator
◦Typically, several dozen in current CPUs

7-
2) Special-Purpose
Registers
Program Count Register (PC)
◦Also called instruction pointer
◦Holds the address of the current instruction being executed
Instruction Register (IR)
◦Holds actual instruction being executed currently by the computer
Memory Address Register (MAR)
◦Holds address of memory location
Memory Data Register (MDR)
◦Holds data being stored or retrieved from the memory
location currently addressed by the MAR
Status Registers
◦Status of CPU and currently executing program
◦ Flags (one-bit Boolean variable) to track condition like arithmetic carry
and overflow, power failure, internal computer error

7-
Arithmetic Logic Unit
 (ALU)
Processing unit is hardware that  The size of input quantities of ALU is
implements Arithmetic and Logical often referred to as word length of
Operations. the computer.

 ALU stands for Arithmetic and Logic Unit,  Many processors today have word
capable of performing length of 32 and 64 bit.

 ADD, SUBTRACT, AND, OR, and NOT  Processing unit also includes a set of
 operations. registers for temporary storage of
data and memory addressing.

7-16
Memory
 Memory is a fundamental component of the computer
that is categorized into primary and secondary memory.

 Primary memory is the main memory of the computer


which can be directly accessed by the central
processing unit

 secondary memory refers to the external storage device


which can be used to store data or information
permanently.
Memory
types
Memory is primarily of three
types :

•3) Secondary
Memory or
magnetic disks or
1) Cache Memory
solid-state storage.
2) Primary Memory/Main
Memory

7-
What are the main functions of main
memory and secondary memory?
In terms of:
 Storage
 Access
 Speed
 Cost
 Capacity
What are examples of primary memory
and secondary memory?
Memory Partitioning
What is the difference between dynamic
and variable partitioning of the memory?
Memory

location
Memory management in an OS is the process of allocating memory
locations.

 Memory is usually divided into two partitions:


a) operating system
b) user processes.

 The operating system is usually allocated space first, usually at either


low or high memory locations. The remaining available memory is
allocated to processes as needed.

7-18
Memory
location
Some memory locations in an operating system include:
 RAM:
Provides space for user programs, the system stack, and visual monitor
data storage.

 I/O facilities:
Assigned an area of memory in a memory mapped system.

 Logical address:
Generated by CPU in perspective of a program.

 Physical address:
A location that exists in the memory unit.

7-18
Memory
location There are two key operations in memory:

 fetch( address ) returns value without


changing the value stored at that
address.

 store( address, value ) writes new


value into the cell at the given
address.

Such memories are called RAM (random-


access memory.)

Some memory is non-volatile or read-


only (ROM or read-only memory.)

7-18
Virtual Memory (VM)
 Virtual memory provides virtual address mapping
between applications and hardware memory.

 It provides many functions, including multitasking,


allowing multiple processes to access the same shared
library in memory, swapping, and other functions.

 Virtual memory uses both hardware and software to


enable a computer to compensate for physical memory
shortages, temporarily transferring data from random
access memory (RAM) to disk storage.
Diagram showing virtual memory that is larger Transfer of a paged memory to
than physical memory contiguous disk space

https://www.cs.uic.edu/~jbell/CourseNotes/OperatingSystems/9_VirtualMemory.html
Understanding MAR
and MDR
MAR stands for memory address
register:

• MAR is connected to the address


bus.
• MAR is "the only way" for the CPU
to communicate with address bus.
• Tri-state buffer between MAR and
the address bus prevents MAR from
continuously dumping its output to
the address bus.
• MAR can hold either an instruction
address or a data address.

7-19
Understanding MAR
and MDR
•MDR Stands memory data register.
for
• MDR is connected to the data bus.
• Data can go in both directions: to and
from memory,
• therefore, MDR can load its data
from
• the data bus (for reading data)
• one of the CPU registers (for
storing data.)
• A 2-1 MUX circuit selects input from
one of the two.

7-20
RAM: Random Access
Memory
RAM (Random Access Memory)
 is the internal memory of the CPU for storing data, program, and program
result. It is a read/write memory which stores data until the machine is
working. As soon as the machine is switched off, data is erased.

RAM is volatile, i.e. data stored in it is lost when we switch off the computer or
if there is a power failure. Hence, a backup Uninterruptible Power System (UPS)
is often used with computers. RAM is small, both in terms of its physical size and
in the amount of data it can hold.

RAM is of two types :

 Static RAM (SRAM)


 Dynamic RAM (DRAM)

7-23
RAM: Random Access
Memory
Static RAM (SRAM)
The word static indicates that the memory retains its contents as long as power
is being supplied. However, data is lost when the power gets down due to
volatile nature. SRAM chips use a matrix of 6-transistors and no capacitors.

Dynamic RAM (DRAM)


DRAM, unlike SRAM, must be continually refreshed in order to maintain the
data. This is done by placing the memory on a refresh circuit that rewrites the
data several hundred times per second. DRAM is used for most system
memory as it is cheap and small. All DRAMs are made up of memory cells,
which are composed of one capacitor and one transistor.

7-24
ROM: Read Only
Memory
 The memory from which we can only read but cannot write on it. This type
of memory is non-volatile.
 The information is stored permanently in such memories during
manufacture. A ROM stores such instructions that are required to start a
computer.
 This operation is referred to as bootstrap.
 ROM chips are not only used in the computer but also in other electronic
items like washing machine and microwave oven.

7-25
ROM: Read Only
Memory
Types of ROMs and their characteristics.

 MROM (Masked ROM)


The very first ROMs were hard-wired devices that contained a pre-programmed
set of data or instructions. These kind of ROMs are known as masked ROMs, which
are inexpensive.

 PROM (Programmable Read Only Memory)


PROM is read-only memory that can be modified only once by a user. The user
buys a blank PROM and enters the desired contents using a PROM program.

 EPROM (Erasable and Programmable Read Only Memory)


EPROM can be erased by exposing it to ultra-violet light for a duration of up to 40
minutes. Usually, an EPROM eraser achieves this function.

 EEPROM (Electrically Erasable and Programmable Read Only Memory)


EEPROM is programmed and erased electrically. It can be erased
and reprogrammed about ten thousand times.

7-26
Machine instruction
cycle

7-27
High-level architecture

7-28
Machine instruction
cycle
The machine instruction cycle, also known as the fetch-decode-execute
cycle, is the cycle that the central processing unit (CPU) follows to
process instructions.

The cycle consists of four phases:


 Fetch: The CPU fetches instructions from the memory location
indicated by the program counter
 Decode: The fetched instruction is decoded
 Read address: The address is read from memory
 Execute: The instruction is executed

7-
Machine instruction
cycle
Machine instruction cycle
Machine instruction
cycle
LMC
◦ 2 phases
1. LM fetched the instruction from memory and read it
2. Interpret the instruction and perform the action
◦ Repeat this cycle endlessly  stop!
CPU (much of the procedure consists of copying
data from one register to another)
1. PC  MAR
2. MDR  IR PC = PROGRAM COUNTER
3. IR [address]  MAR IR = INSTRUCTION
4. MDR  A REGISTER A =
5. PC + 1  PC ACCUMULATOR

7-
Instructions
formats
 Instruction formats refer to the way instructions are encoded and represented
in-machine language.
 There are several types of instruction formats, including zero, one, two, and
three-address instructions.

0. Zero Address Instructions

7-41
CPU architectures

Most CPU architectures today are categorized into


two types:

 CISC (complex instruction set computers)


 RISC (reduced instruction set computers)
Complex Instruction Set
Architecture (CISC)
 The CISC approach attempts to minimize the number of instructions per program
but at the cost of an increase in the number of cycles per instruction.

Characteristic of CISC:
 Complex instruction, hence complex instruction decoding.
 Instructions are larger than one-word size.
 Large number of specialized, complex instructions
 Complex Addressing Modes.
https://www.geeksforgeeks.org/computer-organization-risc-and-cisc/

7-
CISC Architecture
Examples
Intel x86, IBM Z-Series Mainframes, older CPU architectures

Characteristics
 Few general purpose registers
 Many addressing modes
 Large number of specialized, complex instructions
 Instructions are of varying sizes

8-48
Limitations of CISC Architecture
• Complex instructions are infrequently used by
programmers and compilers
• Memory references, loads and stores, are slow
• Procedure and function calls are a major bottleneck

 Passing arguments
 Storing and retrieving values in registers

8-49
Reduced instruction set computer (RISC)
What is RISC based?
 In computer engineering, a reduced instruction set computer (RISC)
computer
is a architecture designed to simplify the individual instructions given to
the computer to accomplish tasks.

 Reduce the cycles per instruction at the cost of the number of instructions per
program.

Characteristic of RISC:
 Simpler instruction, hence simple instruction decoding.
 Instruction comes undersize of one word.
 Instruction takes a single clock cycle to get executed.
 More general-purpose registers.
 Simple Addressing Modes.
 Fewer Data types.
 A pipeline can be achieved.
https://www.geeksforgeeks.org/computer-organization-risc-
and-cisc/

7-45
Instruction Formats:
RISC

7-
Thank
you

7-49

You might also like