Skip to content
digiwleeaTools
LearnGlossaryAboutCheat sheetHow a CPU worksToolsOpen the lab →

How to build an excess-3 to BCD code converter

An excess-3 to BCD converter subtracts 3 from a 4-bit excess-3 code E3 E2 E1 E0 to get the decimal digit back as B3 B2 B1 B0. Using the six unused codes as don't-cares it takes six gates: B0 = NOT E0, B1 = E1 XOR E0, B2 = E2 XNOR (E1 AND E0) and B3 = E3 AND (E2 OR E1 E0).

Excess-3 stores each decimal digit as its value plus 3, so the digits 0 to 9 become 0011 to 1100 and the codes 0000 to 0010 and 1101 to 1111 never occur. Those six codes are free in the K-maps, which is what keeps the equations this small. The low bits follow from the subtraction itself: taking away 0011 always flips bit 0, and bit 1 becomes E1 XOR E0. This is the reverse of the BCD to excess-3 converter. Excess-3 is self-complementing: inverting all four bits of a digit's code gives the code of 9 minus that digit, which made it handy for subtraction in early decimal machines. The ten valid codes are checked before the page is built, and the live circuit starts at 0011, the code for 0.

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 →

What you need

Step by step

  1. Place inputs E3 to E0 and probes B3 to B0.
  2. Write the table for the ten valid codes (B = E - 3) and mark codes 0000, 0001, 0010, 1101, 1110 and 1111 as don't-cares.
  3. Read the low bits off directly: B0 = NOT E0 and B1 = E1 XOR E0.
  4. From the K-maps: B2 = E2 XNOR (E1 E0) and B3 = E3 (E2 + E1 E0), sharing the AND of E1 and E0.
  5. Step through 0011 to 1100: the outputs count 0000 to 1001.

Excess-3 to BCD table

DigitExcess-3 E3 E2 E1 E0BCD B3 B2 B1 B0
000110000
101000001
201010010
301100011
401110100
510000101
610010110
710100111
810111000
911001001

Codes 0000, 0001, 0010, 1101, 1110 and 1111 never appear in excess-3, so the circuit's output for them does not matter; the equations above use that freedom.

You can also read the full theory in the lesson on BCD. 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.

Build more parts from gates

half adderfull adderhalf subtractorfull subtractor2:1 multiplexer4:1 multiplexerXOR gate from NAND gates2-to-4 decoderSR latchD flip-flopJK flip-flopT flip-flop4-bit shift register4-bit ripple carry adderD latch1-to-4 demultiplexer4-bit magnitude comparator4-bit ring counter4-bit Johnson counter4-to-2 priority encoder4-bit synchronous counter3-to-8 decoder8-to-1 multiplexer4-bit carry lookahead adderhalf adder from NAND gates2-bit comparatorBCD to 7-segment decoder4-bit up/down counterdecade counter2-bit multiplier4-bit ALU4-bit array multiplierNOT, AND, OR and NOR from NANDNOT, OR, AND and XOR from NORfull adder from NAND gatesSR latch from NAND gatesparity generator and checker4-bit adder/subtractorBCD adder4-bit universal shift registermod-6 counter4-bit ripple counterbinary to Gray code converterhalf adder from NOR gatesfull adder from NOR gates4-bit register with parallel load1011 sequence detectorbinary to BCD converterD flip-flop from NAND gates1-bit ALUCMOS inverterCMOS NAND gateCMOS NOR gatePISO shift registerSR flip-flop from NAND gatesBCD to excess-3 code converterHamming (7,4) code encoder and correctortraffic light controller4-bit barrel shifterCMOS AND gateCMOS OR gateCMOS XOR gate1-bit magnitude comparatorhalf subtractor from NAND gatesfull subtractor from NAND gates8-to-3 encoderGray to binary converter4-to-16 decoderfull adder using 4:1 multiplexersedge detectorserial adder4-bit carry-select adderMealy machine (1011 detector)master-slave JK flip-flop (NAND)half subtractor from NOR gates1-to-8 demultiplexervending machine FSM4-bit carry-save adder3-bit synchronous counter (JK)CMOS transmission gatetri-state buffer (CMOS)2-to-1 mux from transmission gatesmod-5 counterflip-flop conversion (JK to D)8-bit ALUdecimal to BCD encoderBCD to decimal decoder4-to-1 mux from 2-to-1 muxes

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 excess-3 to BCD code converter in the lab →

Frequently asked

How do you convert excess-3 to BCD?

Subtract 3 (0011) from each 4-bit group. In hardware, a six-gate circuit does it: B0 = NOT E0, B1 = E1 XOR E0, B2 = E2 XNOR (E1 AND E0) and B3 = E3 AND (E2 OR E1 E0).

Why is excess-3 called self-complementing?

Because inverting every bit of a digit's excess-3 code gives the excess-3 code of its 9's complement: 2 is 0101, and its inverse 1010 is the code of 7. That made subtraction easy in decimal machines.

What is 7 in excess-3?

7 + 3 = 10, so 7 is 1010 in excess-3.

Why are don't-cares allowed in the converter?

Six of the sixteen 4-bit codes are never valid excess-3 digits, so whatever the circuit outputs for them never matters, and the K-maps can treat those cells as 0 or 1, whichever gives smaller groups.