Why might a station ticket machine fetch a repeated instruction faster?
A controller built into a Leeds station ticket machine has a dedicated job: managing ticket sales. It's an embedded system. Your laptop is non-embedded because it can run many kinds of program. Both may run an instruction repeatedly. Why might the ticket machine fetch that instruction faster the next time?
You know RAM holds programs in use. In a Von Neumann computer, instructions and data share main memory. The control unit fetches and decodes each instruction, then directs execution. The arithmetic logic unit does calculations and logic operations. The clock supplies timing pulses. Buses carry addresses, data and control signals.
Watch the number one hundred and twenty move. The program counter holds the address of the next instruction. At the start of this fetch, the processor copies that address into the memory address register. Both are registers, small storage locations inside the processor for values it is working with right now.
The processor is about to fetch the instruction at address two hundred and forty. The program counter has just supplied that address. What does the memory address register hold at this point? Pick one answer.
Follow the request for the instruction at address one hundred and twenty. The processor finds a copy in a fast store called cache. That's a cache hit. Cache returns the instruction without a slower RAM read. If no copy is there, this fetch model gets the instruction from RAM.
The program counter copies address one hundred and twenty to the memory address register, then advances to the next sequential address. A cache hit supplies the instruction to the memory data register without a RAM read. The instruction moves to the current instruction register, where it's held for decoding.
Now the program counter holds address three hundred and sixty, and cache already has a copy of the instruction at that address. Where does the processor get the instruction on this fetch? Pick the best answer.
Main memory includes RAM and ROM. RAM loses programs and data in use when power is off. ROM keeps instructions such as start-up code without power. Cache and registers are separate from main memory. Cache holds reusable copies, and registers hold values in use right now. Both lose their contents without power.
An exam question might ask: Explain why cache can speed up the fetch stage. The memory address register holds the address to read. If cache holds a copy of the instruction at that address, the processor fetches it from cache and avoids a slower RAM read.