written 2.6 years ago by |
Solution:
The Comparison:
Magnitude comparison is performed by a logic circuit called a comparator. A comparator compares two quantities and indicates whether or not they are equal.
For example, suppose you have two numbers and wish to know if they are equal or not equal and, if not equal, which is greater. The comparison function is represented in Figure.
One number in binary form (represented by logic levels) is applied to input A, and the other number in binary form (represented by logic levels) is applied to input B.
The outputs indicate the relationship of the two numbers by producing a HIGH level on the proper output line.
Suppose that a binary representation of the number 2 is applied to input A and a binary representation of the number 5 is applied to input B.
A HIGH level will appear on the A 6 B (A is less than B) output, indicating the relationship between the two numbers (2 is less than 5).
The wide arrows represent a group of parallel lines on which the bits are transferred.
The Arithmetic Functions:
(1) Addition:
Addition is performed by a logic circuit called an adder, covered in Chapter 6. An adder adds two binary numbers (on inputs A and B with a carry input Cin) and generates a sum and a carry output (Cout), as shown in Figure(a).
Figure(b) illustrates the addition of 3 and 9. You know that the sum is 12; the adder indicates this result by producing 2 on the sum output and 1 on the carry output.
Assume that the carry input in this example is 0.
(2) Subtraction:
Subtraction is also performed by a logic circuit. A subtracter requires three inputs: the two numbers that are to be subtracted and a borrow input.
The two outputs are the differ?ence and the borrow output. When, for instance, 5 is subtracted from 8 with no borrow input, the difference is 3 with no borrow output.
You will see in Chapter 2 how subtraction can actually be performed by an adder because subtraction is simply a special case of addition.
(3) Multiplication:
Multiplication is performed by a logic circuit called a multiplier. Numbers are always multiplied two at a time, so two inputs are required.
The output of the multiplier is the product. Because multiplication is simply a series of additions with shifts in the positions of the partial products, it can be performed by using an adder in conjunction with other circuits.
(4) Division:
Division can be performed with a series of subtractions, comparisons, and shifts, and thus it can also be done using an adder in conjunction with other circuits.
Two inputs to the divider are required, and the outputs generated are the quotient and the remainder.