EECE 251: Digital Logic Design Lecture: 2 Fall 2021 Tareq Hasan Khan, Ph.D. 1.2 What Does “Digital” Mean? • Analog signal • Digital signal – Infinite possible values – Finite possible values • Ex: button pressed on a • Ex: voltage on a wire created by microphone keypad 1 2 3 4 2 digital signal a Possible values: 1.00, 1.01, 2.0000009, ... infinite possibilities a time value value analog signal 4 3 2 1 0 Possible values: 0, 1, 2, 3, or 4. That’s it. time 2 • Binary digital signal -only two possible values – Typically represented as 0 and 1 – One binary digit is a bit – We’ll only consider binary digital signals value Digital Signals with Only Two Values: Binary 1 0 time 3 4 5 Learning objectives • Learning to count in Hexadecimal (Hex) • Converting numbers – Decimal to Binary – Binary to Decimal – Binary to Hex – Hex to Binary – Hex to Decimal – Decimal to Hex 6 7 8 9 Learning objectives • Learning to count in Hexadecimal (Hex) • Converting numbers – Decimal to Binary – Binary to Decimal – Binary to Hex – Hex to Binary – Hex to Decimal – Decimal to Hex 10 Digits and bases of number systems • Hexadecimal numbers use base 16 – 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F • Decimal numbers use base 10 – 0,1,2,3,4,5,6,7,8,9 • Binary numbers use base 2 – 0,1 11 Decimal (Dec) to Binary (Bin) • Divide-By-2 Method Repeatedly divide decimal number by 2, place remainder in current binary digit (starting from 1s column) 12 1. Divide decimal number by 2 Insert remainder into the binary number Continue since quotient (6) is greater than 0 Decimal 6 2 12 –12 0 Binary 0 1 (current value: 0) 2. Divide quotient by 2 Insert remainder into the binary number Continue since quotient (3) is greater than 0 3 2 6 –6 0 0 0 2 1 (current value: 0) 3. Divide quotient by 2 Insert remainder into the binary number Continue since quotient (1) is greater than 0 1 2 3 –2 1 1 0 0 4 2 1 (current value: 4) 4. Divide quotient by 2 Insert remainder into the binary number Quotient is 0, done 0 2 1 –0 1 1 1 0 0 8 4 2 1 (current value: 12) Note: Works for any base N—just divide by N instead Binary (Bin) to Decimal (Dec) • A byte contains 8 bits. – b0 is the least significant bit (LSB) – b7 is the most significant bit (MSB) • Unsigned number can only represent positive number. • If a byte is used to represent an unsigned number, then the value of the number (in decimal) is N = 27*b7 + 26*b6 + 25*b5 + 24*b4 + 23*b3 + 22*b2 + 21*b1 + 20*b0 13 In class exercise • Convert 011010102 to unsigned decimal 14 Learning objectives • Learning to count in Hexadecimal (Hex) • Converting numbers – Decimal to Binary – Binary to Decimal – Binary to Hex – Hex to Binary – Hex to Decimal – Decimal to Hex 15 Binary (Bin) to Hexadecimal (Hex) • Separate the binary numbers into groups of 4 digits (called a ‘nibble’) starting from the right. Put leading zero’s if needed. • Converts each group of 4 digits to one hex digit. 16 Hexadecimal (Hex) and binary (Bin) numbers 17 In class exercise • Convert the following binary numbers to hexadecimal. 101001112 1110102 18 Hexadecimal (Hex) to Binary (Bin) • Substitute the 4-bit binary for each hex digit. In class exercise Convert B5D116 to binary. 19 Learning objectives • Learning to count in Hexadecimal (Hex) • Converting numbers – Decimal to Binary – Binary to Decimal – Binary to Hex – Hex to Binary – Hex to Decimal – Decimal to Hex 20 Hex to Decimal • Method 1 – Covert Hex to Bin, then convert Bin to Hex • Method 2 – For a hex number hn hn-1 … h1 h0, its decimal is 21 In class exercise • Convert 3216 to unsigned decimal 22 Decimal to Hex The steps to convert a number, let's call it N, from decimal to hex look something like this: 1. Divide N by 16. The remainder of that division is the first (leastsignificant/right-most) digit of your hex number. Take the quotient (the result of the division) to the next step. 1. Note: if the remainder is 10, 11, 12, 13, 14, or 15, then that becomes the hex digit A, B, C, D, E, or F. 2. Divide the quotient from the last step by 16 again. The remainder of this division is the second digit of your hex value (second-from-theright). Take the quotient from this division to the next step. 3. Divide the quotient from step 2 by 16 again. The remainder of this division is the third digit of your hex conversion. Noticing a pattern? 4. Keep dividing your quotient from the last step by 16, and storing the remainder until the result of a division is 0. The remainder of that division is your hex value's left-most, most-significant digit. 23 • Convert 197010 to Hex 24 Announcement • Next class: – Binary Addition and Subtraction (Ch. 1) 25