HOME

TheInfoList



OR:

In
electronics The field of electronics is a branch of physics and electrical engineering that deals with the emission, behaviour and effects of electrons using electronic devices. Electronics uses active devices to control electron flow by amplification ...
, a subtractor – a
digital circuit In theoretical computer science, a circuit is a model of computation in which input values proceed through a sequence of gates, each of which computes a function. Circuits of this kind provide a generalization of Boolean circuits and a mathematical ...
that performs subtraction of numbers – can be designed using the same approach as that of an adder. The
binary Binary may refer to: Science and technology Mathematics * Binary number, a representation of numbers using only two digits (0 and 1) * Binary function, a function that takes two arguments * Binary operation, a mathematical operation that t ...
subtraction process is summarized below. As with an adder, in the general case of calculations on multi-bit numbers, three
bit The bit is the most basic unit of information in computing and digital communications. The name is a portmanteau of binary digit. The bit represents a logical state with one of two possible values. These values are most commonly represente ...
s are involved in performing the subtraction for each bit of the
difference Difference, The Difference, Differences or Differently may refer to: Music * ''Difference'' (album), by Dreamtale, 2005 * ''Differently'' (album), by Cassie Davis, 2009 ** "Differently" (song), by Cassie Davis, 2009 * ''The Difference'' (al ...
: the
minuend Subtraction is an arithmetic operation that represents the operation of removing objects from a collection. Subtraction is signified by the minus sign, . For example, in the adjacent picture, there are peaches—meaning 5 peaches with 2 taken ...
(X_),
subtrahend Subtraction is an arithmetic operation that represents the operation of removing objects from a collection. Subtraction is signified by the minus sign, . For example, in the adjacent picture, there are peaches—meaning 5 peaches with 2 taken ...
(Y_), and a borrow in from the previous (less significant) bit order position (B_). The outputs are the difference bit (D_) and borrow bit B_. The subtractor is best understood by considering that the subtrahend and both borrow bits have negative weights, whereas the X and D bits are positive. The operation performed by the subtractor is to rewrite X_-Y_-B_ (which can take the values -2, -1, 0, or 1) as the sum -2B_+D_. : D_ = X_ \oplus Y_ \oplus B_ : B_ = X_ < (Y_ + B_) Subtractors are usually implemented within a binary adder for only a small cost when using the standard
two's complement Two's complement is a mathematical operation to reversibly convert a positive binary number into a negative binary number with equivalent (but negative) value, using the binary digit with the greatest place value (the leftmost bit in big- endian ...
notation, by providing an addition/subtraction selector to the carry-in and to invert the second operand. :-B = \bar + 1 (definition of two's complement notation) :\begin A-B & = A + (-B) \\ & = A + \bar + 1 \\ \end


Half subtractor

The half subtractor is a
combinational circuit In automata theory, combinational logic (also referred to as time-independent logic or combinatorial logic) is a type of digital logic which is implemented by Boolean circuits, where the output is a pure function of the present input only. This i ...
which is used to perform subtraction of two bits. It has two inputs, the
minuend Subtraction is an arithmetic operation that represents the operation of removing objects from a collection. Subtraction is signified by the minus sign, . For example, in the adjacent picture, there are peaches—meaning 5 peaches with 2 taken ...
X and
subtrahend Subtraction is an arithmetic operation that represents the operation of removing objects from a collection. Subtraction is signified by the minus sign, . For example, in the adjacent picture, there are peaches—meaning 5 peaches with 2 taken ...
Y and two outputs the difference D and borrow out B_\text. The borrow out signal is set when the subtractor needs to borrow from the next digit in a multi-digit subtraction. That is, B_ = 1 when X < Y. Since X and Y are bits, B_\text = 1 if and only if X = 0 and Y = 1. An important point worth mentioning is that the half subtractor diagram aside implements X - Y and not Y-X since B_\text on the diagram is given by :B_ = \overline \cdot Y. This is an important distinction to make since subtraction itself is not
commutative In mathematics, a binary operation is commutative if changing the order of the operands does not change the result. It is a fundamental property of many binary operations, and many mathematical proofs depend on it. Most familiar as the name o ...
, but the difference bit D is calculated using an
XOR gate XOR gate (sometimes EOR, or EXOR and pronounced as Exclusive OR) is a digital logic gate that gives a true (1 or HIGH) output when the number of true inputs is odd. An XOR gate implements an exclusive or (\nleftrightarrow) from mathematical log ...
which is commutative. The
truth table A truth table is a mathematical table used in logic—specifically in connection with Boolean algebra, boolean functions, and propositional calculus—which sets out the functional values of logical expressions on each of their functional argumen ...
for the half subtractor is: Using the table above and a
Karnaugh map The Karnaugh map (KM or K-map) is a method of simplifying Boolean algebra expressions. Maurice Karnaugh introduced it in 1953 as a refinement of Edward W. Veitch's 1952 Veitch chart, which was a rediscovery of Allan Marquand's 1881 ''logica ...
, we find the following logic equations for D and B_\text: :D = X \oplus Y :B_\text = \overline X \cdot Y. Consequently, a simplified half-subtract circuit, advantageously avoiding crossed traces in particular as well as a negate gate is:
      X ── XOR ─┬─────── , X-Y, ,  is 0 if X equals Y, 1 otherwise
         ┌──┘   └──┐  
      Y ─┴─────── AND ── borrow, is 1 if Y > X, 0 otherwise
where lines to the right are outputs and others (from the top, bottom or left) are inputs.


Full subtractor

The full subtractor is a
combinational circuit In automata theory, combinational logic (also referred to as time-independent logic or combinatorial logic) is a type of digital logic which is implemented by Boolean circuits, where the output is a pure function of the present input only. This i ...
which is used to perform subtraction of three input
bit The bit is the most basic unit of information in computing and digital communications. The name is a portmanteau of binary digit. The bit represents a logical state with one of two possible values. These values are most commonly represente ...
s: the minuend X, subtrahend Y, and borrow in B_\text. The full subtractor generates two output bits: the difference D and borrow out B_\text. B_\text is set when the previous digit is borrowed from X. Thus, B_\text is also subtracted from X as well as the subtrahend Y. Or in symbols: X - Y - B_\text. Like the half subtractor, the full subtractor generates a borrow out when it needs to borrow from the next digit. Since we are subtracting Y and B_\text from X, a borrow out needs to be generated when X < Y + B_\text. When a borrow out is generated, 2 is added in the current digit. (This is similar to the subtraction algorithm in decimal. Instead of adding 2, we add 10 when we borrow.) Therefore, D = X - Y - B_\text + 2B_\text. The truth table for the full subtractor is: Therefore the equation is: D=X\oplus Y\oplus B_ B_=\barB_+\barY+YB_


See also

*
Adder (electronics) An adder, or summer, is a digital circuit that performs addition of numbers. In many computers and other kinds of microprocessor, processors adders are used in the arithmetic logic units (ALUs). They are also used in other parts of the processor, ...
*
Carry-lookahead adder A carry-lookahead adder (CLA) or fast adder is a type of electronics adder used in digital logic. A carry-lookahead adder improves speed by reducing the amount of time required to determine carry bits. It can be contrasted with the simpler, b ...
* Carry-save adder *
Adding machine An adding machine is a class of mechanical calculator, usually specialized for bookkeeping calculations. In the United States, the earliest adding machines were usually built to read in dollars and cents. Adding machines were ubiquitous off ...
* Adder-subtractor


References

* Foundations Of Digital Electronics by Elijah Mwangi


External links


N bit Binary addition or subtraction using single circuit.
Arithmetic logic circuits 4 Subtraction Binary arithmetic {{CPU technologies, state=collapsed