CS149: Elements of Computer Science Data representation 0=low, 1=high 1. Format (b) More intermediate levels = higher (a) Computers use binary system to error rate represent information (c) Rationale is underlying (b) Bit = binary digit, or { 0 , 1 } electronics: logic gates (c) byte = 8 bits, kilobyte (kb) = 1024 3. Two problems: bytes, megabyte (mb) = 1024 2 (a) How to store and manipulate these bytes, gigabyte = 1024 3 bytes bits? 2. Why binary? (b) How to represent information (a) Corresponds to levels of voltage, using only 0s and 1s? Johan Bollen - http://www.cs.odu.edu/˜jbollen January 18, 2004 Page 1
CS149: Elements of Computer Science Bit storage and manipulations: Boolean logic and gates (b) OR: Raven are white OR the • Boolean logic: sky is blue 1. Two valued logic (c) XOR: Raven are black XOR (a) Statements are either TRUE the sky is blue and FALSE (d) NOT: NOT Raven are black (b) True=1 and FALSE=0 • Implemented by logic gates: (c) Remember: this is formal 1. Little machines that take one or logic. Truth or falsehood of two inputs (TRUE/FALSE, O/1) statement is determined and perform AND, OR, XOR or syntactically, not on empirical NOT operation grounds! 2. Actual mechanical 2. Operations to combine statements: implementation changes (relays, truth of combined statement ICs, manual switches) depends on truth of separate statements and operation 3. Heart of information processing in (a) AND: Raven are white AND computers the sky is blue Johan Bollen - http://www.cs.odu.edu/˜jbollen January 18, 2004 Page 2
CS149: Elements of Computer Science Boolean Logic: AND Logic: about truth or falsity. Example: Determination of truth value for statement C: Statement C = A AND B Statement A: The weather is dry. Statement B: It is warm. Statement C tell us whether it is true that the weather is good... Johan Bollen - http://www.cs.odu.edu/˜jbollen January 18, 2004 Page 3
CS149: Elements of Computer Science Boolean Logic: OR Example: Determination of truth value for statement C: Statement C = A OR B Statement A: It snows Statement B: It rains Statement C tell us whether it is true that we had any precipitation today. Johan Bollen - http://www.cs.odu.edu/˜jbollen January 18, 2004 Page 4
CS149: Elements of Computer Science Boolean Logic: XOR Example: Assume we have a dam with releases. Closing a release holds more water in the reservoir lake and will cause it to gradually fill. However, if two releases are closed the reservoir lake threatens to overflow. We therefore built a mechanism that opens the dam when the lake overflows. It empties the lake. Determination of truth value for statement C: Statement C = A XOR B Statement A: release 1 is closed Statement B: release 2 is closed Statement C tell us whether it is true that we have filled the reservoir lake. Johan Bollen - http://www.cs.odu.edu/˜jbollen January 18, 2004 Page 5
CS149: Elements of Computer Science Boolean Logic: NOT Statement A: Ken is a liar. Statement C = NOT A Statement C tell us what Ken is not. Wait a minute...What happens when Ken issues statement A...? Johan Bollen - http://www.cs.odu.edu/˜jbollen January 18, 2004 Page 6
CS149: Elements of Computer Science Boolean logic and gates 2. Correspond to Boolean logic • Logic gates: electronic components operations that respond to input values, e.g. low 3. Operate on two binary input (0) and high (1), by generating specific values: false-true, yes-no, 0-1 output values 4. Resulting output for given inputs 1. Four types of gates correspond to listed in truth tables for each type 4 basic operations: AND, OR, • Truth tables: XOR, and NOT AND OR XOR Inp Out In Out In Out NOT 0 0 0 0 0 0 0 0 0 Inp Out 0 1 0 0 1 1 0 1 1 0 1 1 0 0 1 0 1 1 0 1 1 0 1 1 1 1 1 1 1 1 0 Johan Bollen - http://www.cs.odu.edu/˜jbollen January 18, 2004 Page 7
CS149: Elements of Computer Science Representation Johan Bollen - http://www.cs.odu.edu/˜jbollen January 18, 2004 Page 8
CS149: Elements of Computer Science Combining gates NOT (A AND B) circuit 1. Circuits: (a) Can perform very complex functions: in fact ALL dig- ital computer functions are implemented by combina- tions of logic gates! (b) Output of one gate is fed C = AB into another’s input (c) Values cascade through system and final output values are generated Johan Bollen - http://www.cs.odu.edu/˜jbollen January 18, 2004 Page 9
CS149: Elements of Computer Science NOT ((NOT B AND A) OR C) circuit C = BA + C a a black dots are connectors: they are not gates Johan Bollen - http://www.cs.odu.edu/˜jbollen January 18, 2004 Page 10
CS149: Elements of Computer Science How to generate a truth table for a given circuit at right most columns, use 1. Values cascade through system starting “doubling” technique discussed in from inputs to outputs class 2. Your objective is to find output values 5. Start at first row for every possible combination of (a) mark input values at appropriate input values channels 3. Identify the input and output channels (b) Start propagating values through 4. Generate blank table: gates, write down gate output (a) First columns (left to right) are values input channels (c) When values finally recombine at (b) Last columns are output channels output channel, write down value (c) Write down all possible in appropriate column combinations of input values: start Johan Bollen - http://www.cs.odu.edu/˜jbollen January 18, 2004 Page 11
CS149: Elements of Computer Science Example: bit equality comparator A B C 0 0 1 0 1 0 C = AB + AB 1 0 0 1 1 1 Johan Bollen - http://www.cs.odu.edu/˜jbollen January 18, 2004 Page 12
CS149: Elements of Computer Science Example: three inputs A B C D 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 Johan Bollen - http://www.cs.odu.edu/˜jbollen January 18, 2004 Page 13
CS149: Elements of Computer Science Information storage: Flip-Flop Memory Element Johan Bollen - http://www.cs.odu.edu/˜jbollen January 18, 2004 Page 14
CS149: Elements of Computer Science 2. Exercise: 1. Memory: Collection of 0’s and 1’s (a) Generate truth table for flipflop saved as status of flipflops. above (a) Flipflop collections store large (b) Determine how value can be reset number of bits and changed (b) Each flipflop or collection can be addressed individually for retrieval Johan Bollen - http://www.cs.odu.edu/˜jbollen January 18, 2004 Page 15
CS149: Elements of Computer Science Information Representation 1. Information (a) Text (b) Numbers (c) Images (d) Sounds 2. Challenge: representation as 0’s and 1’s Johan Bollen - http://www.cs.odu.edu/˜jbollen January 18, 2004 Page 16
CS149: Elements of Computer Science Binary Message sent Arecibo Radio Telescope Johan Bollen - http://www.cs.odu.edu/˜jbollen January 18, 2004 Page 17
CS149: Elements of Computer Science Text Representation 1. ASCII (American Standard Code for Information Exchange) code: (a) Each characters matches a 1 byte bit sequence i. 1 byte: 8 bits ii. example: 01000101= ’E’ (b) 1 byte ˜ 256 characters i. 4 groups of 32 chars: A. Control characters B. Punctuation, misc., and numeric C. Upper case alphabetic D. Lower case alphabetic ii. Remaining 128 values: miscellaneous (c) Example: ’Hello.’: 01001000 01100101 01101100 01101100 01101111 00101110 Johan Bollen - http://www.cs.odu.edu/˜jbollen January 18, 2004 Page 18
CS149: Elements of Computer Science ASCII Table: GROUP 1 00000000 NUL 00000001 SOH 00000010 STX 00000011 ETX 00000100 EOT 00000101 ENQ 00000110 ACK 00000111 BEL 00001000 BS 00001001 HT 00001010 LF 00001011 VT 00001100 FF 00001101 CR 00001110 SO 00001111 SI 00010000 DLE 00010001 DC1 00010010 DC2 00010011 DC3 00010100 DC4 00010101 NAK 00010110 SYN 00010111 ETB 00011000 CAN 00011001 EM 00011010 SUB 00011011 ESC 00011100 FS 00011101 GS 00011110 RS 00011111 US 00100000 SP Johan Bollen - http://www.cs.odu.edu/˜jbollen January 18, 2004 Page 19
CS149: Elements of Computer Science ASCII Table: GROUP 2 00100001 ! 00100010 ” 00100011 # 00100100 $ 00100101 % 00100110 & 00100111 ’ 00101000 ( 00101001 ) 00101010 * 00101011 + 00101100 , 00101110 . 00101111 / 00101101 00110000 0 00110001 1 00110010 2 00110011 3 00110100 4 00110101 5 00110110 6 00110111 7 00111000 8 00111001 9 00111010 : 00111011 ; 00111100 ¡ 00111101 = 00111110 ¿ 00111111 ? 01000000 @ Johan Bollen - http://www.cs.odu.edu/˜jbollen January 18, 2004 Page 20
CS149: Elements of Computer Science ASCII Table: GROUP 3 01000001 A 01000010 B 01000011 C 01000100 D 01000101 E 01000110 F 01000111 G 01001000 H 01001001 I 01001010 J 01001011 K 01001100 L 01001101 M 01001110 N 01001111 O 01010000 P 01010001 Q 01010010 R 01010011 S 01010100 T 01010101 U 01010110 V 01010111 W 01011000 X 01011001 Y 01011010 Z 01011011 [ 01011100 \ 01011101 ] 01011110 ˆ 01100000 ‘ 01011111 Johan Bollen - http://www.cs.odu.edu/˜jbollen January 18, 2004 Page 21
Recommend
More recommend