Control Unit
Control Unit
Control Unit
MICRO-OPERATIONS :-
The Fetch Cycle :- which occurs at the beginning of each instruction cycle and causes an
instruction to be fetched from memory.
■ Memory address register (MAR): Is connected to the address lines of the system bus. It
specifies the address in memory for a read or write operation.
■ Memory buffer register (MBR): Is connected to the data lines of the system bus. It contains
the value to be stored in memory or the last value read from memory.
■ Program counter (PC): Holds the address of the next instruction to be fetched.
■ Instruction register (IR): Holds the last instruction fetched.
The Indirect Cycle :- If the instruction specifies an indirect address, then an indirect cycle
must precede the execute cycle. The data flow differs somewhat from that indicated in
Figure 14.7 (Data Flow, Indirect Cycle) and includes the following micro-operations:
In t3 address field of the IR is updated from the MBR, so that it now contains a direct rather
than an indirect address.
The Interrupt Cycle:- At the completion of the execute cycle, a test is made to determine
whether any enabled interrupts have occurred. If so, the interrupt cycle occurs. The nature of
this cycle varies greatly from one machine to another
Save the PC: The computer records where it was (the PC) before the interrupt happened.
Set the Destination: The computer figures out where to store the saved PC.
Jump to the Interrupt Handler: The computer jumps to a special routine (the interrupt
handler) that knows how to deal with the interrupt.
t1: Load the memory address from the instruction into the MAR.
t2: Fetch the data at that address and store it in the MBR.
t3: Add the value in MBR to the value in R1, and store the result in R1.
1. Setup Interrupt:
This is the initial state where the CPU is ready to handle an interrupt.
The Interrupt Control Code (ICC) is set to 00 to indicate that no interrupt is currently
being processed.
2. Fetch Instruction:
3. Decode Opcode:
The control unit analyzes the opcode of the fetched instruction to determine the operation
to be performed.
4. Execute Instruction:
6. Indirect Addressing:
If the instruction involves indirect addressing (i.e., the operand address is stored in
another memory location), the CPU fetches the effective address from the specified
memory location.
The ICC is set to 01 during the indirect addressing phase.
7. Return to Fetch:
Once the current instruction is completed (either directly or indirectly), the CPU returns
to the fetch stage to fetch the next instruction.
The ICC is reset to 00 to indicate that no interrupt is currently being processed.
Accumulator (AC):
Y and Z:
Additional registers that can be used for various purposes, such as storing operands or
temporary results.
A communication channel within the CPU that connects the various components.
Allows data and control signals to be transferred between components.
Decoder:
Timing Generator:
Produces a sequence of timing signals (T1, T2, ..., Tn) to control the timing of operations
within the CPU.
Control Unit:
Flags:
Stores status flags that indicate the results of operations, such as carry, zero, overflow,
and sign.
These flags can be used for conditional branching and other control flow decisions.
Microinstruction
1) horizontal
2) vertical
Microinstruction Address: Similar to the horizontal format, specifies the address of the
next microinstruction.
Jump Condition: Also similar, determines the branching condition.
Function Codes: A field that encodes the specific operation to be performed by the
microinstruction. This allows for more compact microcode and potentially faster
execution.
Microinstruction Format:
The format of microinstructions is not explicitly shown in the image, but it typically
includes a field for the microinstruction address and a field for the control signals.
The control memory is organized into a sequence of routines, each representing a specific
task or operation that the CPU can perform.
The routines are linked together by jump instructions, which specify the next
microinstruction to be executed.
Routines:
Fetch cycle routine: Responsible for fetching the next instruction from memory.
Indirect cycle routine: Handles indirect addressing, where the effective address of the
operand is determined by the value in a register.
Interrupt cycle routine: Processes interrupts, suspending the current execution and
transferring control to an interrupt service routine.
Execute cycle beginning routine: Initializes the execution of an instruction.
Opcode routine: Contains microinstructions for executing specific opcodes
(instructions).
AND routine: Performs the AND operation on two operands.
ADD routine: Performs the addition operation on two operands.
IOF routine: Handles input/output operations.
Control Flow:
The control flow through the control memory is determined by the jump instructions in
each microinstruction.
The CPU starts by executing the fetch cycle routine, which fetches the next instruction.
Based on the opcode of the fetched instruction, the CPU jumps to the corresponding
opcode routine to execute the instruction.
After executing the instruction, the CPU jumps back to the fetch cycle routine to fetch the
next instruction.
If an interrupt occurs, the CPU jumps to the interrupt cycle routine to handle the
interrupt.
The last step just listed needs elaboration. At the conclusion of each microinstruction, the
sequencing logic unit loads a new address into the control address register. Depending on the
value of the ALU flags and the control buffer register, one of three decisions is made:
■ Get the next instruction: Add 1 to the control address register.
■ Jump to a new routine based on a jump microinstruction: Load the address field of the
control buffer register into the control address register.
■ Jump to a machine instruction routine: Load the control address register based on the
opcode in the IR.
Design Considerations
1) The size of the microinstruction :- The first concern is obvious; minimizing the size of the
control memory reduces the cost of that component
2) The address-generation time:- The second concern is simply a desire to execute
microinstructions as fast as possible.
Sequencing Techniques
■ Two address fields
■ Single address field
■ Variable format
The design of an encoded microinstruction format can now be stated in simple terms:
■ Organize the format into independent fields. That is, each field depicts a set of actions (pattern
of control signals) such that actions from different fields can occur simultaneously.
The vertical format uses multiple microinstructions to control each operation, while the
horizontal format uses a single microinstruction with multiple fields to control multiple
operations simultaneously.
The choice of format depends on factors like the complexity of the instruction set, the desired
speed of execution, and the available hardware resources.
The horizontal format can potentially achieve higher performance due to its ability to execute
multiple operations in parallel.
However, the horizontal format can be more complex to design and implement.
1. Instruction Register:
2. Sequencing Logic:
This logic analyzes the instruction in the instruction register and generates the appropriate
control signals to sequence the execution of the instruction.
It also receives status signals (flags) from the ALU and other components to determine
the next steps in the execution process.
This register stores the address of the current microinstruction to be executed. It acts as a
pointer to the control memory.
4. Control Memory:
This register holds the current microinstruction being executed. It receives the
microinstruction from the control memory and provides the control signals to the various
processor components.
6. Control Logic:
This logic decodes the microinstruction and generates the necessary control signals for
the ALU, registers, and other components.
It also receives external control signals from other components, such as the interrupt
controller, to modify the execution flow.
These signals are generated by the control logic and are used to control the operation of
the processor's internal components, such as the ALU, registers, and memory units.
These signals are generated by the control logic and are used to control the operation of
external devices, such as I/O devices and memory modules.