Chapter 4 Computer Architecture - how computers work The computer itself is housed inside the system unit (the grey box on a desk). Most of the components of a computer are plug in circuit devices called microchips, chips, or integrated circuits. A chip is a piece of crystal with the equivalent of many wires, transistors, etc. burned into it. It is enclosed in black plastic and has many wires coming out of it which fit in sockets on a circuit board. The main circuit board is called the mother board. Some things found on a motherboard: RAM chips - temporarily store data being processed ROM chips - store the boot program, run system diagnostics (error checks), control low-level i/o. the CPU a bus transports data between components on the motherboard. Expansion slots - places that we plug in expansion cards for additional devices added to the computer. Expansion card - circuit board that contains circuitry to control a video display, a printer, a disk drive, modem, etc. port - a plug on an expansion card into which we plug a cable for the printer or telephone wire for a modem. Digital computers use binary codes to represent data. For numbers, they use the binary number system: 0 0 1 1 2 10 3 11 4 100 5 101 6 110 7 111 8 1000 9 1001 10 1010 11 1011 For characters, most computers use the ASCII code (Askey). Some IBM mainframes use EBCDIC. Letter A is 1000001 in ASCII and 11000001 in EBCDIC. 1000001 - 7 bits 11000001 - 8 bits value 64 + 1 = 65 128 + 64 x 1 = 193 Data transfer - uses a bus to move collections of data bits from one point to the other (just like a real bus moves multiple people at one time). A ribbon like cable with many individual wires. A bus runs from the CPU to memory and from memory to a disk drive. The address lines of a bus are used to carry the address (location) of each byte to be transferred. The data lines are used to carry the data bits. Usually 8, 16, or 32 bits are transferred at one time (a byte, a word, or double word). RAM - we've talked about it. A collection of storage locations arranged in groups of 8 bits (zeros or ones). Each location has its own address. The data in a particular address can be changed. RAM is volatile memory - all data in RAM disappears when the computer is turned off. RAM is important because it contains all the data for a program plus the program instructions themselves. RAM goes from 4 Megabyts to 32 Megabytes for todays PCs. The amount you need depends on the software you want to run. For example, windows 3.1, need about 4 megs. Windows 95 about 8 Megs, Windows NT bout 16 Megs. What if you are running 3 programs simultaneously - windows 95 whihc takes 8 megaytes, word which takes 2 megabytes and a spreadsheet that takes 4 megabytes. Do you need all 8 + 4 + 2 megabytes of RAM? No, the computer doesn't try to keep all parts of all 3 programs loaded into memory at the same time. It uses disk storage (slower) as virtual memory. The part of a program being executed is in main memory. It loads seldom used portions of each program into virtual memory and transfers them into main memory when needed (moving somethng else from RAM to virtual memory). Computer runs more efficiently if it has more RAM memory because there is less need to use slower virtual memory. ROM memory contains boot instructions and can never be changed - permanent. Is there any memory that is semipermanent? CMOS (complimentary metal oxide semiconductor) memory requires a low-battery power to retain the data stored in it. semi-permanent memory. Usually contains vital configuration info about a computer- like the #of tracks and sectors on a disk drive. This info. enables the computer to access and use the drive. If you buy a new drive, you will want to run a setup program to change data in CMOS. Central Processing Unit. -------------->>>> RAM data CPU ^ and instructions | | | | | |<<<--- processed data <<<----- CPU consists of 2 parts: the ALU (Arithmetic Logic Unit) and Control Unit. Control Unit examines the instruction and sends a signal to the arithmetic logic unit telling it what to do. The ALU carries it out. The control unit contains an instruction register (holds the current instruction) and an instruction pointer (address of next instruction). The ALU contains registers (fast memory slots) for holding data to be processed and an accumulator register (for holding the result of an operation). Picture of accumulator in action Picture of control unit in action Instructions The instructions tell the computer to do a basic task. Each instruction has an operation code (op code) and one or two operands. Jump M1 (Jump to memory address M1 - change instruction pointer of control unit to M1. Usually there is a 3-letter abbreviation for the op code: JMP M1 Move Accumulator to M2 .. Move accumulator contents to M2 MAM M2 MRA REG1 Move value in Register 1 (off ALU) to accumulator MAR REG1 ... oppossitte - Move Accumulator to REG1 MMR M1 REG1 ... Move value in memory address M1 to Register 1 ADD REG1 REG2 - add the contents of REG1 to REG2 leaving result in accumulator. CMP REG1 REG2 - compare REG1 to REG2 - if equal place a 1 in accumulator, otherwise 0. HLT - halt Instructions to add the values in memory cells M1 and M2 and store the result in memory cell M3: MMR M1 REG1 - move value of M1 to REG1 MMR M2 REG3 - move value of M2 to REG2 ADD REG1 REG3 - add REG1 to REG2 MAM M3 - move accumulater to M3 Instruction cycle: 1. Fetch instruction 2. increment instruction counter 3. interpret the instruction 4. carry it out Question: Book shows #2 at the bottom rather than in middle. Reason this is incorrect is that some instructions: such as JUMP 1000 cause the contents of the instruction pointer to change when they are carried out (1000 is the next instruction to execute). So we don't want to change to 1000 and then increment the pointer, because we'd get the instruction at 1001 instead. System Clock: A clock that drives the control unit. Like a timer - it signals that it is time to start the next cycle. Older PCs had system clocks of 4.77 MegaHertz or 4.77 Million cycles per second. Newer faster PCs (pentiums) operate at 100+ MegaHertz (25 times as fast). This is not 4.77 million additions or multiplications because each operation like that consists of several instructions: Move the 1st data item from memory cell X to register 1 of ALU Move the 2nd data item from memory cell Y to register 2 of ALU Add the 2 numbers in register 1 and register 2 Move the result to memory address Z - the destination of the result Each of these instructions requires 4 clock cycles to be done. Word size - refers to the number of bits the CPU can manipulate at once. Higher word sizes mean faster data transfer and fewer instructions to do the same operation. 8 bits in beginning of PCs, 32 bits more common today. RAM cache: Special high speed memory that contains data the CPU is likely to need: a block of instructions, or a block of memory that contains data for a program. The CPU can retrieve something from cache memory much faster than it can from main memory. Memory has a cycle time too which indicates the time it takes to access a particular byte and move data from it. For cache memory,the access rate and transfer rate is faster. When computer starts a task it moves the data in a block of memory cells into cache memory. Other factors that increase speed: Instruction set complexity - CISC - complex instruction set computer RISC - reducted instruction set computer processor for a CISC can execute many, more instructions than can the processor for a RISC; however, a RISC processor can execute its reduced set faster. Most computers these days are RISC processors. Tradeoff - may require more instructions to complete the same task as a CISC processor. Approaches to speeding up processing: pipelining; the ability to start the instruction cycle for the next instruction midway through the instrution cycle of the current one. For example, some computers can fetch the next instruction (step 1 of the cycle) while carrying out the operation specified for the previous one (step 3 of the cycle). parallel processing: having multiple processors in the CPU, each of which works on a separate instruction so CPU can execute several instructions simultaneously. Requires special software. Not as simple as it seems since many times the next instruction depends on results from the previous one, so you can't finish the next instruction until the previous one is complete. Next 4 instructions: 1. Move data item 1 into register R1 2. Move data item 2 into register R2 3. Add items in R1 and R2, storing result in ACC. 4. Move ACC contents to memory location Z. You can carry out 1 and 2 simultaneously, but you can't do 3 until 1 and 2 are done. You can't do 4 until 3 is done. Input/Output Facilities for entering data and displaying or printing results. The expansion bus is used for transporting data between RAM and the expansion slots. An expansion card, board, or controller card plugs into the expansion card and is used to control an I/O device and pass data to and from the device. An expansion port is housed on an expansion card and its used to connect a cable to an I/O device. Parallel port transmits 8 bits at a time - used to send data to a printer. Serial port transmits one bit at a time - takes 8 times as long to send a byte of data. Used to connect computer to modem. SCSI port (scuzzy) enables you to connect a series of devices to the computer - one after the other in a chain.