This action might not be possible to undo. Are you sure you want to continue?

EE-374 Dr. Nabeel Anwar Room 206, SMME.

Text books

• Digital Logic and Computer Design by Morris Mano • Digital Fundamentals by Floyd

Grading

• Sessional: Two • Quizzes/Assignments • Final

30% 25% 45%

Digital System

Representing Information Electronically

• “Analog electronics” deals with non-discrete values • “Digital electronics” deals with discrete values

a small in size.. 1) with only two discrete values.. 0v) represents a 0 and “full source voltage” (e.g. • We use transistor switches.g. <1v) represents a 0 and “high voltage” (e.. 5v) represents a 1 • Realistically “low voltage” (e. >4v) represents a 1 • We achieve these discrete values by using switches. electronically. which operates at high speed.g. • Ideally “no voltage” (e..Digital Electronics • Digital Electronics represents information (0. .g.

TRUE and FALSE. • Discrete values are called 1 and 0 (ON and OFF. • Digital systems process time-varying signals that can take on only one of two discrete values of voltages (in electrical/electronics systems).) .Analog versus Digital • Analog systems process time-varying signals that can take on any value across a continuous range of voltages (in electrical/electronics systems). HIGH and LOW. etc.

Benefits of Digital over Analog • Reproducibility • Not effected by noise means quality • Ease of design • Data protection • Programmable • Speed • Economy .

Case Study of a Simple Logic Design: Seven Segment Display L1 L 4 L2 L 5 L3 L 7 L 6 B3 0 0 0 0 0 0 0 0 1 1 B2 0 0 0 0 1 1 1 1 0 0 B1 0 0 1 1 0 0 1 1 0 0 B0 0 1 0 1 0 1 0 1 0 1 Val 0 1 2 3 4 5 6 7 8 9 .

Case Study (cont.) L1 L 4 L2 L 5 L3 L 7 L 6 B3 0 0 0 0 0 0 0 0 1 1 B2 0 0 0 0 1 1 1 1 0 0 B1 0 0 1 1 0 0 1 1 0 0 B0 0 1 0 1 0 1 0 1 0 1 Val 0 1 2 3 4 5 6 7 8 9 L1 1 0 1 1 0 1 1 1 1 1 L2 0 0 1 1 1 1 1 0 1 1 L3 1 0 1 1 0 1 1 0 1 1 L4 1 0 0 0 1 1 1 0 1 1 L5 1 0 1 0 0 0 1 0 1 0 L6 1 1 1 1 1 0 0 1 1 1 L7 1 1 0 1 1 1 1 1 1 1 .

Digital Revolution • Digital systems started back in 1940s. • Digital systems cover all areas of life: • still pictures • digital video • digital audio • telephone • traffic lights • Animation .

Number Systems .

13 Binary Numbers • Strings of binary digits (“bits”) • One bit can store a number from 0 to 1 • n bits can store numbers from 0 to 2n .

14 Binary – Powers of 2 Positional representation • Each digit represents a power of 2 So 101 binary is 1 • 22 + 0 • 21 + 1 • 20 or 1•4 + 0•2 + 1•1=5 .

15 Converting Binary to Decimal • Easy. just multiply digit by power of 2 • Just like a decimal number is represented • Example follows .

16 Binary Decimal Example 7 27 128 6 26 64 5 25 32 4 24 16 3 23 8 2 22 4 1 21 2 0 20 1 What is 10011100 in decimal? 1 0 0 1 1 1 0 0 128 + 0 + 0 + 16 + 8 + 4 + 0 + 0 = 156 .

17 Decimal to Binary • A little more work than binary to decimal • Some examples • 3 = 2 + 1 = 11 (that’s 1•21 + 1•20) • 5 = 4 + 1 = 101 (that’s 1•22 + 0•21 + 1•20) .

18 Algorithm – Decimal to Binary • Find largest power-of-two smaller than decimal number • Make the appropriate binary digit a ‘1’ • Subtract the power of 2 from decimal • Do the same thing again .

so use 16 Binary 10000 Decimal 28 – 16 = 12 Next is 8 Binary 11000 Decimal 12 – 8 = 4 Next is 4 Binary 11100 Decimal 4 – 4 = 0 7 27 128 6 26 64 5 25 32 4 24 16 3 23 8 2 22 4 1 21 2 0 20 1 .19 Decimal Binary Example • Convert 28 decimal to binary 32 is too large.

20 Hexadecimal • Strings of 0s and 1s too hard to write • Use base-16 or hexadecimal – 4 bits Dec 0 1 2 3 4 5 6 7 Bin 0000 0001 0010 0011 0100 0101 0110 0111 Hex 0 1 2 3 4 5 6 7 Dec 8 9 10 11 12 13 14 15 Bin 1000 1001 1010 1011 1100 1101 1110 1111 Hex 8 9 ? ? ? ? ? ? .

21 Hexadecimal • Letters to represent 10-15 Dec 0 1 2 3 4 5 6 7 Bin 0000 0001 0010 0011 0100 0101 0110 0111 Hex 0 1 2 3 4 5 6 7 Dec 8 9 10 11 12 13 14 15 Bin 1000 1001 1010 1011 1100 1101 1110 1111 Hex 8 9 a b c d e f .

22 Hex to Binary • Convention – write 0x before number • Hex to Binary – just convert digits Bin 0000 0001 0010 0011 0100 0101 Hex 0 1 2 3 4 5 6 7 8 9 a b c d e f 0x2ac 0010 1010 1100 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 0x2ac = 001010101100 No magic – remember hex digit = 4 bits .

23 Binary to Hex • Just convert groups of 4 bits Bin 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 Hex 0 1 2 3 4 5 6 7 8 9 a b c d e f 101001101111011 0101 0011 0111 1011 5 3 7 b 1010 1011 1100 101001101111011 = 0x537b 1101 1110 1111 .

and 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 add the results. 0x2ac 2 • 256 163 4096 + 10 • 16 + 12 • 1 = 684 162 256 161 16 160 1 .24 Dec Hex 0 1 2 3 4 5 6 7 8 9 a b c d e f Hex to Decimal • Just multiply each hex digit by decimal value.

Do the same thing again . 3. Analogous to decimal binary. 4.25 Decimal to Hex 1. 2. The integer result is hex digit. The remainder is new decimal number. Find largest power-of-16 smaller than decimal number Divide by power-of-16.

26 Dec Hex 0 1 2 3 4 5 6 7 8 9 a b c d e f Decimal to Hex 684 684/256 = 2 684%256 = 172 172/16 = 10 = a 163 4096 162 256 161 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0x2__ 0x2a_ 172%16 = 12 = c 0x2ac 160 1 .

27 Octal • Octal is base 8 • Similar to hexadecimal • Conversions • Less convenient for use with 8-bit bytes .

addition • Binary similar to decimal arithmetic No carries 1 0 0 0 0 1 1 0 1 1 0 0 1 1 1 1 1 0 1 1 0 0 0 1 1 Carries 0 + 1 1 1 0 1 1 0 1 + 1 1 0 1+1 is 2 (or 102).28 Arithmetic -. which results in a carry .

29 Arithmetic -.subtraction No borrows 0 1 1 0 0 0 0 1 1 0 0 1 0 1 1 1 0 0 1 1 1 1 0 0 1 1 Borrows 1 1 0 0 0 0 1 0 1 0 .1 results in a borrow .

Note that multiplication by 102 just shifts bits left.multiplication 1 X 1 0 1 1 0 1 0 1 0 0 1 0 0 1 1 1 1 1 0 1 0 1 1 1 Successive additions of multiplicand or zero. multiplied by 2 (102).30 Arithmetic -. .

31 Hexadecimal Arithmetic • Similar • If you’re doing by hand. easiest to convert each set of digits to decimal and back • Skill is not very useful… .

1 . you can write a number between 0 and 99. Consider a single digit decimal number: in a single decimal digit. you can write a number between 0 and 9. and so on.How we store numbers in Comp A number can be signed or unsigned. etc The generalized limit is 0 and 10 n . Since nine is equivalent to 10 1 . 99 is equivalent to 10 2 .1. An unsigned integer is either positive or zero. In two decimal digits.1.

1 For one byte (8 bits) the maximum UNSIGNED number can goes to 0 to 2 8 . .How we store numbers in Comp For a binary number 0 and 2 n .1 = 0 to 255 What about SIGNED number? One common method is to reserve MSB as sign indication.

1 to 2 n-1 .1 For one byte (8 bits) the maximum SIGNED number can goes to -128 to 127 “Instead of storing the ‘-’ sign with the number computer simply assign one bit as a sign bit” Then how computer performs arithmetic? .How we store numbers in Comp The range of the sign number is -2n .

Positive Numbers: Positive 2's complement numbers are represented as the simple binary. Negative Numbers: Negative 2's complement numbers are represented as the binary number that when added to a positive number of the same magnitude equals zero.Negative number representation Property Two's complement representation allows the use of binary arithmetic operations on signed integers. . yielding the correct 2's complement results.

Negative number representation Integer Signed 5 4 3 2 1 0 -1 -2 -3 -4 -5 Unsigned 5 4 3 2 1 0 255 254 253 252 251 2's Complement 0000 0101 0000 0100 0000 0011 0000 0010 0000 0001 0000 0000 1111 1111 1111 1110 1111 1101 1111 1100 1111 1011 .

subtraction by borrowing is difficult and inefficient for digital computers. • However.Subtraction using addition • Conventional addition (using carry) is easily implemented in digital computers. • Much more efficient to implement subtraction using ADDITION OF the COMPLEMENTS of numbers. .

N the (r. •so the 9’s complement of N is (10n-1)-N •99999…….N •For decimal numbers the base or r = 10 and r. complement of N is defined as (rn .Complements of numbers (r-1 )’s Complement •Given a number N in base r having n digits.1) .1= 9. .1)’s 9 9 Digit n-1 9 Next digit 9 Next digit 9 First digit - Digit n .

12389 = 87610.546700= 453299 - 5 4 9 9 2 7 9 3 6 9 8 1 9 9 0 and the 9’s complement of 12389 is 99999.9’s complement Examples 9 9 4 5 9 6 3 9 7 2 9 0 9 9 0 9 Example: Find the 9’s complement of 546700 and 12389 The 9’s complement of 546700 is 999999 . - 1 8 .

1’s complement • For binary numbers. Bit n-1 Bit n-2 ……. Bit 1 Bit 0 1 1 Digit n-1 1 Next digit 1 Next digit 1 First digit - Digit n . • The l’s complement of N is (2n .N. • r-1’s complement is the l’s complement.1) . r = 2 and r — 1 = 1.

n = 4.l’s complement Find r-1 complement for binary number N with four binary digits. The l’s complement of N is (24 .N. r-1 complement for binary means 2-1 complement or 1’s complement.1 = (1111)2.N . = (1111) . we have 24 = (10000)2 and 24 .1) .

l’s complement 1 1 0 1 1 1 0 1 1 0 1 0 1 1 0 1 1 1 0 The complement 1’s of 1011001 is 0100110 - 1 0 1 1 0 1 1 0 1 1 1 0 1 1 0 1 1 0 1 1 0 The 1’s complement of 0001111 is 1110000 - 0 1 .

N - Digit n .r’s Complement •Given a number N in base r having n digits. 1 0 0 Digit n-1 0 Next digit 0 Next digit 0 First digit •so the 10’s complement of N is 10n-N.N. . •100000……. •For decimal numbers the base or r = 10. •the r’s complement of N is defined as rn .

12389 = 87611. 1 0 5 4 0 4 5 0 6 3 0 7 3 0 0 0 0 0 0 - 1 0 1 8 0 2 7 0 3 6 0 8 1 0 9 1 - .546700= 453300 and the 10’s complement of 12389 is 100000 .10’s complement Examples Find the 10’s complement of 546700 and 12389 The 10’s complement of 546700 is 1000000 . Notice that it is the same as 9’s complement + 1.

r’s complement is the 2’s complement.2’s complement For binary numbers. 1 0 0 Digit n-1 0 Next digit 0 Next digit 0 First digit - Digit n . The 2’s complement of N is 2n .N. r = 2.

2’s complement Example 1 0 1 0 0 0 1 0 1 0 0 1 0 0 0 1 0 0 1 0 1 1 The 2’s complement of 1011001 is 0100111 1 0 0 1 0 0 1 0 0 1 0 1 0 0 1 0 0 1 0 0 1 1 The 2’s complement of 0001111 is 1110001 - .

Fast Methods for 2’s Complement Method 1: The 2’s complement of binary number is obtained by adding 1 to the l’s complement value. Example: 1’s complement of 101100 is 010011 (invert the 0’s and 1’s) 2’s complement of 101100 is 010011 + 1 = 010100 .

Fast Methods for 2’s Complement Method 2: The 2’s complement can be formed by leaving all least significant 0’s and the first 1 unchanged. and then replacing 1’s by 0’s and 0’s by 1’s in the four most significant bits. . Example: The 2’s complement of 1101100 is 0010100 Leave the two low-order 0’s and the first 1 unchanged. and then replacing l’s by 0’s and 0’s by l’s in all other higher significant bits.

(01100101)2 [N] = 2’s complement = 1’s complement (10011010)2 +1 =(10011011)2 • Method 2 – Starting with the least significant bit.Examples Finding the 2’s complement of (01100101)2 • Method 1 – Simply complement each bit and then add 1 to the result. copy all the bits up to and including the first 1 bit and then complement the remaining bits. N =01100101 [N] = 1 0 0 1 1 0 1 1 .

the negative sign will produce an end carry rn we need to take the r’s complement again.) .Subtraction of Unsigned Numbers using r’s complement Subtract N from M : • r’s complement • add M to ( rn – N ) : M–N N (rn – N ) Sum = M + ( r n – N) • take r’s complement (If M N.

take the r’s complement of sum and place negative sign in front of sum. . The answer is negative.Subtraction of Unsigned Numbers using r’s complement • (1) if M N. ignore the carry without taking complement of sum. • (2) if M < N.

Example 1 (Decimal unsigned numbers). perform the subtraction 72532 . M > N : “Case 1” “Do not take complement of sum and discard carry” The 10’s complement of 13250 is 86750.13250 = 59282. Therefore: M= 72532 10’s complement of N =+86750 Sum= 159282 Discard end carry 105= .100000 Answer = 59282 no complement .

Now consider an example with M <N. Using the procedure with complements. we have M = 13250 10’s complement of N = +27468 Sum = 40718 Take 10’s complement of Sum = 100000 -40718 The number is : 59282 Place negative sign in front of the number: -59282 . The subtraction 13250 .72532 produces negative 59282.Example 2.

Sign up to vote on this title

UsefulNot useful- Lecture Notes 3 (CSC-103)
- Hexadecimal Numbers
- Converting Denary to Hex
- Hexadecimal Number System
- New Microsoft Word Document
- lecture2_Numbersystems_.ppt;filename_= UTF-8''lecture2(Numbersystems)-1
- Number System
- Hexadecimal - Learn.sparkfun.com
- Hex Numbering System
- System of Num.
- Base Conversion
- Base Conversion
- Hexadecimal Numbers
- Computer Number System
- Cosysor Assignment (09!27!11)
- CH09-COA10e
- Hexadecimal Numbers
- Number Systems
- WP Mays Number Decode 1
- Hex 2 Bi
- Assembler
- binary worksheet.doc
- 02Data Representation
- Hexadecimal and Binary Number System Basics for Embedded Programming
- Numerical Bases
- How to Convert Between Base 10 Hexadecimal and B
- binaryhexaoctal
- Numerical Bases
- Slayt2 Fundamentals
- N301. M2. NumberSystems
- Lecture 1 2

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

We've moved you to where you read on your other device.

Get the full title to continue

Get the full title to continue reading from where you left off, or restart the preview.

scribd