Full subtractor using a 3-to-8 decoder and OR gates, live
A full subtractor computes A - B - Bin and gives a difference D and a borrow out Bout. With a 3-to-8 decoder it takes just two OR gates: the decoder lights the minterm for the current row, and D = m1 + m2 + m4 + m7, Bout = m1 + m2 + m3 + m7.
As with the full adder using a decoder, the decoder turns A, B and Bin into one active line per row, so each output is the OR of the rows where it is 1, read straight from the truth table. The difference is the same as a full adder's sum, 1 when an odd number of inputs are 1 (rows 1, 2, 4, 7). The borrow differs from the carry: you need to borrow when A is 0 and B or Bin is 1, or when B and Bin are both 1 (rows 1, 2, 3 and 7), that is Bout = A'B + A'Bin + B Bin. Compare the gate-level full subtractor from two half subtractors.
Open this circuit in the lab →
What you need
- 1× 3-to-8 decoder (3 NOT, 12 AND): one line per minterm of A B Bin
- 3× OR: D = m1 + m2 + m4 + m7
- 3× OR: Bout = m1 + m2 + m3 + m7
Step by step
- Place inputs
A,BandBinand a 3-to-8 decoder with A as the most significant select bit. - Write the full subtractor's truth table and note the rows where D is 1 (1, 2, 4, 7) and where Bout is 1 (1, 2, 3, 7).
- OR decoder lines 1, 2, 4 and 7 into
D, and lines 1, 2, 3 and 7 intoBout. - Step through all eight rows and check A - B - Bin = D - 2 Bout.
Full subtractor truth table with minterms
| Row (minterm) | A | B | Bin | D | Bout |
|---|---|---|---|---|---|
| m0 | 0 | 0 | 0 | 0 | 0 |
| m1 | 0 | 0 | 1 | 1 | 1 |
| m2 | 0 | 1 | 0 | 1 | 1 |
| m3 | 0 | 1 | 1 | 0 | 1 |
| m4 | 1 | 0 | 0 | 1 | 0 |
| m5 | 1 | 0 | 1 | 0 | 0 |
| m6 | 1 | 1 | 0 | 0 | 0 |
| m7 | 1 | 1 | 1 | 1 | 1 |
All eight rows of the live circuit are checked before the page is built.
You can also read the full theory in the lesson on subtraction. Prefer to build it yourself from scratch? Open the digiwleea lab and place the gates on the canvas, or start from the logic gate simulator.
More builds: Arithmetic
All 246 build guides, by topic
Each of these is one step from a transistor to a working CPU. Build every gate from CMOS transistors and work all the way up in the free digiwleea lab, with the free theory reference alongside.
Open the Full subtractor using a decoder in the lab →Frequently asked
How do you implement a full subtractor using a decoder?
Use a 3-to-8 decoder with A, B and Bin as inputs. OR together outputs 1, 2, 4 and 7 for the difference, and outputs 1, 2, 3 and 7 for the borrow out.
What is the difference between a full adder and a full subtractor on a decoder?
The difference output uses the same minterms as the sum (1, 2, 4, 7). Only the second output changes: carry is m3 + m5 + m6 + m7, borrow is m1 + m2 + m3 + m7.
Can one decoder implement a full adder and a full subtractor together?
Yes. The decoder's eight lines can feed any number of OR gates, so the sum or difference, the carry and the borrow can all come from one decoder.