CSIT123-week-2-lecture 2.pptx
Document Details

Uploaded by BrainyBasil
University of Wollongong in Dubai
Full Transcript
University of Wollongong in Dubai CSIT123 Autumn 2023 Learning Objectives 1. Explain and calculate Boolean operations using the AND, OR, XOR, NOT gates. 2. Determine the input/output table of a Boolean circuit 3. Use ASCII to encode a text. 4. Convert a decimal number into a binary numb...
University of Wollongong in Dubai CSIT123 Autumn 2023 Learning Objectives 1. Explain and calculate Boolean operations using the AND, OR, XOR, NOT gates. 2. Determine the input/output table of a Boolean circuit 3. Use ASCII to encode a text. 4. Convert a decimal number into a binary number 5. Convert a binary number into a decimal number 6. Explain and use the hexadecimal representation of numbers. History of computers Three women operating The ENIAC Control panel ENIAC (Electronic Numerical Integrator and Computer) ENIAC ENIAC weighed 30 tons, took up 1,800 square feet of space, and was made of 17,468 vacuum tubes, 1,500 relays, 70,000 resistors, 10,000 capacitors, and nearly five million hand-soldered joints. Bits and their reprsentation Bits and data representation Inside today’s computers all information is encoded as patterns of 0s and 1s. These digits are called bits (short for binary digits). Question Bits are meant to represent numerical values. YES ? NO? The answer is NO Because bits can represent Characters in an alphabet and punctuation sometimesmarks; they represent color and images; and sometimes they represent sounds. Data Representation and Storage in a computer 00110101001001001010101111101110101010111110 10101011111011100011010100100100101010111110 11000110110101011111001001001010000000111111 10101011111101001001000101110001100100100100 00100110111110101010001101010011100100100101 1 01001001001010101111101110001101000011010100 1 10100001101010010010111010011111000011010100 1 But what 0 and 1 stand for? What “0” and “1” stand for? The bit 0 represents the value false The bit 1 represents the value true. What “0” and “1” stand for? Operations that manipulate true/false values are called Boolean operations The main basic Boolean operations Main Boolean operations NOT AND OR XOR Gates A gate: A device that computes a Boolean operation Often implemented as small electronic circuits called transistors Provide the building blocks of computers The main basic Boolean operations The operations correspond gates (circuits) NOT (inverter gate) AND (gate) OR (gate) XOR (gate) Graphical representation of the binary operations Graphical representation of the binary operations Type of Symbolic representation Action gate NOT Input Output P Q 1 0 0 1 AND INPUT OUTPUT P Q R 1 1 1 1 0 0 0 1 0 0 0 0 OR INPUT OUTPUT P Q R 1 1 1 1 0 1 0 1 1 0 0 0 Main Boolean arithmetic Symbols Operato Symbol r AND OR NOT XOR Example 1 Input signals P=0, Q=1 Output R? Example 2 Input signals P=1, Q=0 R=1, S? Build the input/output table corresponding to the circuit below Input Output P Q R 1 1 1 0 0 1 0 0 Build the input/output table corresponding to the circuit below Input Output P Q R 1 1 1 1 0 1 0 1 0 0 0 1 Build the input/output table corresponding to the circuit below Build the input/output table corresponding to the circuit below For this input/output table: How many rows are needed? How many columns are needed? Build the input/output table corresponding to the circuit below For this input/output table: We have three inputs Each input can have two possible values 0 or 1 So there is 2*2*2 possible combinations of “0” and “1” as inputs Hence we need 8 rows for the possible inputs, plus one row for the header of the table Build the input/output table corresponding to the circuit below For this input/output table: We have two outputs S and T Hence we need 5 columns , 3 for the inputs, 2 for the outputs Hence our table requires 5 columns and 9 rows. Build the input/output table corresponding to the circuit below INPUT P Q R T= P Q S= T R 1 1 1 1 1 0 1 0 1 1 0 0 0 1 1 0 1 0 0 0 1 0 0 0 Build the input/output table corresponding to the circuit below INPUT P Q R T= P Q S= T R 1 1 1 0 0 1 1 0 0 0 1 0 1 1 1 1 0 0 1 0 0 1 1 1 1 0 1 0 1 0 0 0 1 0 0 0 0 0 0 0 NAND and NOR gates Use the binary symbols to Find the Boolean expression of the following digital logic circuit Boolean Expression Find the Boolean expression of the following digital logic circuit Where is data stored Where data is stored? Main memory – RAM or Random Access Memory – DRAM or Dynamic Random Access Memory – SDRAM or Synchronous Dynamic Random Access Memory Mass storage ( secondary memory) – Magnetic Systems – Optical systems – Flash Drives Data Representation and Storage: the byte Digital computers store information as a sequence of bits (binary digits). The value or state of a bit at any given time can be 0 or 1 (off or on). Data is stored as a sequence of bytes. – A byte is a sequence of 8 bits. A byte is made of 8 bits b7 b6 b5 b4 b3 b2 b1 bo 9/23/2024 Data Representation and Storage: the byte A byte is a cell of main memory Or A unit of main memory (typically 8 bits which is one byte) – Most significant bit: the bit at the left (high-order) end (b7) – Least significant bit: the bit at the right (low-order) end (b0) A byte is made of 8 bits b 7 b6 b5 b4 b3 b2 b1 b o 9/23/2024 Two main ways to represent Text ASCII: American Standard Code for Information Interchange This code uses bit patterns of length seven to represent the upper and lowercase letters of the English alphabet, punctuation symbols, the digits 0 through 9, and certain control information such as line feeds, carriage returns, and tabs. Unicode Transformation Format 8-bit (UTF-8) UTF-8 is a character encoding system. It allows you represent characters as ASCII text, while still allowing for all type of international characters, ASCII Code Use ASCII to encode the message Hello. H e l l o. Representing Numeric values Decimal Binary system system Hexadeci mal system Decimal system Base(10) number system Ten decimal digits (0,1,2,3,4,5,6,7,8,9) Each position in a representation is associated with a quantity. Each digit multiplies a power of ten 24510 = 2*102 + 4*101 + 5*100 Example 3957 in base 10 395710 103 102 101 100 3 9 5 7 3957 = 3*103+9*102+5*101+7*100 Binary System Base two (binary) number system Two binary digits (0,1) Each digit multiplies a power of two Convert 101102 Into a decimal number How to convert a binary number X into a decimal number? 1. Draw a five -row table with as many columns as there are digits in the binary number 2. Fill the first row from right to left with the numbers 0, 1, 2, 3, … i), Where (i+1) corresponds to the number of binary digits representing the binary number 3. Fill the second row from right to left with the different powers of 2 for k= 0, 1, 2, 3, …., i , that is 20, 21, 22, …., 2i. 4. Fill the third row with the decimal values for each of the elements of the second row. 5. Fill the fourth row from right to left with the binary digits of X using the same order. 6. For each column from right to left, using row 3 and row 4, multiply the corresponding cell values, and store the resulting products in the corresponding cell of row5 7. The value of X in decimal is obtained by adding the decimal values of the different cells of the 5th row Example: step by step Convert 101102 Into a decimal number An example : step by step Draw a Five-row table with as many columns as there are digits in the binary number X has five digits, so, we draw a table of 5 rows and 5 columns An example : step by step Fill the first row from right to left with the numbers 0, 1, 2, 3, … i, Where (i+1) corresponds to the number of binary digits representing the binary number X has 5 binary digits, So i+1= 5 or i=4 Let us fill the first row 4 3 2 1 0 An example : step by step Fill the second row from right to left with the different powers of 2 for k= 0, 1, 2, 3, …., i , that is 20, 21, 22, …., 2i. 4 3 2 1 0 24 23 22 21 20 An example : step by step Fill the third row with the decimal values for each of the elements of the second row. 4 3 2 1 0 24 23 22 21 20 16 8 4 2 1 An example : step by step Fill the fourth row from right to left with the binary digits of X using the same order. We know that X = 101102 therefore, the fourth row would be: 4 3 2 1 0 24 23 22 21 20 16 8 4 2 1 1 0 1 1 0 An example : step by step For each column from right to left, using row 3 and row 4, multiply the corresponding cell values, and store the resulting products in the corresponding cell of row5 4 3 2 1 0 24 23 22 21 20 16 8 4 2 1 1 0 1 1 0 1*16=16 0*8=0 1*4=4 1*2 =2 0*1=0 An example : step by step The value of X in decimal is obtained by adding the decimal values of the different cells of the 5th row. X 10 = 0 + 2+ 4 + 0 +16= 2210 4 3 2 1 0 24 23 22 21 20 16 8 4 2 1 1 0 1 1 0 1*16=16 0*8=0 1*4=4 1*2 =2 0*1=0 Binary System Base two (binary) number system Two binary digits (0,1) Each digit multiplies a power of two 101102 = 1*24 + 0*23 + 1*22 + 1*21 + 0*20 = 1*16 + 0*8 + 1*4 + 1*2 + 0*1 = 16 + 0 + 4 + 2 + 0 = 2210 Converting a decimal number into a binary number: three steps Divide the value by two and record the remainder. As long as the quotient obtained is not zero, continue to divide the newest quotient by two and record the remainder. Now that a quotient of zero has been obtained, the binary representation of the original value consists of the remainders listed from right to left in the order they were recorded. Converting 13(base 10) to a binary number Computer representation of integers How do we convert a decimal number to a binary number? Example 17710 Solution Binary Addition To understand the process of adding two integers that are represented in binary, Let us first recall the process of adding values that are represented in traditional base ten notation. Consider the following addition: 5810 +2710 Decimal Addition We being by adding 8 and 7 in the right most 5 8 column We obtain 15 + 2 7 We record 5 at the = bottom of that column And Carry the one “1” to the next column Decimal Addition 1. We being by adding 8 Carr 1 and 7 in the right most y column 5 8 2. We obtain 15 3. We record 5 at the + 2 7 bottom of that column 4. And Carry the one “1” = 5 to the next Column Decimal Addition 1. We being by adding 8 and 7 in the right most column Carr 1 y 2. We obtain 15 3. We record 5 at the bottom of that 5 8 column 4. And Carry the one “1” to the next + 2 7 Column 5. We now add 5 and 2 in the next column along with the carry. = 8 5 6. We obtain 5+2+1= 8 7. We record “8” at the bottom of the column Decimal Addition Summary of the method Decimal addition You must progress from right to left as you add the digits in each column, write the least significant digit of that sum under the column, and carry the more significant digit of the sum (if there is one) to the next column. The binary addition Same method as for the decimal addition Binary addition of two integers You use the same method as for the decimal addition Except that now all the sums are computed using the following properties of binary numbers The binary addition: example Let us add: 111010 + 11011 Looking at the two binary numbers we need to add, the largest one (111010) has six digits So we need a table with: – 8 digits – 5 rows carr If you wonder why, it is because when adding y the two numbers, we may end up with a number that has 5 digits. So we need the allow room for that possible extra digit I added an extra column just for clarity and avoiding a cluttered table In terms of rows, we need 5 rows, such as: One row for each of the operands ( thus 2 rows) One row for the carry One row for the horizontal line One row for the result The binary addition: example Let us add: 111010 + 11011 1. First we enter the two operands in row 2 and row 3, starting from the least significant digit in the right most column To the most significant digit in the left most carr column y 1 1 1 0 1 0 + 1 1 0 1 1 = The binary addition: example Let us add: 111010 + 11011 We being by adding 0 and 1in the right most column We obtain 0 +1 =1 We record “1” in the bottom of that column carr y 1 1 1 0 1 0 + 1 1 0 1 1 = 1 The binary addition: example Let us add: 111010 + 11011 We now add 1 and 1 1+1 = 10 We record the 0 at the bottom of the column And carry the 1 to the next column. carr 1 y 1 1 1 0 1 0 + 1 1 0 1 1 = 0 1 The binary addition: example Let us add: 111010 + 11011 We now move to next column at the left We add the values of the 2nd row and the 3 row ( from the operands) We obtain: 0+0=0 But there is a carry of “1” in this column. carr 1 So, we add the carry the 0+0 y We have 0+0+1= 1 So, we report “1” in the bottom row of the 1 1 1 0 1 0 column + 1 1 0 1 1 = 1 0 1 The binary addition: example Let us add: 111010 + 11011 We now move to next column at the left We add the values of the 2nd row and the 3 row ( from the operands) We obtain: 1+1=10 We report the “0” at the bottom of the carr 1 1 column y And we report the “1” as a carry in the next column. 1 1 1 0 1 0 + 1 1 0 1 1 = 0 1 0 1 The binary addition: example Let us add: 111010 + 11011 We now move to next column at the left We add the values of the 2nd row and the 3 row ( from the operands) We obtain: 1+1=10 But a look at the carry shows that there is a carr 1 1 1 “1” y So we are ending up with: 1+1+1 = 10+1 =11 in binary 1 1 1 0 1 0 The least significant bit of this sum is a “1” And the most significant bit of this sum is a + 1 1 0 1 1 “1” also. We will report the “1” of the least significant bit at the bottom of the column = 1 0 1 0 1 And we will report the “1” of the most significant bit as a carry in the next column. The binary addition: example Let us add: 111010 + 11011 We now move to next column at the left We add the values of the 2nd row and the 3 row ( from the operands) We obtain: 1+0=1 But a look at the carry shows that there is a carr 1(*) 1 1 1 “1” y So we are ending up with: 1+0+1 = 1+1 =10 in binary 1 1 1 0 1 0 The least significant bit of this sum is a “0” And the most significant bit of this sum is a + 1 1 0 1 1 “1” We will report the “0” of the least significant bit at the bottom of the column = 0 1 0 1 0 1 And we will report the “1” of the most significant bit as a carry in the next column. (*) The binary addition: example Let us add: 111010 + 11011 We now move to next column at the left There is no values in the 2nd row and the 3 row ( from the operands). This means that the values in the 2nd row and the 3 row ( from the operands) are carr 1(*) 1 1 1 Zeros. y But looking carefully, you can see that there is carry of “1” in this column 1 1 1 0 1 0 So we are ending up with: 0+0+1 = 1 = in binary + 1 1 0 1 1 Since “1” holds on one bit, there is no need for a carry now. We report “1” at the bottom of this column. = 1 0 1 0 1 0 1 The binary addition: example Let us add: 111010 + 11011 We report “1” at the bottom of the left most carr 1(*) 1 1 1 column. y Since we have processed all 1 1 1 0 1 0 the columns of the + 1 1 0 1 1 operands = 1 0 1 0 1 0 1 We stop and report the result as it is displayed by the bottom row. 1010101 Hexadecimal notation What is the binary representation of your student ID Number? Which representation is easier to remember by humans? The hexadecimal notation is meant to make manipulating numbers, especially large binary numbers more convivial Hexadecimal notation Based on 16 digits: 1,2,3,4,5,6,7,8,9,A,B,C,D,E,F Decimal 1 2 3 4 5 6 7 8 9 10 1 1 1 1 15 1 2 3 4 Hexadeci 1 2 3 4 5 6 7 8 9 A B C D E F mal Binary 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 Hexadecimal to decimal 2FB16 =? Hexadecimal to decimal 2FB16 = 2*162 + F*161 + B*160 = 2*256 + F*16 + B*1 = 512 + 240 + 11 = 76310 Hexadecimal to binary 1. Write each hexadecimal in 4-bit binary representation 2. Append the results together Hexadecimal to binary Convert AF1C5 to binary hexadeci A F 1 C 5 mal Decimal Binary Hexadecimal to binary Convert AF1C5 to binary hexadeci A F 1 C 5 mal Decimal 10 15 1 12 5 Binary 1010 1111 0001 1100 0101 equivalent of each digit Binary 10101111000111000101 Convert binary to hexadecimal 1. Group the binary digits into sets of four, starting from the right, and add leading zeros as needed. 2. Convert the binary number in each set of four to an hexadecimal digit. 3. Juxtapose the different hexadecimal digits. Binary to Hexadecimal Convert 0011110011010011 to hexadecimal binary 0011110011010011 4-bit binary 001 1100 110 0011 1 1 Intermediary 3 C D 3 hexadecimal Hexadecimal 3CD3