Presentation is loading. Please wait.

Presentation is loading. Please wait.

Basics Hardware and Number Representation Adapted by S. Sudarshan from slides provided by: JPC and JWD © 2002 McGraw-Hill, Inc.

Similar presentations


Presentation on theme: "Basics Hardware and Number Representation Adapted by S. Sudarshan from slides provided by: JPC and JWD © 2002 McGraw-Hill, Inc."— Presentation transcript:

1 Basics Hardware and Number Representation Adapted by S. Sudarshan from slides provided by: JPC and JWD © 2002 McGraw-Hill, Inc.

2 Computer Organization CPU - central processing unit Memory Input devices Output devices CPU - central processing unit Where decisions are made, computations are performed, and input/output requests are delegated Memory Stores information being processed by the CPU Input devices Allows people to supply information to computers Output devices Allows people to receive information from computers

3 Computer Organization Memory CPU Input Devices Output Devices bus

4 CPU CPU: Brains of the computer Arithmetic calculations are performed using the Arithmetic/Logical Unit or ALU Control unit decodes and executes instructions Arithmetic operations are performed using binary number system CPU executes instructions which are stored in memory Program = sequence of instructions E.g: 1. Cut potatoes 2. Boil for 10 minutes 3. Fry with salt and pepper

5 “Toy” Instructions Instruction formats: operation.location.location operation.location.value operation value E.g. operation codes: 1 = Set, 4 = read from keyboard 5 = add, 9 = print to screen LocationValueMeaning 11.100.12Set M100 12 24.101Read into M101 35.101.100M101 = M100+M101 49.101Print M101

6 Program Execution Fetch the instruction to which the PC points Increment the Program Counter Execute the fetched instruction Locati on ValueMeaning 11.100.12Set M100 12 24.101Read into M101 35.101.100M101 = M100+M101 49.101Print M101

7 Control Unit The fetch/execute cycle is the steps the CPU takes to execute an instruction Performing the action specified by an instruction is known as executing the instruction The program counter (PC) holds the memory address of the next instruction

8 Input and Output Devices Accessories that allow computer to perform specific tasks Receive information for processing Return the results of processing Store information Accessories that allow computer to perform specific tasks Receive information for processing Return the results of processing Store information Common input and output devices SpeakersMouse Scanner PrinterJoystickCD-ROM KeyboardMicrophoneDVD Accessories that allow computer to perform specific tasks Receive information for processing Return the results of processing Store information Common input and output devices SpeakersMouse Scanner PrinterJoystickCD-ROM KeyboardMicrophoneDVD Some devices are capable of both input and output Floppy driveHard driveMagnetic tape units

9 Examples Linux, Windows ®, UNIX ®, Mac OS X ® Controls and manages the computing resources Important services that an operating system provides File system  Directories, folders, files Commands that allow for manipulation of the file system  Sort, delete, copy Ability to perform input and output on a variety of devices Management of the running systems Time sharing of processes, and protection from each other Operating System

10 Binary Number Representation Early mechanical computers used decimal notation Binary is much easier to implement in electronic computers Switch is On or Off E.g. 0 Volts = 0 3 Volts = 1  Voltages in-between should not occur (except very close to 0 or 3 volts) Storage elements (e.g. “flip-flop” circuits) can be in state 0 or 1 state can be changed by signal

11 The individual digits of a binary number are referred to as bits Each bit represents a power of two Most-significant and least-significant bits 01011 = 0 2 4 + 1 2 3 + 0 2 2 + 1 2 1 + 1 2 0 = 11 00010 = 0 2 4 + 0 2 3 + 0 2 2 + 1 2 1 + 0 2 0 = 2 Binary Arithmetic 00010 + 01011 01101 Binary addition 2 + 11 13 Equivalent decimal addition 4 3 2 1 0 ( Power of 2)

12 Logic Circuits Basic logic circuits: AND, OR, NOT AND OR NOT 0 1 0 0 0 1 0 1 B A 0 1 0 0 1 1 1 1 B A A 0 1 1 0

13 Binary Addition 1.S0 = (A0 or B0) and not (A0 and B0) 2.C1 = A0 and B0 3.S1 = (C1 and A1 and B1) or (C1 and (not A1) and (not B1)) or ((not C1) and A1 and (not B1)) or ((not C1) and (not A1) and B1) 4.C2 = (C1 and A1) or (C1 and B1) or (A1 and B1) 5.Ci, Si similarly defined for other i C carry 00010 A + 01011 B 01101 S sum 4 3 2 1 0 AND OR NOT AND A0 B0 S0

14 Binary Arithmetic 5 ×11 55 Equivalent decimal multiplication 0101 × 1011 0101 0000 0101 0110111 Binary multiplication Implemented in hardware using multiple shift-left and add steps Shift A left to multiply by B1 (= 2 1 ) A B Since B2 = 0 Manual verification: 32 + 16 + 4 + 2 + 1 = 55

15 Negative Numbers: Two’s Complement Representation for signed binary numbers Leading bit is a sign bit Binary number with leading 0 is positive Binary number with leading 1 is negative Magnitude of positive numbers is just the binary representation Magnitude of negative numbers is found by Complement the bits Replace all the 1's with 0's, and all the 0's with 1's Add one to the complemented number The carry in the most significant bit position is thrown away when performing arithmetic Why this complexity? To allow addition to work the same way for +ve and –ve numbers

16 Two’s Complement Performing two's complement on the decimal 7 to get -7 Using a five-bit representation 7 = 00111 Convert to binary 11000 Complement the bits 11000 Add 1 to the complement + 00001 11001 Result is -7 in two's complement

17 Two's Complement Arithmetic Computing 8 - 7 using a two's complement representation with five- bit numbers 8 - 7 = 8 + (-7) = 1 01000 Two's complement representation of 8 11001 Two's complement representation of -7 01000 Add 8 and -7 + 11001 100001 00001 Is the five-bit result Throw away the high-order carry as we are using a five bit representation

18 Overflow in 2’s Complement With 5 bits, what is 15 + 15? 01111 + 01111 = 11110  which represents -2 (Flip bits to get 00001, add 1 to get 00010) What happened? Overflow With 5 bits, maximum unsigned number is 1+2+4+8+16=31, but maximum 2’s complement number is 15 (min is -16)

19 Real Numbers “Floating point” representation E.g. 3.1415 =.31415 x 10 1 3141.5 =.31415 x 10 4 0.0031415 =.31415 x 10 -2 - 31.415 = -.31415 x 10 2 Note that.31415 = 3 x 10 -1 + 1 x 10 -2 + 4 x 10 -3 + 1 x 10 -4 + 5 x 10 -5 2-part number representation: Mantissa: fractional part (in binary), with sign Exponent: power of 2, with sign In C/C++ notation: 0.31415E1 = 3.1415 -0.31415E-1 = -.031415

20 Binary Floating Point Representation In binary:.1011 = 1 x 2 -1 + 0 x 2 -2 + 1 x 2 -3 + 1 x 2 -4 101.1 =.1011 x 2 3 2-part number representation: Mantissa: fractional part (in binary, with sign) Exponent: power of 2 (in binary, with sign) Total number of bits divided into sign, mantissa, and exponent  E.g. 32 bits: 21 bit mantissa (1 sign bit + 20 bits), 11 bit exponent (1 sign bit + 10 bits)  Gives 10 bits for exponent and exponent from 2 -10 to 2 10 Numbers up to 2 power 2 10 ExponentMantissa

21 Floating Point Standards IEEE 754 Floating point standard Special codes for +/- infinity, not-a-number (NaN)  +0 and -0 32 bit (Single precision)  sign bit  Exponent uses 8-bit “biased” representation (store exponent+127) Exponent range from -126 to + 127  Mantissa (fraction) is 23 bit 64 bit (Double precision) for computations that require greater precision  sign bit  11 bit exponent (store exponent + 1023) and  52 bit mantissa

22 Arithmetic on Real Numbers Arithmetic on real numbers more complicated Most ALU (arithmetic and logic units) do only integer arithmetic Real (floating point) arithmetic is done in software on some low-end processors in a floating-point unit on most modern processors Most processors today support single and double precision floating point arithmetic

23 Computer Organization Memory CPU Input Devices Output Devices CPU Memory Address+Control Bus Data Bus

24 Memory Units of memory 1 bit: 0 or 1 Byte = 8 bits Word: depends on CPU, typically 32 bits (4 bytes) 1 Kilobyte(KB) = 2 10 = 1024 bytes 1 Megabyte (MB) = 2 20 = 1024 Kilobytes 1 Gigabyte (GB) = 23 0 = 1024 Megabytes Main memory (Random Access Memory, or RAM) fast, but volatile (i.e. contents lost on power off) access time ~ 100 nano sec (nano = 10 -9 )  Random access: to any specified part of memory typical capacity today: 512 MB to a few GB

25 Magnetic Disks Magnetic disk Data stored magnetically on disk platter typical capacity today: 80 GB to 400 GB Per-byte cost << main memory data retained even if power is off To read from a specific disk location  Read/write head (disk arm) moves to correct distance from center  Disk rotates till specific location is under the head. Random access is slow  5 milliseconds to read a randomly specified piece of data Sequential access (once head has reached location) is fast  40 MB/sec to 80 MB/sec today

26 Other Forms of Memory Optical disk (CD, DVD) Flash memory Memory is preserved even on power off In between main memory and disk in terms of  cost per byte  memory size (few GB typical today)  speed of access (close to main memory) Widely used, e.g.  Mobile phones  Digital cameras  USB keys (Pen drive) for transferring data

27 CPU Processors have a clock that “ticks” (1 tick = 1cycle) Nominally one instruction per clock cycle  Usually much less because memory is slower Clock speeds today: a few Gigahertz Can have multiple processors executing different programs in parallel Were very expensive earlier, widely available today  E.g. Pentium Core Duo: 2 processors

28 Communication Technologies Serial port / Parallel port: old technologies E.g. old mice, keyboards, printers USB (Universal Serial Bus): connection between computer and peripherals E.g. computer to mobile phone IDE/SATA/.. : connection technologies to connect hard disks to computers Don’t worry about what the names mean! Ethernet: connection to computer networks 100 Mb/sec to 1Gb/sec (Mb = Megabit, Gb = Gigabit) Optical fiber: backbone of computer networks Multiple 1 to 10 Gb/sec channels per fiber

29 Communication (Cont.) Wireless Communication Bluetooth: standard for short distances of a few metres  slow (1 Mb/sec) WiFi: standard for communication within a few 10s to 100 metres  High speed (10 to 50 Mb/sec) GSM/CDMA: mobile phone protocols  several kilometres, but very slow (and expensive) for data typical 14 Kb/sec Faster long distance protocols under development (WiMax)

30 Monitor Pixel: single dot on screen Screen: 2-D array of pixels Resolution: number of pixels along each axis E.g. 1280x1024, 1024 x 768, 800x600 Widescreen (e.g.): 1366x768, 1920x1200 Bits per pixel 3 colors (Red, Green, Blue) per pixel 8 bits/color typical  = 24 bits, or 3 Bytes per pixel 1024x1024 screen: 3 MB memory for screen (Graphics memory)


Download ppt "Basics Hardware and Number Representation Adapted by S. Sudarshan from slides provided by: JPC and JWD © 2002 McGraw-Hill, Inc."

Similar presentations


Ads by Google