Lecture 1.2 (Chapter 1) Prepared by Dr. Lamiaa Elshenawy Logic Design (CE1111) Lecture 1.2 (Chapter 1) Prepared by Dr. Lamiaa Elshenawy
Outlines Digital Systems Binary Numbers Number-Base Conversions Octal and Hexadecimal Numbers Complements of Numbers Signed Binary Numbers Binary Codes Binary Storage and Registers Binary Logic
Complements of Numbers Complements are used in digital computers to simplify the subtraction operation and for logical manipulation Simplifying operations leads to simpler, less expensive circuits to implement the operations
Complements of Numbers Types of complements Radix complement (r’s complement) Diminished radix complement ((r-1)’s complement) Decimal Numbers 10’s complement and 9’s complement Binary Numbers 2’s complement and 1’s complement
Complements of Numbers How can we calculate r’s complement and (r-1)’s complement ? Radix complement 𝑟 𝑛 −𝑁 Diminished radix complement 𝑟 𝑛 −1 −𝑁 Where n is number of digits
Complements of Numbers Calculate the 10’s complement and 9’s complement of 546700. Solution 10’s complement: 1000000 - 546700=453300 9’s complement: 999999 - 546700=453299
Complements of Numbers Calculate the 2’s complement and 1’s complement of 1011000. Hint Solution 2’s complement: 1011000 0101000 1’s complement: 1011000 0100111 2’s complement: leave all least significant 0’s and first 1 unchanged, change from 0 to 1 or from 1 to 0 for all other higher significant digits 1’s complement: change from 0 to 1 or from 1 to 0
Signed Binary Numbers Leftmost position of the number used for sign: Bit 0 Positive number Bit 1 Negative number Example (+9)10 =(01001) signed-magnitude representation (-9)10 =(11001) 2 signed-magnitude representation (-9)10 =(10110) 2 signed-1’s complement representation (-9)10 =(10111) 2 signed-2’s complement representation
Arithmetic Addition Unsigned numbers: As ordinary arithmetic Example 25+12=37 13+ −30 =− 30−13 =−17 Signed numbers: Positive numbers as ordinary arithmetic +25 + +12 =+37 Negative numbers Write negative number in signed-2’s complement Discard the end carry
Arithmetic Addition Example
Arithmetic Subtraction Unsigned numbers: As ordinary arithmetic Example 27−14=13 15− −30 =15+ 30 =45 Signed numbers:
Arithmetic Subtraction Example −6 − −13 =−6+13=+7 −6 10=(1000 0110)2 =(1111 1010)2 (signed-2’s complement) +13 10=(0000 1101)2 1111 1010 0000 1101 𝟏0000 𝟎𝟏𝟏𝟏 =+7 Discard
Binary Codes What is a binary code? An n‐bit binary code is a group of n bits that assumes up to 2 𝑛 distinct combinations of 1’s and 0’s to represent one element that is being coded. Why we use binary codes? Because digital systems understands only 1 or 0
Binary Codes What are the most common binary codes? Binary-Coded Decimal (BCD) 2421-Code Excess-3 Code 8,4,-2,-1 Code Gray Code ASCII Character Code
Binary-Coded Decimal Converts Decimal Numbers Binary Numbers How? Write each decimal digits in 4bits Example
Binary-Coded Decimal
Signed-BCD Addition Write each decimal number in BCD Write sign in the leftmost position (0 for +, 1 for -) Add (6) 10=(0110) 2 to the binary sum If 𝑠𝑢𝑚≥ (1010) 2 Example
ASCII Character Code It codes 128 Characters in7-bits 26 capital letters 26 small letters 10 decimal digits Special characters ASCII: American Standard Code for Information Interchange
Registers What is a register? A register is a group of binary cells. A register with n cells can store any discrete quantity of information that contains n bits
Register Transfer
Information Processing
Binary Logic What is a binary logic? Binary logic consists of binary variables and a set of logical operations Variables are designated by letters of the alphabet, such as A, B, C, x, y, z, etc., with each variable having two and only two distinct possible values: 1 and 0
Binary Logic What are the most common logic gates? AND: 𝑥.𝑦=𝑥 𝐴𝑁𝐷 𝑦=𝑧 OR: 𝑥+𝑦=𝑥 𝑂𝑅 𝑦=𝑧 NOT: 𝑥 ′ = 𝑥 =𝑧
Binary Logic
Thank you for your attention