0% found this document useful (0 votes)
5 views56 pages

Unit 2

The document covers computer organization and design, focusing on performance, instruction types, and control mechanisms within a CPU. It explains memory reference, register reference, and I/O instructions, as well as the roles of the control unit and clock in synchronizing operations. Additionally, it discusses RISC and CISC architectures, addressing modes, and the importance of microprogrammed control in executing machine instructions.

Uploaded by

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

Unit 2

The document covers computer organization and design, focusing on performance, instruction types, and control mechanisms within a CPU. It explains memory reference, register reference, and I/O instructions, as well as the roles of the control unit and clock in synchronizing operations. Additionally, it discusses RISC and CISC architectures, addressing modes, and the importance of microprogrammed control in executing machine instructions.

Uploaded by

Susheel Kumar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Module 2

Computer Organization and Design


Performance in a computer system:
computer instructions

1. Memory Reference Instructions


Memory reference instructions are instructions that access data stored in main memory (RAM).
They involve reading data from memory or writing data to memory.

• Programs and data are stored in memory


• The CPU must fetch data from memory to process it
• Results often need to be stored back into memory

2. Register Reference Instructions


Register reference instructions perform operations only on CPU registers.

3. Input–Output (I/O) Instructions


Input–Output instructions manage communication between the CPU and external devices.
Timing and Control
Timing and Control is the mechanism that ensures all parts of the CPU work together in the correct
order and at the correct time.

1. Control Unit (CU)

The Control Unit is a part of the CPU that directs and coordinates all operations inside the
computer system.

Main Functions of the Control Unit


1. Generates Timing Signals

2. Coordinates Execution of Instructions


Every instruction follows a sequence:
Fetch instruction
Decode instruction
Execute instruction
Store result
Clock

The clock is an electronic oscillator that produces regular pulses

Role of the Clock


• Synchronizes all CPU operations
• Ensures every unit works in step
• Acts like a metronome for the processor
Memory Reference Instructions
Memory Reference Instructions are instructions that access data stored in memory (RAM), rather
than operating only on registers or constants.

These instructions read from or write to a memory location.

Types of Memory Reference Instructions

1. Load Instructions
Move data from memory to a register

Eg: LOAD R1, 1000

Means: Load the value stored at memory address 1000 into register R1
2. Store Instructions
Move data from a register to memory

Eg: STORE R1, 1000

Means: Store the value in R1 into memory address 1000

3. Read–Modify–Write Instructions
Access memory, modify data, then write it back

Eg: ADD R1, 1000


INC 2000
What is Input–Output?

Input–Output refers to the communication between the CPU/memory and external


devices such as: Keyboard, mouse, Monitor, Printer etc.

The CPU itself can only process data it cannot directly interact with these devices.
I/O mechanisms make that possible.

Each I/O device typically has:

1. Device controller (interface hardware)


2. Data register – holds data being transferred
3. Status register – device state (ready/busy/error)
4. Control register – commands from CPU
Methods of Input–Output Pros
•Simple
1. Programmed I/O (Polling) •Easy to implement
CPU repeatedly checks device status.
Cons
while(device not ready) •CPU wastes time waiting
wait •Very inefficient
read data

2. Interrupt-Driven I/O
Instead of waiting, the CPU continues executing other programs.

• Device signals CPU when it is ready


• CPU temporarily stops current task
• Handles the I/O request
What is an Interrupt?
An interrupt is a signal sent to the CPU that immediately requests attention.

Examples:
Key pressed
Disk operation completed
Timer expired

Why Interrupts Are Needed


Without interrupts:
• CPU must constantly check devices (polling)
• Huge waste of CPU cycles

With interrupts:
• CPU works efficiently
• Devices get attention only when needed
What is Microprogrammed Control?

Microprogrammed Control is a technique used to generate control signals inside the CPU by
executing a small program called a microprogram.

Instead of hardwiring control logic with circuits, the CPU uses:


• Microinstructions
• Stored in Control Memory
• Executed step-by-step to control the datapath

Why Do We Need Microprogrammed Control?


In a CPU:

• Every instruction (ADD, LOAD, STORE, etc.)


• Requires multiple control signals
• In a specific sequence
Key Components of a Microprogrammed Control Unit

1. Control Memory (CM)


• A special memory that stores microprograms
• Each microprogram corresponds to one machine instruction

2. Microinstruction
A microinstruction is a low-level instruction that directly controls the datapath.

It tells the CPU:


• Which register to read/write
• Which ALU operation to perform
• Whether to access memory
• Where to go next

3. Microinstruction Register (MIR)

A register that holds the currently executing microinstruction

What it does
• Fetch microinstruction from Control Memory
• Store it in MIR
• Its bits directly generate control signals
Problem:
Suppose a program (or a program task) takes 1 billion instructions to execute on a
processor running at 2 GHz. Suppose also that 50% of the instructions execute in 3
clock cycles, 30% execute in 4 clock cycles, and 20% execute in 5 clock cycles. What is
the execution time for the program or task?
Instruction Set:

The operation of the processor is determined by the instructions it executes,


referred to as machine instructions or computer instructions. The collection of
different instructions that the processor can execute is referred to as the
processor’s instruction set.
Instruction Representation: Within the computer, each instruction is represented by a
sequence of bits. The instruction is divided into fields, corresponding to the
constituent elements of the instruction
Instruction types:

 Data processing: Arithmetic and logic instructions

 Data storage: Movement of data into or out of register and or memory location

 Data movement: I/O instructions

 Control: Test and branch instructions


Arithmetic instructions provide computational capabilities for processing
numeric data. Logic (Boolean) instructions operate on the bits; thus, they
provide capabilities for processing any other type of data the user may wish
to employ.

Data storage: These operations are performed primarily on data in processor


registers. Therefore, there must be memory instructions for moving data
between memory and the registers.

I/O instructions are needed to transfer programs and data into memory and
the results of computations back out to the user.

Test instructions are used to test the value of a data word or the status of a
computation. Branch instructions are then used to branch to a different set of
instructions depending on the decision made.
Addressing Modes:
The term addressing modes refers to the way in which the operand of an
instruction is specified.
Immediate Addressing:

The simplest form of addressing is immediate addressing, in which the operand


value is present in the instruction.

Operand = A

The advantage of immediate addressing is that no memory reference other than


the instruction fetch is required to obtain the operand, thus saving one memory
or cache cycle in the instruction cycle. The disadvantage is that the size of the
number is restricted to the size of the address field, which, in most instruction
sets, is small compared with the word length
Control Memory
Control Memory is a special memory inside the CPU that stores microinstructions used to control
the execution of machine-level instructions.

• Machine instructions (ADD, LOAD, JUMP) are too complex to be executed in one step.
• Each instruction is broken into micro-operations
Example: Fetch → Decode → Execute → Store

These micro-operations are stored in Control Memory.

Control Memory Stores


• Microinstructions
• Control signals for:
ALU operations
Register transfers
Memory read/write

• Instruction = “Make Tea”


• Microinstructions = boil water → add tea → add sugar → pour cup
Stack Organization

A stack-based CPU organization where operands are stored in a stack instead of registers.

Stack Characteristics
• LIFO (Last In First Out)
• Uses Stack Pointer (SP)

Stack Operation
PUSH
POP
Program Control Instructions
Program control instructions are machine-level commands that alter the sequential flow of execution
in a microprocessor or microcontroller by modifying the program counter. They enable decision-
making, looping, and branching, allowing the processor to jump to different memory locations,
handle subroutines, or respond to interrupts.
Program Counter (PC)

The Program Counter (PC) is a special register in the CPU.


What it does
• Stores the address of the next instruction to be executed
• Controls the flow of program execution

Branch Instructions

Branch instructions allow a program to jump to a different location in memory.


Purpose
Implement decision making
Create loops
Control program logic

Unconditional Branch (JUMP)


An unconditional jump transfers control to another address without any condition.

eg. JUMP 2000

PC is set to address 2000, skipping all instructions in between


RISC – Reduced Instruction Set Computer
RISC architecture is designed around the idea that simpler instructions executed very fast can
give better overall performance than complex instructions executed slowly.

RISC processors focus on:


• Doing fewer things per instruction
• Executing instructions quickly
• Maximizing pipeline efficiency

Characteristics of RISC Architecture

1. Simple Instructions
• Each instruction performs a very basic operation
• Examples: load, store, add, subtract
• Complex operations are broken into multiple
simple instructions
2. Fixed Instruction Length
• All instructions have the same size (e.g., 32 bits)
• Instruction fetch and decode are predictable

Benefit:
• Easier hardware design
• Faster instruction decoding
• Ideal for pipelining

3. Few Addressing Modes


• Limited ways to access operands
• Typically register-based operations
• Memory accessed only using LOAD and STORE

4. Large Number of Registers


• Many general-purpose registers Advantages of RISC Architecture
• Reduces frequent memory access • Faster execution
• Operands are mostly kept in registers • Efficient pipelining
• Simple hardware design
• Lower power consumption
• High performance per clock cycle
CISC – Complex Instruction Set Computer

CISC architecture aims to reduce the number of instructions per program by using complex
instructions that can perform multiple operations at once.

Characteristics of CISC Architecture

1. Large Instruction Set


• Hundreds of instructions
• Includes complex operations like:
• Memory-to-memory operations
• String processing
• Floating-point instructions

2. Variable Instruction Length


• Instructions can be of different sizes
• Depends on complexity and operands
3. Complex Addressing Modes
• Many ways to access memory
• Instructions can operate directly on memory operands

4. Microprogrammed Control
• Instructions are broken into microinstructions
• Executed using a microcode control unit

Advantages of CISC Architecture


• Compact code (smaller program size)
• Fewer instructions per program
• Efficient use of memory
• Easier assembly-level programming
RISC vs CISC Comparison

Feature RISC CISC


Instruction Length Fixed Variable
Instruction Set Small Large
Execution Time Single cycle Multiple cycles
Addressing Modes Few Many
Registers Many Few
Hardware Design Simple Complex
Pipelining Easy Difficult
Performance High Moderate
Power Efficiency High Lower
What is Performance?

Computer performance refers to how fast and efficiently a computer system executes a given
task or program.

Higher performance = Less time taken to complete a task

Execution Time (Response Time)


The total time taken by a computer to complete a program.

CPU Execution Time


CPU execution time is the most important metric in processor performance.
Question 1
A microprogrammed control unit has a control memory of 1024 words, and each microinstruction
is 40 bits long.

1. How many bits are required to address the control memory?


2. What is the total size of control memory in bits and bytes?
Stack Organization Question 2
Consider a stack-organized CPU. The stack pointer (SP) initially points to address 500. The
following operations are executed:

PUSH 10
PUSH 20
POP
PUSH 30
1. What is the final value of SP?
2. What is the content at the top of the stack?

Solution Operation 2: PUSH 20 Operation 4: PUSH 30


Initial State • SP = 499 − 1 = 498 • SP = 499 − 1 = 498
SP = 500 • Stack[498] = 20 • Stack[498] = 30

Operation 1: PUSH 10
Operation 3: POP
• Stack grows downward
• Remove top element (20)
• SP = SP − 1 = 499
• SP = 498 + 1 = 499
• Stack[499] = 10

You might also like