EE221 Lecture 1 - 3
EE221 Lecture 1 - 3
Chapter 1:
Digital Systems and Binary Numbers
1
Subtraction with Complements
• The subtraction of two n-digit unsigned numbers M – N in base r can be done as follows:
– Add the minuend, M, to the r’s complement of the subtrahend, N:
» M + (rn – N) = M – N + rn
– If M N, the sum will produce an end carry, r n, which can be discarded; what is left is the result
of M – N.
– If M N, the sum does not produce an end carry and is equal to r n – (N – M), which is the r’s
complement of (N – M). To obtain the answer in a familiar form, take the r’s complement of the
sum and place a negative sign in front.
» 10’s complement by leaving all LSB 0s unchanged, subtract first non-zero digit from 10
and rest all digits from 9
• Note that the extra 9 in the 10’s complement of N is to fill the space holder 0.
10’s Complement Subtraction
sign bit
1 1 1 1 0 1 1 0
Negative
0 0 0 0 1 0 1 0 Positive
Signed Complement System
• Note that to determine 2’s complement, leave the least significant 0’s and
the first 1 unchanged and then switch the remaining 1’s to 0’ and 0’s to 1’s.
Number Representations
• The following is the representation for +11:
– 00001011
• The following are different methods for representing -11:
– Signed magnitude: 10001011
– Signed-1’s-complement: 11110100
– Signed-2’s-complement: 11110101
• This system doesn’t require the comparison of the signs and the
magnitudes (as in signed-magnitude system), but only addition.
• The addition of two signed binary numbers with negative numbers
represented in signed-2’s complement form is obtained from
addition of the two numbers, including their sign bits.
• A carry out of the sign-bit position is discarded.
• If the sum is negative, it will be in 2’s complement form.
Arithmetic Subtraction
• BCD only represents each of the decimal digitals 0 through 9 as a single 4-bit
binary value.
• When adding two BCD values, if the sum is equal to or less than 1001 (9), the
corresponding BCD value is correct.
• However, when the binary sum is greater or equal to 1010 (10), the result is an
invalid BCD value.
– To overcome the invalid BCD value, add 0110 (6) to the result to obtain the
BCD representation and produces a carry as required.
» The use of 0110 (6) works because the difference between a carry in the
most significant bit position of the binary sum and a decimal carry differ
by 16-10 = 6.
BCD Arithmetic
• BCD arithmetic involving negative numbers uses the 10’s
complement for representing the negative numbers including
the sign digit.
– 0 (0000) represents a positive sign and 9 (1001) represents a negative sign
• As an example, imagine we want to add
(+257) + (-160) = +97
• Note: To obtain 10’s complement of a BCD number, we first take the 9’s
complement (by subtraction of each digit from 9) and then add one to
least significant digit
Other Decimal Codes
P Information Bits
1 1 0 0 0 0 1 1 0 1 0 0 0 0 1 1
Added even parity bit Added odd parity bit
Parity Code Example
0 0 1 0 1 0 1 1
Binary Cell
• The memory cell is an electronic circuit that stores one bit of binary information and it must be set to store a logic 1
(high voltage level) and reset to store a logic 0 (low voltage level). Its value is maintained/stored until it is changed
by the set/reset process. The value in the memory cell can be accessed by reading it.
Register Transfer
• A Register transfer operation involves the
transfer of binary information from one set
of binary registers into other set of binary
registers.
• The capture and storage of information
requires:
– An input register to store the key inputs
from the keyboard
– A processor register to store the data
when processed by the CPU
– A memory register in the memory unit
to store the values
• We need processing
• We need storage
• We need communication
Binary Logic
• Binary logic consists of binary variables and logical operations.
– The variables are designated by letters of the alphabet (A, B, C, x, y, z, etc.).
– There are three basic logical operations:
» AND
» OR
» NOT
NOT
A A'
0 1
1 0
Truth Tables
AND
A B A.B
0 0 0
0 1 0
1 0 0
1 1 1
OR
A B A+B
0 0 0
0 1 1
1 0 1
1 1 1
Binary Signal
• Logic gates are electronic circuits that operate on one or more input
signals to produce an output signal.
– The state (high-low, on-off) of electricity on a line represents each of the two states for
binary representation (1 or 0).