27
1 CSE-221 CSE-221 Digital Logic Digital Logic Design (DLD) Design (DLD) Lecture-1: Digital Systems & Number Systems

CSE-221 Digital Logic Design (DLD)

Embed Size (px)

DESCRIPTION

CSE-221 Digital Logic Design (DLD). Lecture-1: Digital Systems & Number Systems. Decimal Numbers. Uses 10 digits [ 0, 1, 2, . . . 9 ]. Positional Number Notation Weight of digit determined by its position. Example: 246= 200 + 40 + 6 = 2 x 10 2 + 4 x 10 1 + 6 x 10 0. In general: - PowerPoint PPT Presentation

Citation preview

Page 1: CSE-221 Digital Logic Design (DLD)

1

CSE-221CSE-221Digital Logic Digital Logic Design (DLD)Design (DLD)

Lecture-1: Digital Systems & Number

Systems

Page 2: CSE-221 Digital Logic Design (DLD)

2

Uses 10 digits [ 0, 1, 2, . . . 9 ] Uses 10 digits [ 0, 1, 2, . . . 9 ]

Decimal Numbers Decimal Numbers

In general:

N = Ni x 10i where Ni [0, 1, 2, . . .8, 9],

where Ni are the weights and the base of the number

System, i.e., 10, is raised to the exponent i.

Note: decimal fractions occur when i is negative

0.35 = 3 x 10-1 + 5 x 10-2

In general:

N = Ni x 10i where Ni [0, 1, 2, . . .8, 9],

where Ni are the weights and the base of the number

System, i.e., 10, is raised to the exponent i.

Note: decimal fractions occur when i is negative

0.35 = 3 x 10-1 + 5 x 10-2

Positional Number NotationPositional Number Notation

Weight of digit determined by its position.

Positional Number NotationPositional Number Notation

Weight of digit determined by its position.

Example: 246 = 200 + 40 + 6

= 2 x 102 + 4 x 101 + 6 x 100

Page 3: CSE-221 Digital Logic Design (DLD)

3

Binary NumbersBinary NumbersUses 2 digits [ 0 & 1 ] Uses 2 digits [ 0 & 1 ]

Example:

1110012 = 1000002 + 100002 + 10002 + 0002 + 002 + 12

= 1 x 25 + 1 x 24 + 1 x 23 + 0 x 22 + 0 x 21 + 1 x 20

= 1 x 32 + 1 x 16 + 1 x 8 + 0 x 4 + 0 x 2 + 1 x 1

= 5710

In general:

N = Ni x 2i where Ni [0, 1].

Note: binary fractions occur when i is negative

0.112 = 1x 2-1 + 1 x 2-2 = 0.510 + 0.2510 = 0.7510

In general:

N = Ni x 2i where Ni [0, 1].

Note: binary fractions occur when i is negative

0.112 = 1x 2-1 + 1 x 2-2 = 0.510 + 0.2510 = 0.7510

Positional Number NotationPositional Number NotationPositional Number NotationPositional Number Notation

Page 4: CSE-221 Digital Logic Design (DLD)

4

Hexadecimal (Hex) NumbersHexadecimal (Hex) Numbers

Example:

89AB16 = 800016 + 90016 + A016 + B16

= 8 x 163 + 9 x 162 + A x 161 + B x 160

= 8 x 4096 + 9 x 256 + 10 x 16 + 11 x 1 = 3524310

Uses 16 digits [ 0, 1, 2, . . . 9, A, B, C, D, E, F ]Uses 16 digits [ 0, 1, 2, . . . 9, A, B, C, D, E, F ]

In general:

N = Ni x 16i where Ni [0, 1, 2, ..., 9, A, B, C, D, E, F].

Note: hexadecimal fractions occur when i is negative

0.9A16 = 9 x 16-1 + 10 x 16-2 = 0.562510 + 0.039062510 = 0.601562510

In general:

N = Ni x 16i where Ni [0, 1, 2, ..., 9, A, B, C, D, E, F].

Note: hexadecimal fractions occur when i is negative

0.9A16 = 9 x 16-1 + 10 x 16-2 = 0.562510 + 0.039062510 = 0.601562510

Note: A - F represent the decimal values of 10 - 15, respectively.Note: A - F represent the decimal values of 10 - 15, respectively.

Positional Number NotationPositional Number NotationPositional Number NotationPositional Number Notation

Page 5: CSE-221 Digital Logic Design (DLD)

5

Conversion Among Bases Conversion Among Bases In general, with positional number notation and the known decimal weights for each position in any arbitrary base, it is easiest to convert other bases to decimal.

This was demonstrated in each previous example where the decimal value was found using the equation for base B:

Ni x Bi where Ni [0, 1, 2, . . . , B-1] and

substituting the equivalent decimal weight for the digits Ni and

the decimal value of Bi.

Conversion among the 2n bases (binary, hexadecimal, octal, etc.) is most easily achieved by first converting to binary, regrouping into n bits (starting at the base point) and then converting the groups of bits into the proper digits.

Page 6: CSE-221 Digital Logic Design (DLD)

6

Memorize this table!!!

It makes conversions between hexadecim

al and binary trivial

Memorize this table!!!

It makes conversions between hexadecim

al and binary trivial

Hexadecimal Hexadecimal Binary Binary

Hex Binary Decimal0 0000 01 0001 12 0010 23 0011 34 0100 45 0101 56 0110 67 0111 78 1000 89 1001 9A 1010 10B 1011 11C 1100 12D 1101 13E 1110 14F 1111 15

Hex Binary Decimal0 0000 01 0001 12 0010 23 0011 34 0100 45 0101 56 0110 67 0111 78 1000 89 1001 9A 1010 10B 1011 11C 1100 12D 1101 13E 1110 14F 1111 15

Example: convert 100110001110011012 hexadecimalGroup by 4s, starting at the right expand into 4 bit groups

1 0011 0001 1100 11012 1 3 1 C D16

Example: convert 100110001110011012 hexadecimalGroup by 4s, starting at the right expand into 4 bit groups

1 0011 0001 1100 11012 1 3 1 C D16

Page 7: CSE-221 Digital Logic Design (DLD)

7

Decimal Decimal Binary Binary

Example:57 2 = 28, remainder = 1 (binary number will end with 1)28 2 = 14, remainder = 014 2 = 7, remainder = 0 7 2 = 3, remainder = 1 3 2 = 1, remainder = 1 1 2 = 0, remainder = 1 (binary number will start with 1)

Therefore, collecting the remainders, 5710 = 1110012

(((((0x2 + 1)x2 + 1)x2 + 1)x2 +0)x2 +0)x2 +1 = 1x32 + 1x16 + 1x8 + 0x4 + 0x2 + 1x1 = 57

(check: 32 + 16 + 8 + 0 + 0 + 1 = 57)

Based on the remainders after dividing the decimal number by higher powers of 2.

If the decimal number is even, the corresponding binary number will end in a 0, and if it is odd, the binary number will end in a 1, and so on.

Based on the remainders after dividing the decimal number by higher powers of 2.

If the decimal number is even, the corresponding binary number will end in a 0, and if it is odd, the binary number will end in a 1, and so on.

Successive Division:Successive Division: an easy way to convert Decimal to BinarySuccessive Division:Successive Division: an easy way to convert Decimal to Binary

Page 8: CSE-221 Digital Logic Design (DLD)

8

Decimal Decimal Hex Hex

Example:35243 / 16= 2202, remainder = 11 B (hex number will end with B) 2202 / 16= 137, remainder = 10 A 137 / 16= 8, remainder = 9 8 / 16 = 0, remainder = 8 (hex number will start with 8)

Therefore, collecting the remainders, 3524310 = 89AB16

(check: 8 x 4096 + 9 x 256 +10 x 16 + 11 = 35243)

Successive Division:Successive Division: an easy way to convert Decimal to HexadecimalSuccessive Division:Successive Division: an easy way to convert Decimal to Hexadecimal

Based on the remainders after dividing the decimal number by higher powers of 16.

Based on the remainders after dividing the decimal number by higher powers of 16.

Page 9: CSE-221 Digital Logic Design (DLD)

9

Hex Hex Decimal Decimal

Example:BA89 B x 163 + A x 162 + 8 x 16 + 9

(CAUTION: mixed bases)

= 11 x 4096 + 10 x 256 + 8 x 16 + 9= 45056 + 2560 + 128 + 9= 47753

We can check by converting back to hex:

47753 / 16 = 2984 + remainder, 9

2984 / 16 = 186 + remainder, 8

186 / 16 = 11 + remainder, 10 A

11 / 16 = 0 + remainder, 11 B

4775310 BA8916

Multiplication:Multiplication: an easy way to convert Hexadecimal to DecimalMultiplication:Multiplication: an easy way to convert Hexadecimal to Decimal

Multiply the hexadecimal weights by powers of 16. Multiply the hexadecimal weights by powers of 16.

Page 10: CSE-221 Digital Logic Design (DLD)

10

Binary Binary Decimal Decimal

Compare:

110101102 27 + 26 + 24 + 22 + 2 (exploiting the binary weights)= 128 + 64 + 16 + 4 + 2= 21410

110101102 D616 13 x 16 + 6 = 208 + 6 = 21410

Multiplication:Multiplication: an easy way to convert Binary to DecimalMultiplication:Multiplication: an easy way to convert Binary to Decimal

We can multiple the binary weights by powers of 2.

However, sometimes it is just as easy to convert the binary number to hexadecimal first and and then into decimal.

We can multiple the binary weights by powers of 2.

However, sometimes it is just as easy to convert the binary number to hexadecimal first and and then into decimal.

Page 11: CSE-221 Digital Logic Design (DLD)

11

• Computers have circuits that do binary

arithmetic.

• You already know the rules for decimal

addition and subtraction (how to handle sums,

carries, differences, and borrows).

• Analogously, we develop the rules for binary

addition and subtraction.

Binary ArithmeticBinary Arithmetic

Page 12: CSE-221 Digital Logic Design (DLD)

12

9510 9 x 101 + 5 x 100

+ 1610 + 1 x 101 + 6 x 100

10 x 101 + 11 x 100

11110

Decimal AdditionDecimal Addition

SummarySummary

11 Column carries

9510

+ 1610

11110

RefresherRefresher

= 1 x 102 + (0+1) x 101 + 1 x 100

Page 13: CSE-221 Digital Logic Design (DLD)

13

Binary AdditionBinary Addition

0 + 0 = 0

0 + 1 = 1

1 + 0 = 1

1 + 1 = 0 with a carry of 1

0 + 0 = 0

0 + 1 = 1

1 + 0 = 1

1 + 1 = 0 with a carry of 1

This table calculates the sum for pairs of binary numbersThis table calculates the sum for pairs of binary numbers

Also know as the Half Adder TableAlso know as the Half Adder Table

Page 14: CSE-221 Digital Logic Design (DLD)

14

Binary Addition with CarryBinary Addition with Carry

carry addend augend sum

0 + 0 + 0 = 0

0 + 0 + 1 = 1

0 + 1 + 0 = 1

0 + 1 + 1 = 0 with a carry of 1

1 + 0 + 0 = 1

1 + 0 + 1 = 0 with a carry of 1

1 + 1 + 0 = 0 with a carry of 1

1 + 1 + 1 = 1 with a carry of 1

carry addend augend sum

0 + 0 + 0 = 0

0 + 0 + 1 = 1

0 + 1 + 0 = 1

0 + 1 + 1 = 0 with a carry of 1

1 + 0 + 0 = 1

1 + 0 + 1 = 0 with a carry of 1

1 + 1 + 0 = 0 with a carry of 1

1 + 1 + 1 = 1 with a carry of 1

This table shows all the possible sums for binary numbers with carriesThis table shows all the possible sums for binary numbers with carries

Also known as the Full Adder TableAlso known as the Full Adder Table

Page 15: CSE-221 Digital Logic Design (DLD)

15

Binary AdditionBinary Addition

(carries)

1 0 12 = 510

+ 1 12 = 310

= 810

Example: Add 5 and 3 in binaryExample: Add 5 and 3 in binary

1

1 10

1

10

1

102

Similar to the decimal caseSimilar to the decimal case

Page 16: CSE-221 Digital Logic Design (DLD)

16

borrow = -1x101

9 1510 95 = 9x101 + 5x100 = 9x101 + 15x100

- 1 610 -16 = -1x101 + -6x100 = -1x101 + -6x100 -

1

7 910 7x101 + 9x100

Decimal SubtractionDecimal Subtraction

Note: borrows are shown as explicit subtractions.Note: borrows are shown as explicit subtractions.

RefresherRefresher

Page 17: CSE-221 Digital Logic Design (DLD)

17

Binary SubtractionBinary Subtraction

0 - 0 = 0

0 - 1 = 1 with a borrow of 1

1 - 0 = 1

1 - 1 = 0

0 - 0 = 0

0 - 1 = 1 with a borrow of 1

1 - 0 = 1

1 - 1 = 0

This table calculates the difference for pairs of binary numbersThis table calculates the difference for pairs of binary numbers

Also known as the Half Subtractor TableAlso known as the Half Subtractor Table

Page 18: CSE-221 Digital Logic Design (DLD)

18

Binary Subtraction with Binary Subtraction with BorrowBorrow

minuend subtrahend borrow difference

0 - 0 - 0 = 0

0 - 0 - 1 = 1 with a borrow of 1

0 - 1 - 0 = 1 with a borrow of 1

0 - 1 - 1 = 0 with a borrow of 1

1 - 0 - 0 = 1

1 - 0 - 1 = 0

1 - 1 - 0 = 0

1 - 1 - 1 = 1 with a borrow of 1

minuend subtrahend borrow difference

0 - 0 - 0 = 0

0 - 0 - 1 = 1 with a borrow of 1

0 - 1 - 0 = 1 with a borrow of 1

0 - 1 - 1 = 0 with a borrow of 1

1 - 0 - 0 = 1

1 - 0 - 1 = 0

1 - 1 - 0 = 0

1 - 1 - 1 = 1 with a borrow of 1

This shows all the possibile differences for binary numbers with borrowsThis shows all the possibile differences for binary numbers with borrows

Also known as the Full Subtractor TableAlso known as the Full Subtractor Table

Page 19: CSE-221 Digital Logic Design (DLD)

19

Binary SubtractionBinary Subtraction

1 0 12 = 510

- 1 12 = 310

2 = 210

Similar to the decimal caseSimilar to the decimal case

Example: Subtract 3 from 5 in binaryExample: Subtract 3 from 5 in binary

0

- 1 (borrows)

10

0 1

Page 20: CSE-221 Digital Logic Design (DLD)

20

Number SystemsNumber Systems

PositivePositive numbers are same in most systems

Major differences are in how negativenegative numbers are represented

Two major schemes:

sign & magnitudesign & magnitude two’s- two’s-complementcomplement

For the examples assume a 4 bit machine word

16 different values can be represented

roughly half are positive, half are negative

Representation of IntegersRepresentation of Integers

Page 21: CSE-221 Digital Logic Design (DLD)

21

Sign & Magnitude RepresentationSign & Magnitude Representation

• SignSign equals the High order bit: equals the High order bit: 0 = positive or zero (non-negative)

1 = negative

• MagnitudeMagnitude equals the three low order bits: equals the three low order bits: 0 = 000 thru 7 = 111

• The number range = 7 for 4 bit numbers; for nn bits, 2n-1 -1

• Two Representations for 0 (redundant & problematic)

0000

0111

0011

1011

11111110

1101

1100

1010

1001

1000

0110

0101

0100

0010

0001

++00+1

+2

+3

+4

+5

+6

+7--00

-1

-2

-3

-4

-5

-6

-7

0 100 = + 4

1 100 = - 4

+ sign+ sign

- sign- sign

4 bit example4 bit example

Page 22: CSE-221 Digital Logic Design (DLD)

22

Sign & MagnitudeSign & Magnitude

4

+ 3

7

0100

0011

0111

-4

+ (-3)

-7

1100

1011

1111

Sign of the result:Sign of the result:the same as the operands'sign

(Don’t add sign bits)(Don’t add sign bits)(Don’t add sign bits)(Don’t add sign bits)

Operands have the same signOperands have the same sign

4

+ (-3)

1

0100

1011

0001

-4

+ 3

-1

1100

0011

1001

Sign of the result:Sign of the result:the sign of operand with the larger magnitude

Magnitude of the Magnitude of the result:result:subtraction operation

Operands have different signsOperands have different signs

AdditionAddition

Page 23: CSE-221 Digital Logic Design (DLD)

23

Sign & MagnitudeSign & Magnitude

4

- 3

1

0100

0011

0001

-4

- (-3)

-1

1100

1011

1001

Sign of the result:Sign of the result:the same as the operands'sign

(Don’t subtract sign bits)(Don’t subtract sign bits)(Don’t subtract sign bits)(Don’t subtract sign bits)

Operands have the same signOperands have the same sign

4

- (-3)

7

0100

1011

0111

-4

- 3

-7

1100

0011

1111

Sign of the result:Sign of the result:the sign of operand withthe larger magnitude

Magnitude of the Magnitude of the result:result:addition operation

Operands have different signsOperands have different signs

SubtractionSubtraction

Page 24: CSE-221 Digital Logic Design (DLD)

24

Page 25: CSE-221 Digital Logic Design (DLD)

25

Page 26: CSE-221 Digital Logic Design (DLD)

26

Page 27: CSE-221 Digital Logic Design (DLD)