Detailed Analysis of the Fetch-Decode-Execute Cycle and Register Logic Operation
Overview of the Fetch-Decode-Execute (FDE) Cycle Components
Program Counter (PC): A dedicated register that holds the memory address of the next instruction to be fetched. It keeps track of the program's progress through memory.
Memory Address Register (MAR): A register that holds the memory address currently being accessed for either reading (fetching an instruction or data) or writing (storing data).
Memory Data Register (MDR): A temporary storage buffer that holds the data or instruction fetched from memory, or the data waiting to be written to memory.
Current Instruction Register (CIR): A register that holds the current instruction while it is being decoded and executed. It splits the instruction into its opcode (instruction type) and operand (data or address).
Accumulator (ACC): A primary register in the Arithmetic Logic Unit (ALU) used to store the results of mathematical and logical operations.
Address Bus: A unidirectional communication pathway used by the CPU to send the specific address it wants to access in memory.
Data Bus: A bidirectional communication pathway used to transport the actual data or instructions between the CPU and memory.
Control Bus: Carries control signals (such as Read or Write) from the CPU to other components to coordinate operations.
Memory Layout and Initial State
The program and data are stored in memory at the following specific addresses: - Address : Contains the instruction
LOAD 5. - Address : Contains the instructionADD 6. - Address : Contains the instructionSTO 7. - Address : Empty/Not specified. - Address : Contains the data value . - Address : Contains the data value . - Address : Initially empty (reserved for output).
Detailed Execution of Instruction 1: LOAD 5
Fetch Stage: - The PC contains the address . - The value is copied from the PC to the MAR via the Address Bus. - The CPU sends a read signal to memory. The instruction at address (
LOAD 5) is transferred via the Data Bus to the MDR. - The PC is incremented from to to prepare for the next cycle. - The instructionLOAD 5is copied from the MDR to the CIR.Decode Stage: - The CIR decodes the instruction
LOAD 5. The CPU identifies the opcodeLOAD(meaning fetch data from a memory address and place it in the Accumulator) and the operand address .Execute Stage: - The operand address is moved to the MAR. - The value at address () is fetched from memory via the Data Bus and placed into the MDR. - The value in the MDR is then copied into the Accumulator (ACC). - Current State: ACC = .
Detailed Execution of Instruction 2: ADD 6
Fetch Stage: - The PC contains the address . - The value is copied from the PC to the MAR. - The instruction at memory address (
ADD 6) is fetched and sent via the Data Bus to the MDR. - The PC is incremented from to . - The instructionADD 6is copied from the MDR to the CIR.Decode Stage: - The CIR decodes the instruction
ADD 6. The CPU identifies the opcodeADD(meaning add the value at a specified memory address to the current value in the Accumulator).Execute Stage: - The operand address is moved to the MAR. - The value at address () is fetched via the Data Bus and placed into the MDR. - The ALU performs the addition: Current ACC value () plus MDR value (). - The result, , is stored back in the Accumulator (ACC). - Current State: ACC = .
Detailed Execution of Instruction 3: STO 7
Fetch Stage: - The PC contains the address . - The value is copied from the PC to the MAR. - The instruction at memory address (
STO 7) is fetched and sent via the Data Bus to the MDR. - The PC is incremented from to . - The instructionSTO 7is copied from the MDR to the CIR.Decode Stage: - The CIR decodes the instruction
STO 7. The CPU identifies the opcodeSTO(meaning store the value currently in the Accumulator into a specified memory address).Execute Stage: - The operand address is moved to the MAR. - The value in the Accumulator (ACC), which is , is copied to the MDR. - The CPU sends a write signal, and the value in the MDR is transferred via the Data Bus to memory address . - Final State: Memory Address now contains the value .