Computer Organisation And Architecture - Auckland

Transcription

Computer Organisation and Architecture David J. Scott Department of Statistics, University of AucklandComputer Organisation and Architecture – p.1/

OutlineComponents of a computer systemDigital circuitsRepresentation of information Operating systemsComputer Organisation and Architecture – p.2/

Resources Introduction to Computers by Grassroots Design, available atSuggested sections:HardwareSoftware Peter Norton’s Guide to Computers available atSuggested lessons: 1, 7, 9, 28The Fifth Edition PowerPoint lessons are excruciatinglydull For a hard-core treatment, see Jonathan G Campbell LectureNotes on Computer Systems and Operating Systems availableatComputer Organisation and Architecture – p.3/

Resources howstuffworks at Suggested sections, under Electronics Stuff:How Bits and Bytes Work,How Computer Memory Works,How Microprocessors Work,How Operating Systems Work,How PCs WorkUnder Computer Stuff:How Boolean Logic WorksComputer Organisation and Architecture – p.4/

Components of a Computer SystemComputer Organisation and Architecture – p.5/

ComputersA working computer requires hardware and softwareHardware: the computer’s physical and electronic componentsinput devicesa central processing unit (CPU)memory-storage devicesoutput devicesLinked together by a communication network or bus (seediagrams) Software: the programs that instruct the hardware to performtasksOperating system softwareApplications softwareComputer Organisation and Architecture – p.6/

Input DevicesKeyboardMouseCamera, still or videoMicrophoneJoystick, trackball Lightpens, touch screens, digitizer pads, optical scanners,voice-recognition circuitryComputer Organisation and Architecture – p.7/

CPUPerforms arithmetic and logic operations on dataTimes and controls the rest of the systemLarger computers have a CPU with several linked microchips,called microprocessors, performing separate tasksSmaller computers have a single microprocessor Most CPUs have 3 functional sectionsarithmetic/logic unit (ALU) for arithmetic and logicoperationstemporary storage, called registers for data, instructions orintermediate results of calculationscontrol section, times and regulates all elements of thecomputer system, translates register patterns intocomputer activitiesComputer Organisation and Architecture – p.8/

Clock and Clock SpeedA very fast clock times and regulates the CPUEach clock tick or cycle causes each part of the CPU to beginits next operation and to stay synchronized with the other partsA fast computer requires a fast clock, speed measured incycles per second, or hertz (Hz)Typical desktop speeds are 1 to 4 gigahertz (GHz) or billioncycles per second Simple operations (e.g. copying) take 1 to 2 cycles, others(e.g. division) up to dozens of cyclesComputer Organisation and Architecture – p.9/

Memory-Storage DevicesStorage can be internal or external (auxiliary) Internal storageMain memory or random access memory (RAM)Each byte can be stored and retrieved directly rather thansequentiallyComprised of memory chips soldered onto printed circuitboards or plugged into sockets on the motherboardAlso called read/write memoryOther memory is read-only memory (ROM)Persists with no power, used to boot up the computer andcarry out basic operationsBoth hardware and software: firmwareComputer Organisation and Architecture – p.10/

Auxiliary StorageHard disks, floppy disks, magnetic tapeStore data magnetically by rearranging metal particles ontheir surfacesTape drives store huge amounts of data, used for backingupFlash drives are solid state electronic storage, combinerecordability of RAM with persistence of ROM Optical disks encode data as a series of pits and flat spaces,read by a laserComputer Organisation and Architecture – p.11/

Output DevicesVideo display terminal (VDT) or monitor, either a cathode-raytube (CRT) or liquid-crystal display (LCD)Modem (modulater-demodulator) converts digital signal toanalogue for transmission over telephone linesA DSL or digital subscriber line modem does the transfer if thetelephone line is digitalA wireless modem converts the digital signal tohigh-frequency radio waves Printers are used for hard copyComputer Organisation and Architecture – p.12/

Digital CircuitsComputer Organisation and Architecture – p.13/

Logic GatesDigital circuits are complicated combinations of logic gatesGates are usually implemented electronically using diodes ortransistorsA logic gate takes one or more logic level (0 or 1, or TRUE orFALSE) inputs and produces a single logic output There are a few basic gates: NOT, AND, OR, NAND, NOR,XOR, XNOR, which are defined by their truth tablesComputer Organisation and Architecture – p.14/

Logic GatesFor example a NOT gate is a simple inverter: it takes a singleinput and 0 input produces 1, 1 input produces 0Below are the truth table for a NOT gate and the symbol usedto represent it in a circuit diagram OutputNot A10 InputA01Computer Organisation and Architecture – p.15/

Logic GatesA NAND gate is a NOT AND gate, it takes two inputs andproduces 0 only when both inputs are 1The X in XOR and XNOR means exclusive, for example theXOR takes two inputs and is like an OR gate except itexcludes the case of both inputs being 1The truth table and diagram for an OR gate are shown below OutputA OR B0111 InputA B0 00 11 01 1Computer Organisation and Architecture – p.16/

Digital CircuitsCombining two NAND gates or NOR gates with feedback fromone to the other creates a flip-flop which can be used to storea single binary digit or bitStatic RAM for registers is built out of flip-flops A half adder can be built out of an XOR and an AND gate, ittakes two binary inputs and produces the sum and a carry bitComputer Organisation and Architecture – p.17/

Digital CircuitsA full adder performs addition on two binary digits and a carryin bit to produce a sum and a carry valueFull adders may be combined to produced an adder for twobinary words, say 16, 32 or 64 bits If 2’s complement representation is used to represent negativenumbers, it is easy to modify an adder to be anadder-subtracterComputer Organisation and Architecture – p.18/

Information RepresentationComputer Organisation and Architecture – p.19/

Binary DataAll data in a computer is stored in binary formatA bit is single binary digitA byte is eight binary digitsThe size of a word varies from computer to computer Commonly a word is a number of bytes with moderncomputers being 4 bytes or 32 bits, or increasingly 8 bytes or64 bitsComputer Organisation and Architecture – p.20/

Representing Text This allows Character data is commonly stored as one byte per characterdifferent characters to be representedCommonly the representation used is ASCII (AmericanStandard Code for Information Interchange)The English letters (upper and lower case) and specialcharacters ( ,%, etc) and characters for special actions suchas NL for new line take up only 7 bits (128 characters) One use for the remaining 128 characters is for foreignlanguage symbols ä,é,å,ç, Unicode is an industry standard using two bytes to representand manipulate text in any of the world’s writing systems(Latin, Cyrillic, Hangeul, Arabic, Devanagari, Syllabaries,Chinese Characters) comprises about 100,000 charactersComputer Organisation and Architecture – p.21/

Representing IntegersRepresenting decimal numbers as one character per byte isvery wastefulNumbers are stored as binary with various encodingsWith the standard conversion of decimal integers to binaryintegers, in one byte, the numbers 0 to 255 are represented by0000 0000 (2) 0 (10) to 1111 1111 (2) 255 (10)where decimal numbers in parentheses indicate the baseTo represent more numbers, use more bytes What about negative numbers? Use 1 bit for the sign, givessigned magnitude representationComputer Organisation and Architecture – p.22/

Signed Magnitude Representation Decimal Binary-7 1111-6 1110-5 1101.-1 1001-0 10000 00001 0001.5 01016 01107 0111Computer Organisation and Architecture – p.23/

different numbers 32 bits allows for Representing Integersnumbers. Why? Signed magnitude would allow onlyOther encodings also permit easier construction of deviceswhich can both add and subtractCommonly 2’s complement is used to encode negativenumbers Start with 1’s complement where the rule to represent aninteger isif is positive, the binary representation is the same asthe signed magnitude formif is negative take the 1’s complement form of(apositive number) and complement itComputer Organisation and Architecture – p.24/

1’s Complement Representation Decimal Binary-7 1000-6 1001-5 1010.-1 1110-0 11110 00001 0001.5 01016 01107 0111Computer Organisation and Architecture – p.25/

Representing IntegersTwo 1’s complement numbers can be added withoutconsidering their signs, provided that the sign bits are addedalso, and if there is a carry, the carry is added on the right(called end-around carry)With one byte, 1’s complement encodes -127 to -0 as1000 0000 to 1111 1111, instead of1111 1111 to 1000 0000, in signed magnitude2’s complement: add 1 to the 1’s complement (ignoringoverflow) Encode -128 to -1 as 1000 0000 to 1111 1111Computer Organisation and Architecture – p.26/

2’s Complement Representation Decimal Binary-8 1000-7 1001-6 1010-5 1011.-1 1111-0 00000 00001 0001.5 01016 01107 0111Computer Organisation and Architecture – p.27/

Representing Real NumbersFixed point: 1 bit for sign, some bits for integral part,remaining bits for fractional partDisadvantages: overflow occurs very readily because therange of the numbers representable is very small Overflow: getting an answer too large to be representedComputer Organisation and Architecture – p.28/

Representing Real Numbers Floating point: like scientific notation, e.g. represent36752010000000000000 asThe numbers in front giving the value comprise the mantissa,then comes the base (10 in this case) raised to the powergiven by the exponentIn a computer the base is 2. , while in binary, the first bit With base 10,mantissaafter the point is a 1. In normalised floating point form, the mantissa has onlyzeroes before the decimal or binary point. Since the first bit is a 1, it can be dropped effectively giving anextra bit for the the mantissaComputer Organisation and Architecture – p.29/

Representing Real NumbersTypical computer representation with a 32 bit word might be: 1sign bit, 8 bits for the exponent, 23 for the mantissaThen exponents are in the range -128 to 127 (using 2’scomplement say)Floating point numbers have large range but are not spreadevenly over lineWe can still have overflow, but also underflow, and roundofferror Zero is usually represented by zero mantissa and largestnegative exponentComputer Organisation and Architecture – p.30/

' %& !#" Floating Point CalculationsCan you explain the following?Computer Organisation and Architecture – p.31/

Floating Point CalculationsFloating point operations do not necessarily obey the laws ofarithmetic. In particular Addition need not be associative: Multiplication need not be associative: Multiplication may not be distributive over addition: Cancellation may not apply:does not mean Order of operations may be important:Computer Organisation and Architecture – p.32/

Operating SystemsComputer Organisation and Architecture – p.33/

What is an Operating System?An operating system is a set of computer programs thatmanage the hardware and software resources of a computerPerforms basic taskscontrolling and allocating memoryprioritizing system requestscontrolling input and output devicesfacilitating networkingmanaging file systems The interface to the operating system can be a command lineinterpreter or a graphical user interface (GUI)Computer Organisation and Architecture – p.34/

Process ManagementEvery program is a process (see the Task Manager on aWindows computer)Running multiple processes is called multitasking: carried outby rapid switching between programs (time slicing)Processes are assigned a priority Interrupt driven processes generally receive high priorityComputer Organisation and Architecture – p.35/

Memory ManagementOrganisation is hierarchical: fastest to slowestRegisters, CPU cache, RAM, disk storageOS coordinates availability, allocation and deallocation,moving data between storageLimited size of RAM is overcome by the operating systemusing virtual memory: swapping data in from disk as neededin a transparent manner When processes require more memory than is available thiscan lead to thrashing where the computer spends all its timetransferring data and none doing any real workComputer Organisation and Architecture – p.36/

SecurityAccess to resources such as files, sensitive system calls,Distinguish between different users to determine access toresources Allow or disallow network requests for access: firewalls areusedComputer Organisation and Architecture – p.37/

Device DriversEach device connected to the computer has a device driverControls interaction between the device and the computer The operating system provides generic support for types ofdevice, a device driver translates the generic operationsprovided by the operating system into device specific callsComputer Organisation and Architecture – p.38/

Computers A working computer requires hardware and software Hardware: the computer's physical and electronic components input devices a central processing unit (CPU) memory-storage devices output devices Linked together by a communication network or bus (see diagrams) Software: the programs that instruct the hardware to perform tasks