ScholarQuill logoScholarQuillUniversity Notes
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
Study Tools
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
Contact
ScholarQuill logo
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
ScholarQuill logoScholarQuillUniversity Notes
Study PortalCOMP3137Control Unit
Ctrl + K
Login
Explore
Search
Semester
Papers
CGPA
    COMP3137

    Computer Organization and Assembly Language

    Progress0 / 73 done
    Topics73
    1Introduction to Computer Organization2Assembly Language3Comparison of Low-Level and High-Level Languages
    4General Purpose and Special Purpose Registers5Introduction and Usage of RAM6Processor7Registers8System Bus9Instruction Execution Cycle10Assembly and Machine Language11Assembler12Linker and Link Libraries13Programmer's View of a Computer System14RISC and CISC Architecture15Physical Address Calculation16Basic Memory Organization17CPU Organization18Top Level View of Computer Function and Interconnection19Assembler Instruction Cycle20Execute Cycle21Interrupts22Interrupt Cycle23Memory Connection24Input/Output Connection25CPU Connection26MASM27MIPS28Defining Data in MASM Assembler29Elements of Assembly Language30Integer Constants31Integer Expressions32Real Number Constants33Character Constants34String Constants35Reserved Words36Identifiers37Directives38Instructions39The NOP (No Operation) Instruction40Adding and Subtracting Integer41INC and DEC Instructions42NEG Instruction43How to Move Integer Number in Register44Adding and Subtracting Numbers in Registers45Declaration and Initialization of Variables46Moving Data from Variable to Register47Data Definition Statement48BYTE and SBYTE Data49WORD and SWORD Data50Defining DWORD and SDWORD Data51Knowledge about Different Data Types52Operations, Array & Loops53Division and Multiplication in Assembly54Jumps Based on Specific Flags55Jumps Based on Equality56Simple Jump Statements57Jumps Based on Specific Condition58Code Examples59Practice on MASM60Procedures61File Operations Procedures62Labels in Procedures63Stack64Runtime Stack65Conditional Control Flow Directives66Compound Expressions67Data Representation & Conversion68Architecture69Data Path70Control Unit71Critical Path72General Principles of Pipelining73Pipelined Y86 Implementations
    8 min read
    Topic 70 of 73
    Topic Study Note Illustration
    70

    Control Unit

    The Control Unit (CU) is one of the key components of the Central Processing Unit (CPU) responsible for directing the operation of the processor. Its primary role...

    Control Unit (CU) in Computer Architecture

    The Control Unit (CU) is one of the key components of the Central Processing Unit (CPU) responsible for directing the operation of the processor. Its primary role is to coordinate the activities of the CPU, ensuring that instructions are executed in the correct sequence and that the appropriate resources (such as registers, the ALU, memory, and I/O devices) are used effectively.

    In essence, the control unit acts as the "brain" of the processor, overseeing the execution of all instructions and controlling the flow of data throughout the system. It does not perform any calculations itself; instead, it sends control signals that direct other parts of the computer to perform calculations, store data, or transfer information.


    Key Functions of the Control Unit

    1. Instruction Fetch:

      • The control unit fetches the instruction from memory (RAM) based on the address in the Program Counter (PC).
      • The fetched instruction is then placed into the Instruction Register (IR) for decoding and execution.
    2. Instruction Decode:

      • The control unit decodes the instruction held in the Instruction Register (IR) to determine what operation needs to be performed (e.g., arithmetic operation, memory read, or write, or I/O operation).
      • The CU identifies the opcode (operation code), which specifies the operation, as well as any operands (data or memory addresses).
    3. Execution Control:

      • The control unit sends control signals to various parts of the CPU and memory to execute the decoded instruction.
      • It instructs the Arithmetic Logic Unit (ALU) to perform an operation (like addition, subtraction, or comparison).
      • It might send data to or from memory, using the Memory Address Register (MAR) and Memory Buffer Register (MBR).
    4. Sequencing:

      • After decoding and executing the current instruction, the CU updates the Program Counter (PC) to the next instruction's address, unless a jump or branch instruction alters the flow (like in the case of conditional jumps or interrupts).
      • It ensures the correct sequence of operations and controls the fetching of subsequent instructions.
    5. Control Signal Generation:

      • The control unit generates control signals for different parts of the CPU, memory, and I/O devices to ensure the proper execution of each instruction step.
      • These signals may include read/write commands for memory, clock pulse synchronization, enabling/disabling of registers, or activating specific paths on the data bus.
    6. Handling Conditional Branches:

      • In cases of branching instructions (e.g., if-else, loops), the CU determines whether the branch condition is true (e.g., zero flag set after an ALU operation) and modifies the Program Counter (PC) accordingly.
      • For example, in conditional jumps, it checks flags like zero (Z), carry (C), overflow (O), and negative (N) before making a decision.

    Types of Control Units

    There are two primary types of control units used in modern processors: Hardwired Control Unit and Microprogrammed Control Unit.

    1. Hardwired Control Unit

    In a hardwired control unit, control signals are generated using combinational logic circuits, such as gates and flip-flops. The design is "hardcoded," meaning that the control unit follows a fixed, predefined set of operations based on the opcode of the instruction.

    • Advantages:

      • Faster than microprogrammed control because it uses fixed logic circuits to generate control signals.
      • More efficient for simpler or specialized processors.
    • Disadvantages:

      • Limited flexibility. Modifying the control unit design can be complex and difficult.
      • Hard to adapt to changes in the instruction set.

    Example: Simple processors like those found in embedded systems or certain RISC processors may use a hardwired control unit.

    2. Microprogrammed Control Unit

    A microprogrammed control unit uses a set of instructions (called micro-operations or microinstructions) stored in memory to generate control signals. Each instruction is decoded into a series of micro-operations that are executed step by step.

    • Advantages:

      • More flexible and easier to modify. Microinstructions can be changed by altering the control memory (a type of ROM or RAM).
      • Suitable for more complex processors that support a wide variety of instructions.
    • Disadvantages:

      • Slower than hardwired control, as it involves fetching microinstructions from memory.
      • More complex than hardwired control.

    Example: Many CISC processors (like the x86 architecture) use a microprogrammed control unit because of the complexity and richness of their instruction sets.


    Control Unit Components

    To understand how a control unit works, it's helpful to know the key components involved:

    1. Instruction Register (IR):

      • Holds the instruction currently being decoded and executed.
      • The CU reads the instruction from the IR to determine what operation to perform.
    2. Program Counter (PC):

      • Points to the memory location of the next instruction to be fetched.
      • After each instruction is executed, the PC is updated (usually incremented) to point to the next instruction, unless a jump or branch alters the flow.
    3. Control Logic:

      • This is the part of the CU that generates the control signals.
      • In a hardwired control unit, control signals are generated through combinational logic circuits based on the opcode and other input conditions.
      • In a microprogrammed control unit, control signals are generated by fetching microinstructions from control memory.
    4. Control Signals:

      • The CU sends out control signals to different parts of the CPU to carry out the appropriate tasks, such as:
        • Enabling or disabling registers (e.g., ALU input/output registers).
        • Activating the ALU to perform calculations.
        • Managing memory read/write operations.
        • Setting flags (e.g., Zero, Carry, Overflow) based on results from the ALU.
    5. Timing Signals:

      • The control unit also manages the timing signals, which synchronize the various parts of the CPU, ensuring that operations occur in the correct order.
      • It coordinates the flow of data through registers, buses, and the ALU, based on the clock cycles.

    Control Unit in the Instruction Cycle

    The CU is responsible for managing the entire instruction cycle (also known as the fetch-decode-execute cycle), which is the fundamental process that the CPU uses to execute instructions:

    1. Instruction Fetch:

      • The CU sends a signal to fetch the instruction from memory using the address in the Program Counter (PC).
      • The fetched instruction is stored in the Instruction Register (IR).
    2. Instruction Decode:

      • The CU decodes the instruction in the IR, extracting the opcode and determining what operation to perform.
      • The CU generates the appropriate control signals for the ALU, registers, or memory, based on the decoded instruction.
    3. Execute:

      • The CU directs the ALU or other functional units to perform the required operation (e.g., arithmetic, logic, memory access).
      • The result of the operation is written back to registers or memory as necessary.
    4. Repeat:

      • The CU updates the Program Counter (PC) to point to the next instruction, unless a branch or jump modifies the flow.
      • The cycle repeats for each new instruction.

    Example: Control Unit in Action

    Let’s walk through an example of the ADD instruction (let's assume ADD R1, R2, R3), which adds the values of registers R2 and R3, and stores the result in R1:

    1. Instruction Fetch:

      • The Program Counter (PC) points to the address of the ADD instruction in memory.
      • The CU sends a control signal to memory to fetch the instruction and stores it in the Instruction Register (IR).
    2. Instruction Decode:

      • The CU decodes the instruction ADD R1, R2, R3 to understand that the operation is an addition.
      • The CU sends control signals to:
        • Enable registers R2 and R3 for reading.
        • Enable the ALU to perform the addition.
    3. Execution:

      • The ALU performs the addition of the values in registers R2 and R3.
      • The result is stored back into R1.
      • If needed, flags (like Zero or Carry) are set based on the result.
    4. Program Counter Update:

      • The Program Counter (PC) is incremented to point to the next instruction, unless a jump or branch modifies the flow.

    Conclusion

    The Control Unit (CU) is a crucial part of the CPU that orchestrates the execution of instructions by generating control signals, managing the flow of data, and sequencing operations across various components (ALU, registers, memory, etc.). It plays a central role in determining how a processor performs tasks, coordinates data transfers, and executes complex instruction sets. Understanding the CU’s operation is essential for grasping how a computer’s hardware functions at the lowest level, providing insights into both processor design and the execution of programs.

    ← Previous topic 69
    Data Path
    Next topic 71 →
    Critical Path

    Past Papers

    Open this section to view and download past papers

    Click on Show Past Papers to load available exam papers.

    Reading Progress
    0%
    8mremaining
    1.4kwords
    Intermediatelevel
    On This Page

    No headings found

    Study Toolkit

    Subject Portal

    Computer Organization and Assembly Language