0% found this document useful (0 votes)
4 views33 pages

Module 3 DCO

Module 3 covers the Control Unit in Digital Computer Organization, detailing the role of the control unit in coordinating computer operations, various instruction types, and the instruction cycle. It discusses the differences between hardwired and microprogrammed control units, as well as concepts like RISC, parallel processing, and pipelining. The module also introduces assembly language and program control instructions, highlighting their significance in managing program execution.

Uploaded by

amitkhpd
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)
4 views33 pages

Module 3 DCO

Module 3 covers the Control Unit in Digital Computer Organization, detailing the role of the control unit in coordinating computer operations, various instruction types, and the instruction cycle. It discusses the differences between hardwired and microprogrammed control units, as well as concepts like RISC, parallel processing, and pipelining. The module also introduces assembly language and program control instructions, highlighting their significance in managing program execution.

Uploaded by

amitkhpd
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/ 33

Module 3: Control Unit

Subject: Digital Computer Organization


Course Code: E1PA107T
Course Type: Theory
Overview
• Introduction
• Instruction types and formats
• Instruction cycles and sub-cycles
• Micro-operations
• Execution of a complete instruction
• Introduction to assembly language
• Program control
• Reduced instruction set computer
• Parallel processing
• Pipelining
• Hardwired and microprogrammed control unit
Introduction
Control Unit
• All operations in a computer system must be coordinated in a
synchronized manner, which is the task of the control unit.
• The control unit acts as the nerve center of the system,
managing and directing the flow of data and instructions.
• Conceptually, the control unit is considered a well-defined,
independent unit that interacts with other parts of the system.
• In practice, much of the control circuitry is physically
distributed throughout the machine.
Introduction
• A program is a sequence of instructions that define the operations, operands,
and the order in which processing should occur.
• A computer instruction is represented as a binary code that specifies a series
of micro-operations.
• Instructions, along with data, are stored in the computer's memory.
• The set of all instructions a processor can execute is known as its
instruction set.
• Each processor has a unique and specific instruction set.
• Every instruction contains the necessary information required by the
processor for execution.
• The concept of storing and executing instructions, known as the stored
program concept, is a fundamental characteristic of general-purpose
computers.
• An instruction code is essentially a group of bits that directs the computer to
carry out a specific operation.
Instruction types
• Computers offer a wide range of instructions, giving users the flexibility to
perform various computational tasks.
• The instruction sets of different processors vary, primarily in how operands
are handled and the use of mode fields.
• Despite these differences, the core operations in instruction sets are
generally similar across computers.
• The binary code for an operation's Opcode, however, can vary between
processors, even for the same operation.
• Most computer instructions fall into the following categories:
• Data Transfer Instructions
• Data Manipulation Instructions
• Arithmetic instructions
• Logical and bit manipulation instructions
• Shift instructions
• Program Control Instructions
Data Transfer Instructions

• Data transfer instructions are used to move data from one location to another
without altering its content.
• Common data transfers include:
• Between memory and processor registers.
• Between processor registers and input/output devices.
• Between processor registers themselves.
• Examples of data transfer instructions: LOAD, STOR, MOV, XCHG, IN, OUT,
PUSH, POP, etc.
Data Manipulation Instructions
• Data manipulation instructions are used to perform operations on data, enabling
the computer's computational capabilities.
• These instructions are categorized into:
• Arithmetic Instructions: Perform mathematical operations like addition, subtraction,
multiplication, and division.
• Logical and Bit Manipulation Instructions: Handle logical operations (AND, OR, NOT, XOR)
and manipulate individual bits.
• Shift Instructions: Shift data bits left or right within a register.
Arithmetic Instructions
• Arithmetic instructions perform basic mathematical operations such as
addition, subtraction, multiplication, and division.
• Most computers support all four operations.
• Smaller computers may only include addition and subtraction
instructions, requiring multiplication and division to be implemented
using repeated addition or other instructions.
• Examples of arithmetic instructions: ADD, SUB, MUL, DIV, INC, DEC,
ADDC, SUBB, etc.

Logical and Bit Manipulation Instructions


• Logical and bit manipulation instructions are used to perform logical
operations and directly manipulate individual bits within data.
• Examples include AND, OR, XOR, CLR, COM, CLRC, SETC, COMC, etc.
Shift Instructions

• Shift instructions are used to shift the contents of a register or


accumulator, offering versatile operations for data manipulation.
• Shift operations can be:
• Logical Shifts: Shift bits, filling the vacant positions with zeros.
• Arithmetic Shifts: Maintain the sign bit while shifting.
• Rotate Operations: Rotate bits either left or right.
• Shifts can be performed in either direction: left or right.
• Examples: SHR, SHL, ASHR, ASHL, RAR, RAL, RRC, RLC, etc.
Program Control Instructions
• Program control instructions manage the flow of execution in a
program by altering the sequence of instructions.
• Instructions are stored in consecutive memory locations and fetched
sequentially for execution.
• After fetching an instruction, the program counter (PC) is incremented
to point to the next instruction.
• However, program control instructions can modify the PC's value,
causing a break in the sequential flow of execution.
• These instructions are essential for implementing loops, conditionals,
and function calls.
• Examples: BR, JUMP, JC, JNC, JZ, JNZ, JP, JN, SKP, CALL, RET, etc.
Instruction cycles
• An instruction is a command given to a computer to perform a specific
operation on the provided data.
• A sequence of instructions written to complete a task is called a program.
• Both instructions and data are typically stored in the computer's memory.
• The steps carried out by the CPU to fetch an instruction, gather necessary
data, and execute it are referred to as the Instruction Cycle.
• The instruction cycle is divided into several sub-cycles or phases.
• In a basic computer, an instruction cycle consists of the following steps:
1.Fetch the instruction from memory.
2.Decode the instruction.
3.Read the required operand.
4.Handle any interrupt if it occurs.
5.Execute the instruction.
• Note: The instruction cycle varies depending on the processor architecture.
Instruction cycle
Instruction cycle flow diagram
Instruction cycle state diagram
Instruction cycle state diagram with
interrupt
Micro-operations
• Micro-operations are the fundamental operations that a computer
performs to carry out the execution of an instruction
• Each machine instruction is broken down into a sequence of micro-
operations, typically corresponding to data movement and
arithmetic/logic operations.
• Types of Micro-operations
• Register Transfer: Moving data from one register to another (e.g., A ← B).
• Arithmetic Operations: Performing basic arithmetic like addition, subtraction,
etc. (e.g., A ← A + B).
• Logic Operations: Performing logic operations such as AND, OR, XOR, etc.
(e.g., A ← A AND B).
• Shifting Operations: Performing bit-level shifting of register contents (e.g., A
← A << 1).
• Control Operations: Altering the sequence of instruction execution (e.g.,
changing the program counter or setting condition flags).
• Consider the instruction: "Add the contents of memory
location NUM to the contents of register R1 and store the
result back in register R1." For simplicity, assume that the
address of NUM is directly specified in the instruction's
address field. This means the instruction uses direct
addressing mode.
• The execution of this instruction involves the following steps:
1.Fetch the instruction.
2.Retrieve the first operand (the contents of the memory location
specified by the instruction's address field).
3.Perform the addition operation.
4.Store the result in register R1.
Steps Actions
PCout, MARin, Read, Clear Y, Set carry -in to
1.
ALU, Add, Zin
2. Zout, PCin, Wait For MFC
3. MDRout, Irin
4. Address-field- of-IRout, MARin, Read
5. R1out, Yin, Wait for MFC
6. MDRout, Add, Zin
7. Zout, R1in
8. END
Assembly Language
• Assembly language is a low-level programming language
that uses human-readable symbols, or mnemonics, to
represent machine-level instructions, making it easier to
understand and write than pure binary code.
• Key Features:
• Mnemonics: Symbols like MOV, ADD, SUB represent machine
instruction.
• Architecture-Specific: Assembly languages are tailored to
specific computer architectures, like x86 or ARM.
• Example: (x86 Assembly)
MOV AX, 5 ; Load 5 into register AX
ADD AX, 3 ; Add 3 to the value in AX
Program control in assembly
language
• Program control refers to the instructions that alter the
normal sequence of execution of a program. These
instructions control the flow of execution, allowing for
branching, looping, and conditional operations.
• Key features
• Jump instructions: Change the flow of execution to a
different part of the program (e.g. JMP for unconditional jump).
• Conditional branches: Allow the program to take different
paths based on conditions (e.g. JZ for jump if zero, JC for jump
if carry).
• Call and Return: Used for function or subroutine calls,
enabling modular program design (CALL, RET).
Main Types of Program Control:
• Unconditional Jumps: Direct the program to another instruction without any condition (e.g.,
JMP).
• Conditional Jumps: Direct the program to another instruction based on certain conditions (e.g.,
JZ, JNZ, JC).
• Function/Procedure Calls: Used to call a function or procedure, and return to the original point
after execution (e.g., CALL, RET).
When is Program Control Used?
• Loops: Repeating a set of instructions until a condition is met.
• Conditionals: Executing different sets of instructions based on certain conditions, such as if-else
statements.
• Function Calls: Jumping to and from subroutines for modular code organization.

Example (x86 Assembly):


MOV AX, 0 ; Set AX to 0
CMP AX, 0 ; Compare AX with 0
JZ label ; Jump to 'label' if AX is zero
label:
; Continue execution here
Reduced Instruction Set Computer
(RISC)
• RISC is a processor architecture that uses a small, highly optimized
set of instructions, aiming for simpler and faster execution.
• Key Features:
• Simplified Instructions: Most instructions execute in a single clock
cycle.
• Load/Store Architecture: Only load and store operations access
memory; other operations use registers.
• Uniform Instruction Length: Easier to decode and pipeline instructions.
• Registers-Based Operations: Operations performed mainly on
registers, reducing memory access time.
• Example Instruction (RISC)
LOAD R1, 0x10 ; Load from memory to register R1
ADD R1, R2 ; Add R2 to R1
STORE R1, 0x20 ; Store result back to memory
Parallel Processing
• What is parallel processing?
Parallel processing enhances computer system performance by
executing multiple instructions at the same time.

• The goals of parallel processing


One objective is to decrease the "wall-clock" time, or the real time
required to solve a problem.
Another aim is to tackle larger problems that may exceed the memory
capacity of a single CPU.
Pipeline
What is Pipeline?
• To execute an instruction, several sub-operations must be
carried out.
These sub-operations typically include:
• Instruction fetch
• Instruction decode
• Operand fetch
• Execution, etc.
• Pipelining is a technique used by modern
microprocessors to boost performance by overlapping
the execution of instructions.
• It is similar to the flow of fluids through pipelines or the
assembly line in factories.
• This method breaks down a sequential process into
smaller sub-operations, with each sub-operation
handled by a dedicated segment.
• Each segment processes part of the instruction and
passes it along to the next segment in the pipeline.
• The final result is produced once the instruction has
passed through all segments.
• If the stages of a pipeline are not balanced and one stage is
slower than others, the overall throughput of the pipeline is
negatively impacted.
• Pipelining enables overlapping computations by associating a
register with each segment of the pipeline.
• These registers create isolation between the segments,
allowing each to operate on different data simultaneously.
• In a non-pipelined system, each step must be completed
before the next instruction can be issued.
• While pipelining does not reduce the latency of a single
instruction, it improves the throughput of the entire workload.
• The time taken by each stage, denoted as tp, must be
determined first.
General Structure of Pipeline
Hardwired control unit
• Each step in the sequence is
completed within a single
clock period.
• A counter is often used to
track the control steps.
• Each value, or count, of this
counter corresponds to one
specific control step.
• The necessary control signals
are determined by the
following factors:
• The contents of the instruction
register and decoder.
• The status of the condition code
flags
• External input signals, such as
MFC and interrupt requests
• Signals from the step decoder.
• The step decoder provides a distinct signal line for each step or time slot in
the control sequence.
• Similarly, the instruction decoder outputs a separate line for each machine
instruction.
• For any instruction loaded in the Instruction Register (IR), one of the output
lines (INS1 through INSm) is activated (set to 1), while all other lines are set
to 0.
• The input signals to the encoder block are combined to generate specific
control signals like Yin, PCout, Add, End, and others.
• The control hardware functions as a state machine, transitioning from one
state to another with each clock cycle, based on the contents of the
instruction register, condition codes, and external inputs.
• The outputs of the state machine are the control signals, with some or all of
the lines being activated.
• The sequence of operations performed by this system is determined by the
configuration of the logic elements, which is why it is referred to as
"hardwired”.
• Advantages:
• A hardwired control unit operates quickly
• The combinational circuits generate control signals based on
the status of input signals. The delay from input availability to
output generation depends on the number of gates in the path
and the propagation delay of each gate.
• Disadvantages:
• When the CPU has a large number of control points, designing
the control unit becomes complex.
• The design lacks flexibility.
• Making modifications to the instruction set is extremely
difficult.
Microprogrammed Control Unit
• Microprogramming is a method of designing a
control unit where the selection and
sequencing of control signals are stored in
ROM or RAM, referred to as Control Memory
(CM).
• The control signals that need to be activated
at any given time are specified by a
microinstruction, which is fetched from the
Control Memory.
• Each microinstruction also provides the
necessary information for sequencing the
microoperations.
• A collection of microinstructions forms a
Microprogram.
• The Microprogram can be easily modified by
altering the contents of Control Memory (CM).
• As a result, a microprogrammed control unit is
more flexible than a hardwired control unit.
• The instruction is loaded into the Instruction Register (IR).
• The address field of the microinstruction holds the address of
the next instruction, which will be used when a branching
condition is met.
• The Microprogram Counter (μPC) provides the address of the
next microinstruction when no branching is required.
• The starting or branch address is determined by considering
the condition code, external inputs, and the Control Word (CW).
• The microinstruction is decoded, and the appropriate control
signals, i.e., the Control Word (CW), are generated.
• Typically, control memory is ROM, which cannot be modified.
• For greater flexibility, writable control memory (WCM) is now
used.
• Advantages:
• Less design complexity.
• Flexible due to WCM.
• A given CPU instruction set can be easily modified by
changing the microprogram.
• Disadvantages:
• A microprogram control unit works slow than hardwired
control unit.
THANK YOU

You might also like