1 DLD Lecture 18 Recap
2 Recap °Number System/Inter-conversion, Complements °Boolean Algebra °More Logic Functions: NAND, NOR, XOR °Minimization with Karnaugh Maps °More Karnaugh Maps and Don’t Cares °NAND and XOR Implementations °Circuit Analysis and Design Procedures °Binary Adders and Subtractors °Magnitude Comparators and Multiplexers °Encoders, Decoders and DeMultiplexers
3 Digital Signals °Decimal values are difficult to represent in electrical systems. It is easier to use two voltage values than ten. °Digital Signals have two basic states: 1 (logic “high”, or H, or “on”) 0 (logic “low”, or L, or “off”) °Digital values are in a binary format. Binary means 2 states. °A good example of binary is a light (only on or off) onoff Power switches have labels “1” for on and “0” for off.
4 Number Systems °Decimal is the number system that we use °Binary is a number system that computers use °Octal is a number system that represents groups of binary numbers (binary shorthand). It is used in digital displays, and in modern times in conjunction with file permissions under Unix systems. °Hexadecimal (Hex) is a number system that represents groups of binary numbers (binary shorthand). Hex is primarily used in computing as the most common form of expressing a human- readable string representation of a byte (group of 8 bits).
5 Number Systems SystemBaseSymbols Used by humans? Used in computers? Decimal100, 1, … 9YesNo Binary20, 1NoYes Octal80, 1, … 7No Hexa- decimal 160, 1, … 9, A, B, … F No
6 Conversion Among Bases The possibilities: Hexadecimal DecimalOctal Binary
7 Binary Base 2 = Base = = = = = = = = 7 In Binary, there are only 0’s and 1’s. These numbers are called “Base-2” ( Example: ) Binary to Decimal We count in “Base-10” (0 to 9) °Binary number has base 2 °Each digit is one of two numbers: 0 and 1 °Each digit is called a bit °Eight binary bits make a byte °All 256 possible values of a byte can be represented using 2 digits in hexadecimal notation.
8 Binary as a Voltage °Voltages are used to represent logic values: °A voltage present (called Vcc or Vdd) = 1 °Zero Volts or ground (called gnd or Vss) = 0 A simple switch can provide a logic high or a logic low.
9 A Simple Switch °Here is a simple switch used to provide a logic value: Vcc Gnd, or 0 Vcc Vcc, or 1 There are other ways to connect a switch.
10 Binary digits Bit: single binary digit Byte: 8 binary digits Bit Byte Radix
11 Converting to decimal from binary: °Evaluate the power series Example *2 4 1* * * * *2 0 = Number systems
12 Review of Number systems Memorize the first ten powers of two
13 Review of Number systems
14 Number systems Converting to binary from decimal: –Divide the decimal number by 2 repeatedly. –The remainder gives the digits of the binary number R R 1 93 R 0 93 R 0 46 R 1 46 R 1 23 R 0 23 R 0 11 R 1 11 R 1 5 R 1 5 R R 1 2 R 1 1 R 0 1 R
15 Decimal 2 Binary
16 Octal Numbers: [Base 8],[ 0,1,3,4,5,6,7] Octal to Decimal Conversion: Example:- [2374] 8 = [ ? ] 10 =4×8 0 +7×8 1 +3×8 2 +2×8 3 =[1276] 10 Number systems () Number systems (Octal Numbers) °Octal number has base 8 °Each digit is a number from 0 to 7 °Each digit represents 3 binary bits °Was used in early computing, but was replaced by hexadecimal
17 Decimal to Octal Conversion: The Division: [359] 10 = [ ? ] 8 By using the division system: Reminder Number systems () Number systems (Octal Numbers) Quotient
18 Binary to Octal Conversion: Example:- [110101] 2 = [ ? ] 8 Here we will take 3 bits and convert it from binary to decimal by using the decimal to binary truth table: BinaryDecimal = (65) 8 { 65 { Number systems () Number systems (Octal Numbers)
19 Octal to Binary Conversion: Example:- [13] 8 = [ ? ] 2 Here we will convert each decimal digit from decimal to binary (3 bits) using the decimal to binary truth table: Decimal Binary (13) 8 = (001011) 2 Number systems () Number systems (Octal Numbers)
20 Radix Based Conversion (Example) °Convert 1234 decimal into octal Radix 8Answer Divide by radix
21 Octals Converting to decimal from octal: –Evaluate the power series Example *8 1 2* *8 0 + =
22 Hexadecimal °Hexadecimal is used to simplify dealing with large binary values: Base-16, or Hexadecimal, has 16 characters: 0-9, A-F Represent a 4-bit binary value: (0) to (F) Easier than using ones and zeros for large binary values Commonly used in computer applications °Examples: = = C = A6 C2 16 Hex values can be followed by an “H” to indicate base-16. Example: A6 C2 H
23 Hex Values in Computers
24 Decimal to Hexadecimal DecimalHex A 11B 12C 13D 14E 15F
25 Conversion Binary to Hexadecimal = = = = 6 AC16
26 Radix Based Conversion (Example) °Convert 1234 decimal into hexadecimal Radix 16Answer 4D2 16 Divide by radix D
27 Hexadecimals – Base 16 Converting to decimal from hex: –Evaluate the power series Example 2 E A *16 1 2* * =
28 Octal to Hex Conversion To convert between the Octal and Hexadecimal numbering systems Convert from one system to binary first Then convert from binary to the new numbering system
29 Hex to Octal Conversion Ex : Convert E8A 16 to octal First convert the hex to binary: and re-group by 3 bits (starting on the right) Then convert the binary to octal: So E8A 16 =
30 Octal to Hex Conversion Ex : Convert to hex First convert the octal to binary: re-group by 4 bits (add leading zeros) Then convert the binary to hex: 1 E A So = 1EA 16
31 Octal to Hexadecimal Hexadecimal DecimalOctal Binary
32 Octal to Hexadecimal °Technique Use binary as an intermediary
33 Example = ? E = 23E 16
34 Hexadecimal to Octal Hexadecimal DecimalOctal Binary
35 Hexadecimal to Octal °Technique Use binary as an intermediary
36 Example 1F0C 16 = ? 8 1 F 0 C F0C 16 =
37 Example: Hex → Octal Example: °Convert the hexadecimal number 5A H into its octal equivalent. 5A H = A = Solution: °First convert the hexadecimal number into its decimal equivalent, then convert the decimal number into its octal equivalent.
38 Fractions (Example)
39 Fractions (Example)
40 Radix Based Conversion (Example) °Convert decimal into binary Radix 2 Answer FractionRadixTotal (Fraction x Radix)IntegerFraction Multiply by radix 2
41 FractionRadix Total (Fraction x Radix)IntegerFraction Radix Based Conversion (Example) °Convert to base 16 (up to 4 fractional point) Radix 16 Answer Multiply by radix 16
42 Any base to decimal conversion (110.11) 2 to decimal: (110.11) 2 = 6.75.
43
44 Complement °It has already been studied that °subtracting one number from another is the same as making one number negative and just adding them. °We know how to create negative numbers in the binary number system. °How to perform 2’s complement process. °How the 2’s complement process can be use to add (and subtract) binary numbers. °Digital electronics requires frequent addition and subtraction of numbers. You know how to design an adder, but what about a subtracter? °A subtracter is not needed with the 2’s complement process. The 2’s complement process allows you to easily convert a positive number into its negative equivalent. °Since subtracting one number from another is the same as making one number negative and adding, the need for a subtracter circuit has been eliminated.
45 3-Digit Decimal A bicycle odometer with only three digits is an example of a fixed-length decimal number system. The problem is that without a negative sign, you cannot tell a +998 from a -2 (also a 998). Did you ride forward for 998 miles or backward for 2 miles? Note: Car odometers do not work this way forward (+) backward (-)
46 Negative Decimal How do we represent negative numbers in this 3- digit decimal number system without using a sign? Cut the number system in half. Use 001 – 499 to indicate positive numbers. Use 500 – 999 to indicate negative numbers. Notice that 000 is not positive or negative pos(+) neg(-)
47 3-Digit Decimal (Examples) (-5) + 2 (-3) (-3) 3 (-2) + (-3) (-5) 003 Disregard Overflow 995 Disregard Overflow It Works!
48 Complex Problem °The previous examples demonstrate that this process works, but how do we easily convert a number into its negative equivalent? °In the examples, converting the negative numbers into the 3-digit decimal number system was fairly easy. To convert the (-3), you simply counted backward from 1000 (i.e., 999, 998, 997). °This process is not as easy for large numbers (e.g., -214 is 786). How did we determine this? °To convert a large negative number, you can use the 10’s Complement Process.
49 The 10’s Complement process uses base-10 (decimal) numbers. Later, when we’re working with base-2 (binary) numbers, you will see that the 2’s Complement process works in the same way. First, complement all of the digits in a number. A digit’s complement is the number you add to the digit to make it equal to the largest digit in the base (i.e., 9 for decimal). The complement of 0 is 9, 1 is 8, 2 is 7, etc. Second, add 1. Without this step, our number system would have two zeroes (+0 & -0), which no number system has.
50 10’s Complement Examples 785 Example #1 Example #2 Complement DigitsAdd 1Complement DigitsAdd 1 786
51 8-Bit Binary Number System Apply what you have learned to the binary number systems. How do you represent negative numbers in this 8- bit binary system? Cut the number system in half. Use – to indicate positive numbers. Use – to indicate negative numbers. Notice that is not positive or negative
52 Sign Bit What did do you notice about the most significant bit of the binary numbers? The MSB is (0) for all positive numbers. The MSB is (1) for all negative numbers. The MSB is called the sign bit. In a signed number system, this allows you to instantly determine whether a number is positive or negative pos(+) neg(-)
53 2’S Complement Process The steps in the 2’s Complement process are similar to the 10’s Complement process. However, you will now use the base two. First, complement all of the digits in a number. A digit’s complement is the number you add to the digit to make it equal to the largest digit in the base (i.e., 1 for binary). In binary language, the complement of 0 is 1, and the complement of 1 is 0. Second, add 1. Without this step, our number system would have two zeroes (+0 & -0), which no number system has.
54 2’s Complement Examples Example #1 Example #2 Complement Digits Add 1 5 = = Complement Digits Add = =
55 Using The 2’s Compliment Process 9 + (-5) 4 (-9) (-9) + (-5) POS + POS POS + NEG POS NEG + POS NEG + NEG NEG Use the 2’s complement process to add together the following numbers.
56 POS + POS → POS Answer If no 2’s complement is needed, use regular binary addition +
57 POS + NEG → POS Answer Take the 2’s complement of the negative number and use regular binary addition (-5) 4 ’s Complement Process 1] th Bit = 0: Answer is Positive Disregard 9 th Bit
58 POS + NEG → NEG Answer Take the 2’s complement of the negative number and use regular binary addition (-9) ’s Complement Process th Bit = 1: Answer is Negative To Check: Perform 2’s Complement On Answer
59 NEG + NEG → NEG Answer Take the 2’s complement of both negative numbers and use regular binary addition (-9) + (-5) -14 + 2’s Complement Numbers, See Conversion Process In Previous Slides 1] th Bit = 1: Answer is Negative Disregard 9 th Bit To Check: Perform 2’s Complement On Answer
60 1’s Complement
61 2’s Complement 1s complement with negative numbers shifted one position clockwise Only one representation for 0 One more negative number than positive number High-order bit can act as sign bit
62 Overflow °Overflow conditions °Add two positive numbers to get a negative number °Add two negative numbers to get a positive number