0% found this document useful (0 votes)
2 views45 pages

FCA4

This document covers the design and functions of the Central Processing Unit (CPU), focusing on the Arithmetic and Logic Unit (ALU) and Control Unit (CU). It details the operations performed by the ALU, the instruction cycle of the CPU, and the IEEE 754 standard for floating-point arithmetic. Additionally, it discusses the differences between fixed-point and floating-point arithmetic, as well as the types and features of control units.
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)
2 views45 pages

FCA4

This document covers the design and functions of the Central Processing Unit (CPU), focusing on the Arithmetic and Logic Unit (ALU) and Control Unit (CU). It details the operations performed by the ALU, the instruction cycle of the CPU, and the IEEE 754 standard for floating-point arithmetic. Additionally, it discusses the differences between fixed-point and floating-point arithmetic, as well as the types and features of control units.
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
You are on page 1/ 45

UNIT 4

CPU DESIGN
LEARNING OBJECTIVES
1. Arithmetic and Logic Unit framework.
2. Arithmetic and Logic Unit operations (IEEE
standard).
3.Control Unit (types and organization).
INTRODUCTION
 This Unit explains the key components of the Central Processing Unit (CPU): the Arithmetic and
Logic Unit (ALU) and the Control Unit (CU). These parts work together to process data and control
the system.
 The CPU is the “brain” of the computer, responsible for executing instructions, performing
calculations, and managing system operations.
 Main Components of the CPU:
 Arithmetic and Logic Unit (ALU) - Performs mathematical operations (e.g., add, subtract) and
logical comparisons (e.g.,AND, OR, NOT). Handles actual data processing tasks.
 Control Unit (CU) - Directs the CPU’s operations by fetching, decoding, and managing
instructions. Coordinates the flow of data between the CPU, memory, and input/output devices.
 Registers: Temporary storage locations inside the CPU used for fast data access.
 Types of CPUs: Single-core, Multi-core, Microcontroller, DSP.
 The ALU processes data, while the CU controls how and when that processing happens—together,
they allow the CPU to execute programs efficiently.
PRIMARY FUNCTIONS OF THE CPU
 The CPU operates in a sequence of stages commonly referred to as
the instruction cycle:
 Fetch – Retrieve the instruction from main memory.
 Decode – Translate the instruction into signals that direct the next steps.
 Execute – Perform the required operation (e.g., arithmetic calculation, data
movement).
 Store – Save the result to memory or a register.
 Example: When calculating 2 + 3, the CPU fetches the addition
instruction, decodes it, uses the ALU to compute the sum, and
stores the result in a register.
ARITHMETIC AND LOGIC UNIT
ARITHMETIC AND LOGIC UNIT (ALU) FRAMEWORK
 An Arithmetic Logic Unit (ALU) is a key part of the CPU
(Central Processing Unit). It's like the "brain" of the computer
that does all the math and logic work.
 The ALU handles two main types of tasks:
 Arithmetic operations: like addition, subtraction, multiplication, and
division.
 Logical operations: like AND, OR, NOT, and comparing numbers (e.g.,
checking if one number is bigger or equal to another).
 It uses binary numbers (1s and 0s) to do all this.
ARITHMETIC AND LOGIC UNIT (ALU) FRAMEWORK

 The ALU gets instructions from another part of the CPU called the
Control Unit. Based on those instructions, it performs the right
operation on the data.
 Types of ALUs
 Simple ALUs: Can do basic tasks like add, subtract,AND, OR.
 Complex ALUs: Can do more advanced things like multiply, divide, or shift bits.

 Example: A basic calculator uses a simple ALU, while a smartphone uses a


complex ALU to run apps, play videos, and process images.
ALU COMPONENTS
 Input Registers: Hold data before it goes into the ALU. Can be general-purpose or special, like
the accumulator (used to store results for reuse).
 Data Buses: Act like wires that carry data between components. Can move multiple bits at
once (e.g., 32-bit or 64-bit data).
 Multiplexers (MUX): Decide which input goes into the ALU. Help the ALU choose between
different data or operations.
 Adders/Subtractors: Do addition and subtraction. Use a method called two’s complement to
subtract:A - B = A + (~B) + 1
 Logic Gates: Do logic tasks like AND, OR, XOR. Used to compare or combine binary numbers
(1s and 0s).
 Circuit Operation: The ALU works as data flows through circuits. Control signals tell the ALU
which operation to perform.
ALU FLAGS
 The status register holds special indicators called flags that tell the CPU what happened after
a calculation. These flags help the CPU make decisions, like whether to jump to a different
part of a program or handle errors.

Flag Set When Used For


Zero (Z) The result of an operation is zero. Checking if two values are equal.
Making decisions based on
Negative (N) The result is negative (sign bit = 1).
signed numbers.

Overflow (V) Result is out of range for signed numbers. Detecting arithmetic errors.

Handling large numbers or


Carry (C) There’s a carry out in unsigned operations.
multi-byte math.
MAIN ALU FUNCTIONAL UNITS
 Arithmetic Circuit
 Performs math: add, subtract, compare numbers.

 Logic Circuit
 Handles logical tasks:AND, OR, NOT, etc.

 Shift Unit
 Moves bits left or right.
 Used in operations like multiplication or division.
 May be a separate unit or built into the ALU.
HOW THE ALU WORKS
1. Control Unit Sends Instructions 4. Result Is Produced Instantly
 The Control Unit (CU) tells the ALU what
operation to perform (e.g., add, subtract, AND,  The result comes out as soon as the inputs
OR). are processed (this is called combinational
2. Data Is Loaded into the ALU logic—no waiting or clock cycles needed
 The data needed for the operation comes from inside the ALU itself).
the CPU’s registers or memory.
5. Result Is Stored
 This data enters the ALU through input registers
and data buses.  The result is sent to a register, memory, or
3. ALU Performs the Operation back to the CPU for the next step.
 If it’s a math task: the arithmetic circuit adds,  Flags (like Zero, Carry, Overflow) are
subtracts, etc.
updated in the status register to show the
 If it’s a logic task: the logic circuit applies AND, outcome.
OR, NOT, etc.
 If needed, the shift unit moves bits left or right.
INPUTS & OUTPUTS OF THE ALU
 Inputs:
 Two Operands: From CPU registers (e.g., R1, R2).
 General-purpose registers:Temporarily hold data during operations.
 Control Signals: Tell the ALU what operation to perform (ADD, SUB, AND,
etc.).
 Outputs:
 Result: Sent to a register or memory.
 Accumulator: Keeps the result of calculations so it can be reused easily.
 Status Flags: Indicate the outcome (zero, carry, etc.).
INTERNAL STRUCTURE OF THE ALU
 The ALU is made up of small, specialized units:
 Adders, Logic Gates, Multiplexers work together in one unit.
 A 32-bit ALU, for example, is made from 32 tiny 1-bit ALUs connected in a row
-each one handles one bit of the input.
 Control signals guide each part (e.g., do an AND or ADD).
 ALU Operation Path:
 Inputs from registers.
 Logic circuits perform operations.
 Multiplexer selects the correct result.
 Output goes to destination register.
ALU
ARITHMETIC AND LOGIC UNIT
OPERATIONS (IEEE 754 STANDARD)
ARITHMETIC OPERATIONS
 These are basic math operations done by the ALU:
 ADD – Adds two numbers (e.g., 5 + 3 = 8).
 SUB – Subtracts one number from another using a method called
two’s complement (used to represent negative numbers in binary).
 These are used in both integer and floating-point calculations
(e.g., in calculators, processors, or software applications).
LOGICAL OPERATIONS
 These work bit-by-bit (on 1s and 0s), often used in decision-making or comparing
binary data:
 AND – Returns 1 if both bits are 1.
 OR – Returns 1 if at least one bit is 1.
 XOR – Returns 1 if the bits are different.
 NOT – Flips the bit (1 becomes 0, 0 becomes 1).
 The ALU chooses which operation to perform using control signals sent from the
Control Unit.
IEEE 754 FLOATING-POINT
STANDARD
IEEE 754 FLOATING-POINT FORMAT
 The IEEE 754 standard is a common way computers store and work with real numbers
(decimals).
 It was created in 1985 by the Institute of Electrical and Electronics Engineers (IEEE) to make
calculations more accurate and consistent across different computers.
 Before IEEE 754, different computers handled decimals differently. This made programs less
portable and harder to trust.
 IEEE 754 fixed this by setting clear rules.
 Floating-Point Operations:
 Ensures accurate and predictable results.
 Handles rounding, zero, infinity, NaN (Not a Number), overflow, and underflow.
 Makes calculations consistent across different systems (like Windows, Mac, Unix).
FIXED-POINT
VS
FLOATING-POINT ARITHMETIC
FIXED-POINT ARITHMETIC
 Numbers have a fixed number of digits after (and sometimes before) the decimal point.
 Pros:
 Faster and simpler.
 Good precision at low hardware cost.
 Great for systems where speed and power use are important (like digital watches, microcontrollers).
 Cons:
 Limited range (Cannot handle very large or very small numbers well).
 Example:
 To store 10.75, you might multiply by 100 to remove the decimal:
 10.75 → 1075
 Then the system knows to place the decimal after 2 digits, so it reads it as 10.75.
FLOATING-POINT ARITHMETIC
 Floating-point numbers are stored using three parts:
 Sign: shows if the number is positive or negative.
 Exponent: shows the scale (how big or small).
 Mantissa (or significand): holds the actual digits of the number.
 This format lets computers handle very large or very small
numbers.
 Example: The number 123456.78 or 0.000045 can both be
stored efficiently using floating-point format.
FLOATING-POINT ARITHMETIC
 Pros:
 Can represent a huge range of values — from tiny decimals to massive numbers.
 Allows dynamic precision, meaning more digits can be used where needed.
 Ideal for scientific calculations, graphics, simulations, and engineering applications.
 Cons:
 Uses more memory (e.g., 32 or 64 bits per number).
 Slower and more complex than fixed-point, especially on simple hardware.
 Small rounding errors can happen due to binary approximations of decimal
numbers.
FLOATING-POINT ARITHMETIC PRECISION TYPES

 Single Precision (32 bits):


 1 bit for sign (positive or negative)
 8 bits for exponent
 23 bits for mantissa (fractional
part)
 Double Precision (64 bits):
 1 bit for sign
 11 bits for exponent
 52 bits for mantissa
IEEE 754 FLOATING-POINT STANDARD
 Example: When your calculator or program shows "Infinity" or "NaN", it’s using IEEE 754 rules to
handle strange or extreme values.
 Key Parts of IEEE 754 Format:
 Sign bit:
 0 means the number is positive
 1 means the number is negative.
 Biased Exponent:
 The exponent helps scale the number.
 A bias is added to handle both large and small values (positive and negative exponents).
 Normalized Mantissa:This holds the significant digits of the number.
 In IEEE 754, the mantissa is usually adjusted so it starts with 1. followed by binary digits (like
1.101...), to ensure precision.
REPRESENT 24.125 IN IEEE 754 SINGLE PRECISION

128 64 32 16 8 4 2 1
1 0 0 0 0011
REPRESENT 24.125 IN IEEE 754 DOUBLE PRECISION
FIXED-POINT VS FLOATING-POINT ARITHMETIC
Feature Fixed-Point Floating-Point
Precision Constant (depends on fraction bits) Varies (relative to number size)
Limited (based on number of integer Very wide (supports tiny to huge
Range
bits) numbers)
Speed Fast, simple hardware Slower, more complex
Hardware Requires fewer resources Needs more gates and logic
32 or 64 bits (more for double-
Storage Compact (8, 16, or 32 bits)
precision)
Scientific computing, graphics,
Use Cases Embedded, real-time control
simulations
FIXED-POINT VS FLOATING-POINT ARITHMETIC USE CASE

Scenario Use Format


Very high precision across large/small
Floating-point
numbers
Real-time systems with fixed number range Fixed-point
Low-power or cost-sensitive devices Fixed-point
Scientific, 3D graphics, simulations Floating-point
Sensor or audio data with consistent scale Fixed-point
CONTROL UNIT (CU)
CONTROL UNIT
 The Control Unit (CU) is a critical component of the Central Processing Unit (CPU),
responsible for coordinating and directing the execution of instructions within the processor.
 It performs the following key functions:
 Instruction Fetch: Retrieves the next instruction from main memory, typically using the
Program Counter (PC) and Memory Address Register (MAR).
 Instruction Decode: Interprets the binary-coded instruction to determine the operation
to perform and the resources involved (e.g., registers, ALU).
 Control Signal Generation: Produces appropriate control signals to guide the movement
of data and execution of operations across the datapath elements (ALU, registers,
memory, buses, and I/O).
 In essence, the CU acts as the coordinator of the processor’s activities, ensuring
synchronized and orderly execution of instructions.
TYPES OF CONTROL UNITS
HARDWIRED CONTROL UNIT
 A Hardwired Control Unit is a part of the CPU that uses fixed circuits (like
logic gates and flip-flops) to send signals that control what the CPU does.
 How It Works:
 Sends signals to control each step of instruction execution: fetch, decode,
execute, and store.
 These signals are created instantly using hardware.
 The sequence of steps is fixed, like a traffic light that always follows the
same pattern.
 It uses a Finite State Machine (FSM) to go step by step through each
instruction.
HARDWIRED CONTROL UNIT
 Key Features:
 The control logic is built into the hardware.
 It runs very fast because the signals are generated directly by circuits.
 It’s not easy to change—modifying it means physically redesigning the hardware.
 Pros (Advantages):
 Very fast performance because there's no delay in generating signals.
 Efficient for simple and fixed instruction sets, like those used in RISC (Reduced Instruction Set
Computers).
 Cons (Disadvantages):
 Hard to update or modify (not good for systems where the instruction set might change).
 If the instruction set grows or gets more complex, the hardware design also becomes more
complicated.
HARDWIRED CONTROL UNIT
 Main Parts of a Hardwired CU:
 Instruction Decoder: Reads the instruction and figures out what to do.
 Finite State Machine (FSM): Tracks the current step (fetch, decode, etc.) and decides what’s
next.
 Combinational Logic: Uses logic gates to create the right control signals at each step.
 Control Signal Process:
 Fetch: Get the instruction from memory.
 Decode: Figure out what the instruction means.
 Execute: Carry out the instruction (e.g., do a calculation or load data).
 Repeat: FSM moves to the next step based on the instruction and CPU status.
HARDWIRED CONTROL UNIT
Feature Explanation
Very Fast Uses direct hardware circuits to send signals quickly.
Fixed Paths Signals always follow the same pre-designed routes.
Hard to Change To add or change instructions, the hardware must be
redesigned.
Great for Simple CPUs Works best for CPUs with a small, simple set of
instructions (like RISC).
Not Ideal for Complex CPUs Struggles with handling many or complicated
instructions (like in CISC).
HARDWIRED CONTROL UNIT EXAMPLE
 For a "load" instruction:
 Control unit reads memory, sends data through the bus, and stores it in a
register.
 The steps and signals are built into the hardware, so it happens quickly.
 A microwave has a small processor with fixed tasks like start, stop, and
rotate.
 A hardwired CU is perfect here because:
 Tasks are simple and don’t change.
 It can run fast without needing updates.
MICROPROGRAMMED CONTROL UNIT
 A Microprogrammed Control Unit (MCU) controls the CPU using small steps called
microinstructions.
 These steps are stored in Control Memory (usually ROM or RAM).
 How It Works:
 Every CPU instruction (like ADD, LOAD, or STORE) is broken into smaller steps called a
microprogram (a sequence of microinstructions that describe the steps needed to carry it out).
 The MCU fetches and executes these microinstructions one by one.
 Each microinstruction activates control signals that guide the CPU through:
 Fetch – get the instruction.
 Decode – understand it.
 Execute – carry it out.
 Store – save the result.
MICROPROGRAMMED CONTROL UNIT
 Main Components:
 Control Memory: Stores microinstructions.
 Control Address Register (CAR): Points to the next microinstruction.
 Microinstruction Register (MIR): Holds the current microinstruction.
 Sequencing Logic: Decides the next step based on conditions or instruction type.
 Output Control Logic: Uses the microinstruction to control the CPU (e.g., ALU, registers, memory).
 Key Features
 Uses microcode (like software for the CPU).
 Easy to modify or update by changing microinstructions (no hardware changes needed).
 Good for complex CPUs (like CISC).
 Slower than hardwired control because it reads microinstructions from memory.
 Requires extra memory to store microprograms.
CONTROL SIGNAL GENERATION
 Each microinstruction includes:
 The control signals to activate,
 Where to go next (next step or branch),
 Optional condition checks (like flags).
 Execution Steps:
 Control Address Register (CAR) selects the address.
 The microinstruction is fetched into the Microinstruction Register (MIR).
 MIR activates the needed control signals.
 Sequencing logic chooses the next microinstruction (next line, jump, or return).
Feature Explanation
Flexible & Easy to You can change how the CPU works just by editing
Modify MICROPROGRAMMED CONTROL
microprograms, UNIT needed.
no hardware changes
Supports Complex Great for CPUs with many or complicated
Instructions (CISC) instructions.
Slower Execution Speed Takes more time because it reads and decodes
microinstructions.
Structured & Organized Easier to build, test, and fix because everything is
planned and stored in microcode.
Can Emulate Other Can act like other processors just by changing the
CPUs microprograms.
Reprogrammable (in If the control memory can be written (like
some systems) EEPROM), you can update it even after installation.
MICROPROGRAMMED CONTROL UNIT EXAMPLE
 For an instruction like ADD:
 Fetch the instruction (read from memory).
 Decode it (see it's ADD).
 Perform addition using ALU.
 Store the result in a register.
 Each of these is a microinstruction, and the MCU runs them step by step.
 Washing machine:
 Each mode (Delicate, Heavy, Quick) is like a microprogram.
 Each step (fill water, spin, rinse) is a microinstruction.
 Adding a new mode like "Eco Wash" only needs new microinstructions, not new
hardware.
Feature Hardwired Control Microprogrammed Control
Speed Very fast — uses fixed hardware Slower — must fetch and decode
circuits to send signals instantly. microinstructions from memory.
MICROPROGRAMMED CONTROL UNIT
Flexibility Hard to change — changes need Easy to modify — just update the
rewiring and redesigning hardware. microprogram in memory.

Complexity Handling Works best for simple, fixed instruction Great for complex or evolving instruction
sets (like RISC). sets (like CISC).

Development Time Takes longer — requires designing Faster — uses reusable memory-based
custom hardware for control. control logic.
Cost Cheaper for simple, stable designs. Better for systems that may need updates
or support complex tasks.
Use Cases Simple devices like microwave ovens, More advanced systems like washing
calculators, embedded controllers. machines, printers, and CISC-based
CPUs.
REFERENCE
 Englander, I. (2014). The Architecture Of Computer Hardware, Systems Software, &
Networking. (5th Edition). John Wiley & Sons, Inc.
 Silberschatz A., Galvin P.B., & Gagne G. (2018). Operating System Concepts. (10ed).
John Wiley & Sons, Inc.
 Stallings, W. (2020). Computer Organization and Architecture. Pearson.
 Tanenbaum, A. S. (2016). Structured Computer Organization. Pearson.
UNIT 4 END

You might also like