Chapter 1 · SimulationA Simple CPU: Fetch–Decode–Execute? ← Chapter 1 Sample program Add two numbers (12 + 8) Difference of two numbers (12 − 8) 1 + 2 + … + n (loop) n = (1–9) Step Play Reset Run to endSpeed Try it yourselfInstructions: 0 · Steps: 0 · Correct 0/0 Check CloseA Simple CPU: Fetch–Decode–ExecuteGoal: See the stored-program concept and how the CPU processes every instruction with the fetch → decode → execute cycle, step by step. The program’s instructions and its data sit in the same memory (von Neumann architecture).How to use itPick a sample program. Each press of Step runs one stage of the cycle; Play advances automatically and the Speed slider sets the pace. Run to end finishes the program at once; Reset reloads memory and registers.Fetch: the address in the PC goes onto the address bus, a READ signal goes on the control bus, and the instruction arrives in the IR over the data bus; the PC is incremented.Decode: the control unit splits the instruction in the IR into the opcode (operation code) and the address.Execute: memory is read or written, the ALU computes, or a branch instruction changes the PC.Try it yourself: before every “execute” stage you guess the new value of ACC, memory or the PC; correct answers are counted.RegistersPC (program counter): the address of the next instruction. IR (instruction register): the fetched instruction. ACC (accumulator): the register where results are accumulated.Instruction setInstructionOpcodeMeaningLOAD a0001ACC ← memory[a]ADD a0010ACC ← ACC + memory[a]SUB a0100ACC ← ACC − memory[a]STORE a0011memory[a] ← ACCJMP a0101PC ← a (unconditional jump)JZ a0110if ACC = 0 then PC ← a (conditional jump)HALT0000stopThe codes are hypothetical: in a 16-bit instruction the first 4 bits are the opcode and the last 12 bits are the address (e.g. ADD 1005 → 0010 001111101101). The codes of HALT, LOAD, ADD and STORE are the same as in the slides; SUB, JMP and JZ were added for this simulation.Related slides: Chapter 1.3 · Computers (the Fetch–Decode–Execute Cycle, Buses, Instruction Encoding) and Chapter 1.2 · Computer Hardware.