ScholarQuill logoScholarQuillUniversity Notes
  • Notes
  • Past Papers
  • Blogs
  • Todo
Login
ScholarQuill logoScholarQuillUniversity Notes
Login
NotesPast PapersBlogsTodo
More
SubjectsDiscussionCGPA CalculatorGPA CalculatorStudent PortalCourse Outline
About
About usPrivacy PolicyReportContact
Notes
Past Papers
Blogs
Todo
Analytics
    Current Subject
    🧩
    Computer Organization and Assembly Language
    COMP3137
    Progress0 / 73 topics
    Topics
    1. Introduction to Computer Organization2. Assembly Language3. Comparison of Low-Level and High-Level Languages4. Register Types (16-bit): General Purpose and Special Purpose Registers5. Introduction and Usage of RAM6. Processor7. Registers8. System Bus9. Instruction Execution Cycle10. Assembly and Machine Language11. Assembler12. Linker and Link Libraries13. Programmer's View of a Computer System14. RISC and CISC Architecture15. Physical Address Calculation16. Basic Memory Organization17. CPU Organization18. Top Level View of Computer Function and Interconnection19. Assembler Instruction Cycle20. Execute Cycle21. Interrupts22. Interrupt Cycle23. Memory Connection24. Input/Output Connection25. CPU Connection26. MASM27. MIPS28. Defining Data in MASM Assembler29. Elements of Assembly Language30. Integer Constants31. Integer Expressions32. Real Number Constants33. Character Constants34. String Constants35. Reserved Words36. Identifiers37. Directives38. Instructions39. The NOP (No Operation) Instruction40. Adding and Subtracting Integer41. INC and DEC Instructions42. NEG Instruction43. How to Move Integer Number in Register44. Adding and Subtracting Numbers in Registers45. Declaration and Initialization of Variables46. Moving Data from Variable to Register47. Data Definition Statement48. BYTE and SBYTE Data49. WORD and SWORD Data50. Defining DWORD and SDWORD Data51. Knowledge about Different Data Types52. Operations, Array & Loops53. Division and Multiplication in Assembly54. Jumps Based on Specific Flags55. Jumps Based on Equality56. Simple Jump Statements57. Jumps Based on Specific Condition58. Code Examples59. Practice on MASM60. Procedures61. File Operations Procedures62. Labels in Procedures63. Stack64. Runtime Stack65. Conditional Control Flow Directives66. Compound Expressions67. Data Representation & Conversion68. Architecture69. Data Path70. Control Unit71. Critical Path72. General Principles of Pipelining73. Pipelined Y86 Implementations
    COMP3137›Control Unit
    Computer Organization and Assembly LanguageTopic 70 of 73

    Control Unit

    8 minread
    1,361words
    Intermediatelevel

    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 load past papers

    Click on Show Past Papers to see past papers.
    On This Page
      Reading Stats
      Est. reading time8 min
      Word count1,361
      Code examples0
      DifficultyIntermediate