Higher Grade Computing Studies 2. Computer Structure Computer Structure • The traditional diagram of a computer ... INPUT DEVICES keyboard + mouse etc. CPU CONTROL ALU UNIT REGISTERS RAM R O M MAIN MEMORY BACKING STORAGE 1 Higher Computing Computer Systems S. McCrossan OUTPUT DEVICES monitor + printer etc. Higher Grade Computing Studies 2. Computer Structure The Structure of the CPU - The Control Unit The control unit is like the CPU’s manager. The main functions of the control unit are: • To send out the signals to fetch instructions from memory. • To interpret those instructions. • To send out signals to enable instructions to be carried out. 2 Higher Computing Computer Systems S. McCrossan Higher Grade Computing Studies 2. Computer Structure The Structure of the CPU - The ALU The arithmetic and logic unit, the ALU, performs the following functions; • Calculations such as addition, subtraction, multiplication and division. • Logic functions, such as comparing values. 3 Higher Computing Computer Systems S. McCrossan Higher Grade Computing Studies 2. Computer Structure Main Memory 4 Address Contents Address Contents 00000001 0111010011110000 00001010 0111010011111000 00000010 0011001101101111 00001011 0001000111100000 00000011 1111000011101111 ……… 00000100 0011001100110011 ……… 00000101 1111000010101010 ……… 00000110 1100000000111111 ……… 00000111 0001110010110010 ……… 00001000 0101000000110000 ……… 00001001 0110101100001101 ……… •Address The main Contents ……… memory part ……… can be visualised ……… as a series of ……… ……… individual boxes ……… their own with ……… unique address. ……… ……… Higher Computing Computer Systems S. McCrossan Higher Grade Computing Studies 2. Computer Structure The Size & Number of Memory Locations • The word length of a computer is the size of the data, in bits, which can be manipulated as a single unit by the processor. Logically, it is also the number of bits that a single memory location can store. • The size is determined by the width of the data pathways (or buses) within the computer, between the processor and the memory. 5 Address Contents Ad 00000001 0111010011110000 0000 00000010 0011001101101111 0000 00000011 1111000011101111 …… 00000100 0011001100110011 …… 00000101 1111000010101010 …… 00000110 1100000000111111 …… 00000111 0001110010110010 …… 00001000 0101000000110000 …… 00001001 0110101100001101 …… • The system above has a word length of 16 bits. Higher Computing Computer Systems S. McCrossan Higher Grade Computing Studies 2. Computer Structure Main Memory • RAM has the following features: • The CPU can write to, or read from, RAM at high speed. RAM can be changed by the CPU at any time - it is volatile. • All information stored in RAM is lost when the computer is switched off. • Static RAM holds its contents as long as there is a power supply. • Dynamic RAM, has to be refreshed by reading and rewriting its contents frequently. • DRAM is more common because it needs less power and its circuitry is simpler. Higher Computing 6 Computer Systems S. McCrossan Higher Grade Computing Studies 2. Computer Structure Main Memory • ROM has the following features: • Data in ROM is permanently written into a microchip. • Data in ROM can be read by the CPU from the moment the computer is switched on. • The bootstrap loader is stored in ROM. • Data stored in ROM is not lost when the computer is turned off. 7 Higher Computing Computer Systems S. McCrossan Higher Grade Computing Studies 2. Computer Structure Main Memory • PROM (Programmable Read Only Memory) • Empty of data when the chip is manufactured, can be programmed by the user. Once programmed the data cannot be erased. • EPROM (Erasable PROM) • Like PROM only the chip can be removed from the computer and the program erased and another stored in its place using ultraviolet light. • EEPROM (Erasable PROM) • Like EPROM but electricity is used to erase and reprogram selected contents. 8 Higher Computing Computer Systems S. McCrossan Higher Grade Computing Studies 2. Computer Structure Storage Outside Main Memory • Reading /writing data to and from memory can slow down the system performance. To combat this problem, the processor can store data in cache memory or its internal registers instead of the RAM. • Cache memory • small amount of memory e.g. 512 KB. • stores the next instructions to be read. • physically closer to the processor than RAM. • uses static memory (SRAM). 9 Higher Computing Computer Systems S. McCrossan Higher Grade Computing Studies 2. Computer Structure Storage in the CPU - Registers • Registers are temporary storage locations in the processor. • A register can be used for tasks like ; • holding data for a calculation. • storing the address of the next instruction to be executed. • holding the instruction as it is being decoded and executed. • We will look at registers in more detail in the Fetch-Execute cycle. 10 Higher Computing Computer Systems S. McCrossan Higher Grade Computing Studies 2. Computer Structure The Processor and Main Memory Main Memory Processor Other registers Memory Address Register Memory Data Register ALU 11 Control Unit Address 00001101 00001100 00001011 00001010 Address bus 32 lines Data bus 16 lines Control bus 6 lines Higher Computing Computer Systems S. McCrossan 00001001 00001000 00000111 00000110 00000101 00000100 00000011 00000010 00000001 00000000 Higher Grade Computing Studies 2. Computer Structure Buses • A bus is an electronic highway or a collection of cables where each cable can transmit one bit. • There are three buses: • The address bus, which is used by the processor to pinpoint the memory location, needed. This is a one-way bus. • The data bus, which is used to transfer the data. Its size will usually match the word size i.e. the size of the memory locations. This is a two-way bus. • The control bus, which is used to initiate and control what is happening. 12 Higher Computing Computer Systems S. McCrossan Higher Grade Computing Studies 2. Computer Structure The Address Bus Memory Address Register 0001000 Processor Main Memory Address bus • information is carried from the processor to the main memory • this informs the main memory which memory location will be read or used to store data. • each wire on the bus carries one bit of information at a time. • the number of wires in this bus determines the number of memory locations. • 8 lines will allow 256 memory locations. • 32 lines will allow 68,719,476,736 memory locations. • increasing the width of this bus, increases the number of memory locations that it is possible to address. 13 Higher Computing Computer Systems S. McCrossan Address 00001101 00001100 00001011 00001010 00001001 00001000 00000111 00000110 00000101 00000100 00000011 00000010 00000001 00000000 Higher Grade Computing Studies 2. Computer Structure Main Memory The Data Bus 11100101 Processor Memory Data Register Data bus 11100101 • information is carried to and from the processor and main memory. • this stores data in a memory location and reads data from a memory location. • each wire on the bus carries one bit of information at a time. • the description of the computer i.e 32 bit computer, informs the user of the number of wires in this bus. • increasing the width of this bus, increases the quantity of data that can be carried at one time and so increases the performance of the computer system. Higher Computing Computer Systems 14 S. McCrossan Address 00001101 00001100 00001011 00001010 00001001 00001000 00000111 00000110 00000101 00000100 00000011 00000010 00000001 00000000 Higher Grade Computing Studies 2. Computer Structure Main Memory The Control Bus Processor Control Unit Control bus Informs the memory that data is to be sent to the processor from a particular memory location. Write Informs the memory that data is to be stored in a particular memory location. Clock Generates a constant pulse which regulates the flow of information. 15 A clock of 600MHz (megahertz) generates a pulse 600,000,000 times a second. 00001101 00001100 00001011 00001010 00001001 00001000 00000111 00000110 00000101 00000100 00000011 00000010 00000001 00000000 • each wire on the bus has its own separate function and is activated independently of the others. Read Address Higher Computing Computer Systems S. McCrossan Higher Grade Computing Studies 2. Computer Structure The Control Bus Processor Main Memory Control Unit Control bus Interrupt This is a signal informs the processor that some important external activity has taken place. The current state of processing is saved, then the processor deals with the interrupting device, it then returns to the previous state when finished with the interrupt request. NMI The Non-Maskable Interrupt operates like an interrupt but it cannot be ignored. It must be dealt with immediately. Reset Clears all internal processor registers and returns the computer to its initial switched on state. 16 Higher Computing Computer Systems S. McCrossan Address 00001101 00001100 00001011 00001010 00001001 00001000 00000111 00000110 00000101 00000100 00000011 00000010 00000001 00000000 Higher Grade Computing Studies 2. Computer Structure The Links Between Processor and Memory • The Stored Program concept: • The program and data are stored in RAM until needed by the processor. • The FETCH-EXECUTE cycle: • The first instruction is fetched from memory into the processor where it is decoded and executed. The same happens to the second instruction and so on until the program ends. • The processor has to be able to pinpoint any memory location in which instructions or data are stored. Each memory location is assigned an unique address. 17 Higher Computing Computer Systems S. McCrossan Higher Grade Computing Studies 2. Computer Structure Read From Memory • A processor needs an instruction from memory or requires some data to perform a calculation. Here are the steps and buses needed to fetch that information from memory. 1. Processor sets up address bus with the address to be read in memory in the MAR This pinpoints the desired location 2. Processor activates the read line on the control bus This tells the memory a ‘read’ is to occur and the memory finds the requested location 3. Data from the memory is copied onto the data bus and transferred into the MDR Data is transferred to the processor 18 Higher Computing Computer Systems S. McCrossan Higher Grade Computing Studies 2. Computer Structure Write To Memory • Here are the steps and buses needed to write information to memory. 1. Processor sets up address bus with the address of the location to be written to in the MAR 2. Processor sets up data bus with the data to be written to memory into the MDR 3. Processor activates the write line on the control bus 4. Data from the processor is copied onto the data bus and into memory 19 This pinpoints the desired location This prepares the data This tells the memory a ‘write’ is to occur and the memory finds the requested location Data is transferred to the memory Higher Computing Computer Systems S. McCrossan