Skip to content
digiwleeaTools
LearnGlossaryAboutCheat sheetHow a CPU worksBuild a CPUToolsOpen the lab →

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.

Big circuit: pinch, scroll or tap + to zoom in, then drag to move around.

Live circuit: click the inputs to toggle them and watch the outputs update. It runs the real simulator, right here on the page.

Open this circuit in the lab →

Embed or cite this circuit

Free to embed on a course page, blog or worksheet: paste this code. The circuit stays live, and the small digiwleea badge links back here.

To cite it: digiwleea, “Full subtractor using a decoder”, https://digiwleea.wleeaf.dev/tools/build/full-subtractor-decoder/

What you need

Step by step

  1. Place inputs A, B and Bin and a 3-to-8 decoder with A as the most significant select bit.
  2. 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).
  3. OR decoder lines 1, 2, 4 and 7 into D, and lines 1, 2, 3 and 7 into Bout.
  4. Step through all eight rows and check A - B - Bin = D - 2 Bout.

Full subtractor truth table with minterms

Row (minterm)ABBinDBout
m000000
m100111
m201011
m301101
m410010
m510100
m611000
m711111

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.