Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
Information Representation How to count like a computer? Ashok K Nagawat Joint Director, Centre for Converging Technologies Coordinator, Infonet Center Deputy Director, CDPE Associate Professor, Deptt. of Physics Associate Member, Institute of Informatics and Instrumentation • In order to understand what happens inside a computer we must understand how a computer represents information internally. Analogue Computer Digital Computer Quantum Computer University of Rajasthan, Jaipur [email protected] Digital Computer – A digital system performing computational tasks. – Represents information using variables that take a limited number of discrete values. – Processes these values internally Radix Number Systems Each number system has a number of different digits which is called the radix or the base of the number system. • • • • Decimal Octal Hexadecimal (Hex) Binary Positional Notation Decimal Number System Base (Radix) Digits e.g. 10 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 747510 The magnitude represented by a digit is decided by the position of the digit within the number. 1000 100 10 1 7 4 7 5 For example the digit 7 in the left-most position of 7475 counts for 7000 and the digit 7 in the second position from the right counts for 70. Base = 10 Base = 8 Base = 16 Base = 2 642 in base 10 positional notation is: 6 x 102 = 6 x 100 = 600 + 4 x 101 = 4 x 10 = 40 + 2 x 10º = 2 x 1 = 2 = 642 in base 10 This number is in base 10 The power indicates the position of the number 1 Positional Notation R is the base of the number As a formula: Positional Notation What if 642 has the base of 13? + 6 x 132 = 6 x 169 = 1014 + 4 x 131 = 4 x 13 = 52 + 2 x 13º = 2 x 1 = 2 = 1068 in base 10 dn * Rn-1 + dn-1 * Rn-2 + ... + d2 * R + d1 n is the number of digits in the number d is the digit in the ith position in the number 642 is 63 * 102 + 42 * 10 + 21 642 in base 13 is equivalent to 1068 in base 10 6 Bases Higher than 10 How are digits in bases higher than 10 represented? Hexadecimal Number System Base (Radix) Digits e.g. With distinct symbols for 10 and above. Base 16 has 16 digits: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E, and F 16 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F 2F4D 16 4096=163 256=162 2 16=161 F 4 1=160 D The digit F in the third position from the right represents the value 3840 and the digit D in the first position from the right represents the value 1. Converting Hexadecimal to Decimal What is the decimal equivalent of the hexadecimal number DEF? 162 Dx = 13 x 256 = 3328 + E x 161 = 14 x 16 = 224 + F x 16º = 15 x 1 = 15 = 3567 in base 10 Remember, the digits in base 16 are 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F Octal Number System Base (Radix) Digits e.g. 512=83 1 8 0, 1, 2, 3, 4, 5, 6, 7 16238 64=82 6 8=81 2 1=80 3 The digit 2 in the second position from the right represents the value 16 and the digit 1 in the fourth position from the right represents the value 512. 2 Converting Octal to Decimal What is the decimal equivalent of the octal number 642? 6 x 82 = 6 x 64 = 384 + 4 x 81 = 4 x 8 = 32 + 2 x 8º = 2 x 1 = 2 = 418 in base 10 Binary Number System Base (Radix) Digits e.g. 2 0, 1 11102 1 Decimal is base 10 and has 10 digits: 0,1,2,3,4,5,6,7,8,9 Binary is base 2 and has 2 digits: 0,1 For a number to exist in a given number system, the number system must include those digits. For example, the number 284 only exists in base 9 and higher. Converting Binary to Decimal What is the decimal equivalent of the binary number 1101110? 8=23 4=22 2=21 1=20 1 Binary 1 0 The digit 1 in the third position from the right represents the value 4 and the digit 1 in the fourth position from the right represents the value 8. Why Binary? • For example, the text you are reading is stored on a computer disk. It was entered into a computer system using Powerpoint. • Inside the computer’s memory and on the disk this text (and all other information) can be thought of as being represented by a very long sequence of ones and zeros, i.e. in binary form. 1 x 26 + 1 x 25 + 0 x 24 + 1 x 23 + 1 x 22 + 1 x 21 + 0 x 2º = = = = = = = 1 x 64 1 x 32 0 x 16 1x8 1x4 1x2 0x1 = 64 = 32 =0 =8 =4 =2 =0 = 110 in base 10 Why Binary? • The basic unit of storage in a computer is the bit (binary digit), which can have one of just two values: 0 or 1. • This is easier to implement in hardware than a unit that can take on 10 different values. – For instance, it can be represented by a transistor being off (0) or on (1). – Alternatively, it can be a magnetic stripe that is magnetized with North in one direction (0) or the opposite (1). • Binary also has a convenient and natural association with logical values of False (0) and True (1). 3 Information Representation in Binary Digital Computer Information Representation • It appears as text only on a computer’s monitor or on printed output. • A computer monitor’s hardware receives binary information and transforms it to the symbols that are displayed. • Similarly, a printer’s hardware converts binary information to the text (or graphic) that is printed. • Inside the CPU and the computer’s memory, information is actually stored and transmitted in electrical form, while on disk it is stored in magnetic form. • A particular electrical signal represents a one and another signal represents a zero. Similarly, a specific magnetic orientation represents a one and another orientation represents a zero. A group of these binary digits (bits) can be considered to form a binary code and information is encoded as a sequence of individual units each of which correspond to a distinct binary code. Fundamental Principle Building on Binary • Binary bits are grouped together to allow them to represent more information: • All information is represented by binary codes in a binary digital computer system. Building on Binary • Clearly, the number of possible combinations of a group of N bits is 2N = 2x2x2 … x2 (N 2s). Thus: – A nybble can form 24=16 combinations – A byte can form 28=256 combinations – A 32-bit word can form 232=4,294,967,296 combinations – A nybble is a group of 4 bits, e.g. 1011 – A byte is a group of 8 bits, e.g. 11010010 – A word is a larger grouping: usually 32 bits. A halfword is half as many bits as a word, thus usually 16 bits. A doubleword is twice as many bits, usually 64 bits. However, computers have been designed with various word sizes, such as 36, 48, or 60 bits. Converting Binary to Octal • Groups of Three (from right) • Convert each group 10101011 10 101 011 2 5 3 10101011 is 253 in base 8 4 Converting Binary to Hexadecimal • Groups of Four (from right) • Convert each group 10101011 1010 1011 A B 10101011 is AB in base 16 Converting Decimal to Other Bases Algorithm for converting base 10 to other bases While the quotient is not zero Divide the decimal number by the new base Make the remainder the next digit to the left in the answer Replace the original dividend with the quotient Converting Decimal to Hexadecimal Converting Decimal to Hexadecimal 222 16 3567 32 36 32 47 32 15 Try a Conversion The base 10 number 3567 is what number in base 16? 13 16 222 16 62 48 14 0 16 13 0 13 F E D Binary Arithmetic • Addition Binary Addition (a) •Complements •Subtraction (c) 0 +0 0 1 +0 1 0 +1 1 (b) (d) 1 +1 10 Carry Bit 5 Binary Complement Binary Addition Examples 1011 + 1100 10111 (a) (b) 1010 + 100 1110 (c) (1s Complement) Operation 1011 + 101 10000 1 0 0 1 Example (d) 101 + 1001 1110 110010110 10011001 + 101100 11000101 (e) Two’s Complement The Two’s complement of a binary number is obtained by first complementing the number and then adding 1 to the result. 1001110 0110001 + 1 One’s Complement 0110010 Two’s Complement 001101001 Binary Subtraction Binary subtraction is implemented by adding the Two’s complement of the number to be subtracted. Two’s Example complement of 1001 1101 -1001 1101 +0111 10100 If there is a carry then it is ignored. Thus, the answer is 0100. BCD – Binary Coded Decimal Binary Codes A binary code is a group of n bits that assume up to 2n distinct combinations of 1’s and 0’s with each combination representing one element of the set that is being coded. • BCD – Binary Coded Decimal • ASCII – American Standard Code for Information Interchange When the decimal numbers are represented in BCD, each decimal digit is represented by the equivalent BCD code. Example :BCD Representation of Decimal 6349 6 3 4 9 0110 0011 0100 1001 Decimal Number BCD Number 0 1 2 3 4 5 6 7 8 9 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 6 ASCII Number ASCII 0 1 2 3 4 5 6 7 8 9 0110000 0110001 0110010 0110011 0110100 0110101 0110110 0110111 0111000 0111001 Letter A B C D E F G H I ASCII 1000001 1000010 1000011 1000100 1000101 1000110 1000111 1001000 1001001 Logic Gates ASCII Continued. Letter ASCII J 1001010 K 1001011 L 1001100 M 1001101 N 1001110 O 1001111 P 1010000 Q 1010001 R 1010010 Letter ASCII S 1010011 T 1010100 U 1010101 V 1010110 W 1010111 X 1011000 Y 1011001 Z 1011010 Logic Gates Contd… • Binary information is represented in digital computers by physical quantities called signals. • A particular logic operation can be described in an algebraic or tabular form. • Two different electrical voltage levels such as 3 volts and 0.5 volts may be used to represent binary 1 and 0. • Binary logic deals with binary variables and with operations that assume a logical meaning. • The manipulation of binary information is done by the circuits called logic gates which are blocks of hardware that produce signals of binary 1 or 0 when input logic requirements are satisfied. Logic Gates Contd… • Each gate has a distinct graphics symbol and it’s operation can be described by means of an algebraic expression or in a form of a table called the truth table. • Each gate has one or more binary inputs and one binary output. Logic Gates – AND – OR – NOT (Inverter) – NAND (Not AND) – NOR (Not OR) – XOR (Exclusive-OR) – Exclusive-NOR 7 Logic Gates •AND Table Logic Gates Cont. Logic Gate A B Truth x x=A.B A, B Binary Input Variables x Binary Output Variable Logic Gates •NOT Table AB 0 0 0 1 1 0 1 1 A B x=A+B Truth •NAND A x 0 1 1 0 A B x Logic Gates Logic Gate A B x=A+B Truth x x 0 1 1 1 AB 0 0 0 1 1 0 1 1 x 1 0 0 0 •XOR Table Truth Table x Logic Gates Cont. Logic Gate AB 0 0 0 1 1 0 1 1 Cont. x=A.B x=A •NOR Table x Logic Gates Logic Gate Truth This is read as x equals A or B. Cont. A Logic Gate •OR Table x 0 0 0 1 Cont. x=A+B x 1 1 1 0 Cont. Logic Gate A B AB 0 0 0 1 1 0 1 1 x Truth AB 0 0 0 1 1 0 1 1 x 0 1 1 0 8 Logic Gates Basic logic gates Cont. •Exclusive-NOR Logic Gate A B x x=A+B Truth Table AB 0 0 0 1 1 0 1 1 x 1 0 0 1 • Not • And x y z xyz • Or • Nand • Nor • Xor Completeness of NAND Using A Single Gate Type • It is desirable to use only one type of gate generate the whole circuit. • Can use NAND or NOR gate. • In order to do so, enough to show that – NOT, AND, OR NAND can be generated by NOR gates – NOT, AND, OR, NOR ca be generated by NAND gates. • We say that NAND, NOR are complete for Boolean circuits Completeness of NOR Integrated Circuits • Most gates are attached together to build Integrated Circuits (IC’s) • They are mounted on Plastic or Ceramic with some combination of pins for input/output, power and ground connections • Types base on number of gates: – – – – (SSI) Small Scale Integrated Circuit: 1 to 10 (MSI) Medium Scale IC: 10 to 100 (LSI) Large Scale IC: 100 to 100,000 (VLSI) Very Large Scale IC: Over 100,100 • The current Intel Pentium IV processors have 55 million transistors! 9