{"base":{"id":"cs10-11","subject":"Computer systems","title":"The processor: registers and buses","scene":"mix","steps":[{"use":"sys9","mode":"stored","eyebrow":"Stored programs","title":"Instructions live in memory","body":"In a von Neumann computer, programs and data are stored together in memory. The program counter (PC) holds the address of the next instruction. Move the PC through a short program.","controls":[{"id":"pc","label":"Program counter","min":0,"max":4,"step":1,"value":0}]},{"use":"sys9","mode":"fde","eyebrow":"The fetch–decode–execute cycle","title":"Three steps, billions of times","body":"Fetch: copy the instruction from memory into the CPU. Decode: work out what it means. Execute: carry it out. Then repeat. Step through one full cycle and watch the registers.","actions":[{"id":"step","label":"Step"},{"id":"reset","label":"Reset"}]},{"use":"chip","mode":"ram","eyebrow":"Main memory","title":"Where running programs live","body":"Programs and the data they use are loaded into RAM while running. RAM is fast but volatile: switch off and it is wiped. Open a file, save it, then cut the power.","actions":[{"id":"open","label":"Open a file"},{"id":"save","label":"Save it"},{"id":"power","label":"Switch off"}]},{"use":"sys9","mode":"quiz","look":"fde","eyebrow":"Check yourself","title":"Registers","body":"During the fetch stage, the CPU needs to know where in memory the next instruction is.","question":"Which register holds that address?","options":["The accumulator (ACC)","The program counter (PC)","The current instruction register (CIR)"],"answer":1,"right":"Correct. The PC holds the address of the next instruction, then goes up by 1.","wrong":"Not quite. Which register \"counts\" through the program?"}],"more":[{"type":"cards","id":"worked","eyebrow":"Worked examples","title":"Step by step","items":[{"tag":"Fetch","title":"Step by step","body":"PC → MAR          (address of next instruction)\nPC ← PC + 1\nmemory[MAR] → MDR (via data bus)\nMDR → CIR","code":true},{"tag":"Decode","title":"The control unit","body":"the control unit splits CIR into\nopcode (what to do) and operand (what to use)","code":true},{"tag":"Execute","title":"ADD 7","body":"ALU adds the value at address 7 to ACC\nresult stays in ACC","code":true},{"tag":"Units","title":"ALU and CU","body":"ALU: arithmetic and logic (+, −, AND, compare)\nCU: sends control signals, manages the cycle","code":true}]},{"type":"cards","id":"detail","eyebrow":"The ideas in detail","title":"Registers and buses","items":[{"tag":"PC","title":"Program counter","body":"Holds the address of the next instruction to fetch. Increments after each fetch."},{"tag":"MAR","title":"Memory address register","body":"Holds the address of the memory location being read or written."},{"tag":"MDR","title":"Memory data register","body":"Holds the data or instruction just read from, or about to be written to, memory."},{"tag":"CIR","title":"Current instruction register","body":"Holds the instruction being decoded and executed."},{"tag":"ACC","title":"Accumulator","body":"Holds the result of calculations done by the ALU."},{"tag":"Buses","title":"Address, data and control buses","body":"The address bus carries addresses one way (CPU → memory). The data bus carries data both ways. The control bus carries signals such as read, write and the clock."}]},{"type":"cards","id":"mistakes","eyebrow":"Common mistakes","title":"Watch out for these","items":[{"tag":"Mistake","title":"Mixing up MAR and MDR","body":"MAR holds an ADDRESS; MDR holds the DATA found at that address."},{"tag":"Mistake","title":"Thinking the address bus is two-way","body":"Addresses only travel from the CPU to memory; data travels both ways."},{"tag":"Mistake","title":"\"RAM stores files permanently\"","body":"RAM is volatile. Files are kept on secondary storage."},{"tag":"Mistake","title":"Forgetting the PC increments","body":"The PC goes up during the fetch, so it already points at the next instruction."}]},{"type":"cards","id":"deeper","eyebrow":"Go deeper","title":"More than the lesson","items":[{"tag":"History","title":"The von Neumann design","body":"In 1945 John von Neumann described a computer storing its program in the same memory as its data. Almost every computer since follows this design."},{"tag":"How it works","title":"Billions of cycles","body":"A 3 GHz processor can run around 3 billion clock ticks each second, and modern CPUs overlap several fetch–decode–execute cycles at once (pipelining)."},{"tag":"Careers","title":"Who designs processors?","body":"Electronic and computer engineers design chips; compiler writers make code use them well; security researchers study how they can leak secrets."},{"tag":"Coming next","title":"Where this leads","body":"Next: what makes one processor faster than another, and the tiny computers hidden inside everyday devices."}]},{"type":"cards","id":"challenge","eyebrow":"Challenge yourself","title":"Stretch your brain","intro":"Try each one on paper before opening the card.","items":[{"tag":"Challenge","title":"A CPU runs at 2 GHz and each instruction takes 4 clock ticks. How many instructions per second?","body":"2 000 000 000 ÷ 4 = 500 000 000 instructions per second","code":true},{"tag":"Challenge","title":"Why does the data bus need to be two-way but the address bus doesn't?","body":"The CPU reads data from memory and also writes results back, so data goes both ways. Only the CPU chooses addresses, so addresses only go out."}]},{"type":"activities","id":"try","eyebrow":"Try it at home","title":"Try it yourself","items":[{"title":"Be the CPU","time":"20 minutes","need":["A partner","Sticky notes","A sheet of paper divided into numbered \"memory\" boxes"],"steps":["Write a 5-line program in the boxes, such as LOAD 3, ADD 4, STORE 5.","One person is the PC and MAR; the other is the MDR, CIR and ACC.","Act out fetch, decode, execute for every line.","Swap roles."],"why":"Acting it out shows how each register passes information on in every cycle.","safety":"No safety risks."},{"title":"Look up your processor","time":"10 minutes","need":["A computer or phone"],"steps":["Find your device's processor name in its settings.","Look up its clock speed, cores and cache size.","Compare with a friend's device.","Which do you think is faster, and why?"],"why":"Specifications give clues about performance, but real speed also depends on design.","safety":"No safety risks."}]},{"type":"quiz","id":"quiz","eyebrow":"Quiz","title":"Eight more questions","questions":[{"question":"What does the fetch–decode–execute cycle do?","options":["Saves files","Connects to the internet","Runs instructions one after another"],"answer":2,"right":"Correct.","wrong":"Not quite."},{"question":"Which register holds the result of a calculation?","options":["Accumulator","MAR","PC"],"answer":0,"right":"Correct.","wrong":"Not quite."},{"question":"Which bus carries memory addresses?","options":["Data bus","Address bus","Control bus"],"answer":1,"right":"Correct.","wrong":"Not quite."},{"question":"What does the ALU do?","options":["Stores the program","Controls the screen","Arithmetic and logic operations"],"answer":2,"right":"Correct.","wrong":"Not quite."},{"question":"What happens to RAM when power is lost?","options":["Its contents are lost","It saves automatically","Nothing"],"answer":0,"right":"Correct. It is volatile.","wrong":"Not quite."},{"question":"Which register holds the instruction being decoded?","options":["MDR","CIR","ACC"],"answer":1,"right":"Correct.","wrong":"Not quite."},{"question":"In a von Neumann computer, data and instructions are stored…","options":["in separate memories only","on the hard disk only","in the same memory"],"answer":2,"right":"Correct.","wrong":"Not quite."},{"question":"What does the control unit do?","options":["Manages the cycle and sends control signals","Adds numbers","Stores data permanently"],"answer":0,"right":"Correct.","wrong":"Not quite."}]},{"type":"checklist","id":"check","eyebrow":"Self-check","title":"I can…","items":["describe the von Neumann stored-program idea","describe each stage of the fetch–decode–execute cycle","name and describe PC, MAR, MDR, CIR and ACC","describe the address, data and control buses","describe the jobs of the ALU and control unit","explain why RAM is volatile","trace a simple instruction through the cycle","explain what clock speed means"]},{"type":"keywords","id":"words","eyebrow":"Key words","title":"Words to know","items":[{"word":"CPU","meaning":"Central processing unit: runs instructions."},{"word":"register","meaning":"A tiny, very fast store inside the CPU."},{"word":"program counter","meaning":"Holds the address of the next instruction."},{"word":"accumulator","meaning":"Holds results from the ALU."},{"word":"ALU","meaning":"Arithmetic logic unit."},{"word":"control unit","meaning":"Manages the fetch–decode–execute cycle."},{"word":"bus","meaning":"A set of wires carrying data, addresses or signals."},{"word":"RAM","meaning":"Volatile main memory for running programs."},{"word":"volatile","meaning":"Loses its contents without power."},{"word":"von Neumann architecture","meaning":"Program and data stored in the same memory."}]},{"type":"sources","id":"sources","title":"Sources","items":["BBC Bitesize, GCSE Computer Science: The CPU","Isaac Computer Science: Computer architecture","Computer History Museum: Stored-program computers","Raspberry Pi Foundation: How computers work"]}]},"overlay":null}