STRUCTURE AND FUNCTION OF PROCESSOR Core components of the processor • Control unit ○ Coordinates the activities of the CPU ○ Controls the movement of data between the processor, memory and I/O devices ○ Performs the FDE cycle ○ Sends control signals • Arithmetic logic unit (ALU) ○ Performs arithmetic (+-*/, shifts) and logical operations (AND, OR, NOT, XOR) ○ Components of the ALU § Adder circuits, logic gates, registers and accumulator connections, shift circuits Registers within the processor • Registers are very fast, very small storage locations inside the CPU, which temporarily store data, instructions and addresses while processing occurs • PC (Program counter) ○ Holds the address of the next instruction to be fetched ○ After each fetch, the PC increases to the next address • Accumulator ○ Stores immediate results during mathematical and logical operations • MAR (Memory address register) ○ Holds the address in memory being accessed • MDR (Memory data register) ○ Stores the actual data being transferred to or from memory • CIR (Current instruction register) ○ Holds the current instruction being decoded/executed, divided into opcode/operand Buses • Buses are a set of wires used to transfer data between components, all 3 form the system bus • Data bus ○ Transmits actual data/instructions e.g. data from RAM to CPU, results from CPU to RAM • Address bus ○ Unidirectional, carries the address of the memory location being accessed • Control bus ○ Carries control signals e.g. read and write, system clock, interrupt requests FDE cycle • Repeated process the CPU uses to run instructions • Fetch ○ PC stores address of next instruction to be fetched ○ Address is copied to MAR and sent on the address bus ○ Control unit sends READ signal on control bus ○ Instruction returned on data bus to MDR ○ MDR copied to CIR and PC increments • Decode ○ Control unit decodes instruction in CIR ○ Opcode tells the CPU what operation to perform ○ The operand tells the CPU what data, registers, or memory address to use • Execute ○ Instruction is carried out ○ ALU may perform calculations ○ Data may move between registers/memory ○ Result may be stored in Accumulator or RAM Factors affecting performance • Clock speed ○ a clock is a circuit that generates regular pulses to synchronise CPU operations ○ Faster clock speed means more clock cycles per second ○ So the CPU can execute more instructions per second, improving performance • Number of cores ○ A core is an independent processing unit in the CPU ○ More cores means more instructions/programs can be run simultaneously ○ Improves multitasking and parallel processing and so performance ○ Might not improve performance if software is single-threaded so cannot make use of them • Size and speed of cache ○ Cache is very fast memory inside or very close to the CPU ○ Stores frequently used data/instructions to reduce time waiting for slower RAM ○ Larger cache reduces use of RAM, increasing performance ○ Faster access to cache increases performance Von Neumann and Harvard architecture • Von Neumann ○ Data and instructions are stored in the same memory ○ Uses the same buses to transfer both ○ Benefits § Simpler and cheaper § Flexible memory usage (instructions and data are stored together) ○ Drawbacks § Slower as data and instructions can't be transferred at the same time (Von Neumann bottleneck) • Harvard ○ Data and instructions are stored in separate memories ○ Separate buses for instructions and data ○ Benefits § CPU can fetch instructions and data simultaneously, so faster ○ Drawbacks § More complex and expensive § If one of the memories is full but not the other, the wasted memory cannot be reallocated and the system crashes • Modern processors ○ Mostly based off Von Neumann architecture, but includes features inspired by Harvard ○ Separate instruction and data cache § Allows data and instructions to be accessed simultaneously § Reduces Von Neumann bottleneck ○ Multiple cores § Allows parallel processing ○ Pipelining § Different stages of different instructions overlap, improving efficiency ○ Larger/faster cache § Reduces RAM access TYPES OF PROCESSOR CISC vs RISC • RISC (Reduced Instruction Set Computer) ○ Small and simple instruction set ○ Most instructions only take one clock cycle ○ Fixed-length instructions ○ Benefits § Pipelining is easier as each instruction takes the same amount of time § Simpler hardware is needed to execute simpler instructions ○ Drawbacks § Uses more RAM to store machine code instructions § Compiler has to do more work to translate HLLs into machine code § Programs require more instructions • CISC (Complex Instruction Set Computer) ○ Large and complex instruction set ○ One instruction can perform multiple operations ○ Variable instruction lengths ○ Benefits § Fewer instructions needed per program § Reduces memory usage from machine code ○ Drawbacks § More complex hardware § Instructions may take multiple clock cycles § Harder to pipeline efficiently § High power consumption from complex circuitry GPU (Graphics processing unit) • Specialised processor designed for parallel processing • Has many cores, so allows for massive parallel processing and so SIMD (Single instruction multiple data) processing • Built with specialist instructions e.g. matrix operations, image rendering operations, vector operations • Make GPUs efficient for graphics rendering (calculate colours/pixels for many pixels at once), AI, data mining (process large datasets in parallel), modelling (repeat calculations across many data points) Parallel processing • Can be achieved through multiple processors in one computer, multiple cores in one processor or a GPU which contains many small cores for highly parallel tasks e.g. graphics/AI • Faster processing • Limitations ○ But some tasks cannot be split into parallel tasks ○ Extra coordination is needed, tasks need to be split up, communication between processors and synchronising results can create overhead (more time/resources needed to manage the system than do the actual task) INPUT/OUTPUT AND STORAGE Input devices • Barcode readers ○ Read barcodes using reflected light ○ Pen-type readers § Pen is dragged across barcode § Most durable due to simple design but impractical as pen must touch the barcode ○ Laser scanners § Uses laser, common in shops due to convenience § Reliable and cheap for ○ Camera-based reader § Uses a camera and imaging techniques § Can read barcodes on any surface, printed or on screen, damaged and poorly printed § Used for scanning QR codes, tickets • Digital cameras ○ Uses millions of light sensors • RFID ○ RFID reader uses sends/receives radio waves to detect RFID tag ○ Active - has battery, longer range ○ Passive - no battery, powered by reader's radio waves, cheaper and smaller ○ No line of sight needed, can be read from distance ○ Used in cards, shops (anti-theft tags) and tracking systems Output devices • Screens ○ LCD - uses backlighting § Low power usage, bright and sharp images, long lifespan, cheap § Needs backlight, narrower viewing angles, slower refresh than OLED, blacks less deep due to backlight ○ OLED - each pixel emits its own light § Thinner and lighter due to no backlight, better contrast and blacks, wider viewing angles, faster refresh § More expensive, shorter lifespan, sensitive to water • Printers ○ Laser printer § Fast, high quality text printing § Resolution is too low for high quality images ○ Inkjet printer § Sprays ink onto paper § Better for (colour) photos and images, cheaper to buy § Slower, ink cartridges replaced often which is expensive ○ Dot matrix printer § Pin strikes paper through inked ribbon § Works in harsh environments § Noisy, slow, poor print quality ○ 3D printers can create physical 3D objects • Multimedia projectors - good for education • Actuators - motors that react to sensors to perform physical actions e.g. opening windows, controlling heat, turning wheels Storage devices • Secondary is slower (as it cannot be directly accessed by the CPU) but non-volatile • Magnetic ○ Data is stored using magnetic fields and uses a read/write head ○ Cheapest per GB, high capacity ○ Slower, has moving parts so can wear out over time, is more likely to be damaged by movement, can generate heat/noise and not portable ○ Used for large backups/archive storage • Optical ○ Data is stored on lands and pits read by a laser ○ Cheap, portable ○ Lower capacity, slower, easily scratched ○ Used for media distribution • Flash ○ Stores data electronically using memory cells ○ Very fast, no moving parts, durable, portable ○ Most expensive per GB, limited write cycles (memory cells will wear out ○ Used for fast storage/mobile devices ROM and RAM • RAM (Random access memory) ○ Stores data and instructions currently being used by the CPU ○ Volatile, can be read from or written to, fast access ○ Holds running applications and active data ○ Stores temporary working data while device operates in embedded systems • ROM ○ Stores permanent startup instructions (BIOS) ○ Non-volatile, modern ROM can be rewritten to but during normal operation, the CPU can only read from it ○ Stores fixed instructions in embedded systems Virtual storage • Storage that appears local to the user but is actually stored remotely • Such as elsewhere on the network or on cloud (over the internet, on servers owned by external companies) • Benefits ○ Accessible anywhere with internet ○ Easy backup and recovery ○ Scalable storage ○ Easy file sharing/collaboration • Drawbacks ○ Depends on internet/network connection ○ Slower than local storage ○ Possible security/privacy risks ○ Server outages can prevent access