Digital Logic Design Chapter 1 Part b Digital

Digital Logic Design Chapter 1 (Part b) Digital Systems and Binary Numbers Originally by T. Tasniem Nasser Al-Yahya

Outline of Chapter 1 (Part b) © 1. 5 Complements

Complements © 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.

1. 5 Complements © There are two types of complements for each base-r system: u Diminished Radix Complement - (r-1)’s Complement. u Radix Complement - (r)’s Complement.

Complements Diminished Radix Complement-(r-1)’s Complement © Given a number N in base r having n digits, the (r– 1)’s complement of N is defined as: (rn – 1) – N

Complements Diminished Radix Complement-(r-1)’s Complement © Example for 6 -digit decimal numbers: Subtract each digit from 9 9’s complement of 546700 is 999999– 546700 = 453299 © Example for 7 -digit binary numbers: Subtract each digit from 1 (1 -0=1, 1 -1=0) 1’s complement of 1011000 is 1111111– 1011000 = 0100111 © Observation: Subtraction from (rn – 1) will never require a borrow u Diminished radix complement can be computed digit-by-digit u For binary: 1 – 0 = 1 and 1 – 1 = 0 u

Complements Diminished Radix Complement-(r-1)’s Complement © 1’s Complement (Diminished Radix Complement) All ‘ 0’s become ‘ 1’s u All ‘ 1’s become ‘ 0’s Example (10110000)2 (01001111)2 If you add a number and its 1’s complement … u 10110000 + 01001111

Complements Radix Complement-(r)’s Complement © Given a number N in base r having n digits, the (r)’s complement of N is defined as: Comparing with the (r 1) 's complement, we note that the r's complement is obtained by adding 1 to the (r 1) 's complement, since rn – N = [(rn 1) – N] + 1.

Complements Radix Complement-(r)’s Complement © Example: Base-10 The 10's complement of 012398 is 987602 ( 9's complement+1) The 10's complement of 246700 is 753300 © Example: Base-2 The 2's complement of 1101100 is 0010100 ( 1's complement+1) The 2's complement of 0110111 is 1001001 © Observation: u For binary: starting from right to left keep all the zeroes unchanged and toggle all bits to the left of the first ‘ 1’.

Complements Subtraction using Complements © When subtraction is implemented with digital hardware it is more efficient to use complements. © Procedure for subtracting two n-digit unsigned numbers M – N in base r : u Line up the numbers from right to left. If one number is shorter extend it by adding leading zeros to the front of the number. (my notes) u Add minuend M to the r's complement of the subtrahend N. » This performs M + (rn - N)

Complements subtraction using Complements If M >= N, the sum will produce an end carry rn which is discarded, and what is left is the result M - N u If M < N, the sum does not produce an end carry. It is equal to the r's complement of (M - N). » The correct answer is generated by − taking the r's complement of the answer − then adding a negative sign to the front u Overflow

Complements subtraction using Complements © Example 1. 7 u Given the two binary numbers X = 1010100 and Y = 1000011, perform the subtraction (a) X – Y ; and (b) Y X, by using 2's complement. Discard carry There is no end carry. To clarify, the answer is Y – X = (2's complement of 1101111) = 0010001.

Reading © Chapter 1: 1. 5
- Slides: 13