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 11: Contains the instruction LOAD 5.   - Address 22: Contains the instruction ADD 6.   - Address 33: Contains the instruction STO 7.   - Address 44: Empty/Not specified.   - Address 55: Contains the data value 88.   - Address 66: Contains the data value 44.   - Address 77: Initially empty (reserved for output).

Detailed Execution of Instruction 1: LOAD 5

  • Fetch Stage:   - The PC contains the address 11.   - The value 11 is copied from the PC to the MAR via the Address Bus.   - The CPU sends a read signal to memory. The instruction at address 11 (LOAD 5) is transferred via the Data Bus to the MDR.   - The PC is incremented from 11 to 22 to prepare for the next cycle.   - The instruction LOAD 5 is copied from the MDR to the CIR.

  • Decode Stage:   - The CIR decodes the instruction LOAD 5. The CPU identifies the opcode LOAD (meaning fetch data from a memory address and place it in the Accumulator) and the operand address 55.

  • Execute Stage:   - The operand address 55 is moved to the MAR.   - The value at address 55 (88) is fetched from memory via the Data Bus and placed into the MDR.   - The value 88 in the MDR is then copied into the Accumulator (ACC).   - Current State: ACC = 88.

Detailed Execution of Instruction 2: ADD 6

  • Fetch Stage:   - The PC contains the address 22.   - The value 22 is copied from the PC to the MAR.   - The instruction at memory address 22 (ADD 6) is fetched and sent via the Data Bus to the MDR.   - The PC is incremented from 22 to 33.   - The instruction ADD 6 is copied from the MDR to the CIR.

  • Decode Stage:   - The CIR decodes the instruction ADD 6. The CPU identifies the opcode ADD (meaning add the value at a specified memory address to the current value in the Accumulator).

  • Execute Stage:   - The operand address 66 is moved to the MAR.   - The value at address 66 (44) is fetched via the Data Bus and placed into the MDR.   - The ALU performs the addition: Current ACC value (88) plus MDR value (44).   - The result, 1212, is stored back in the Accumulator (ACC).   - Current State: ACC = 1212.

Detailed Execution of Instruction 3: STO 7

  • Fetch Stage:   - The PC contains the address 33.   - The value 33 is copied from the PC to the MAR.   - The instruction at memory address 33 (STO 7) is fetched and sent via the Data Bus to the MDR.   - The PC is incremented from 33 to 44.   - The instruction STO 7 is copied from the MDR to the CIR.

  • Decode Stage:   - The CIR decodes the instruction STO 7. The CPU identifies the opcode STO (meaning store the value currently in the Accumulator into a specified memory address).

  • Execute Stage:   - The operand address 77 is moved to the MAR.   - The value in the Accumulator (ACC), which is 1212, is copied to the MDR.   - The CPU sends a write signal, and the value 1212 in the MDR is transferred via the Data Bus to memory address 77.   - Final State: Memory Address 77 now contains the value 1212.