CodiodeCodiode
Home
Problem Solving
Skill Tracks
My Assignments
Contests
Leaderboard
Community
Settings
Codiode/Problems/Combinational Logic

BCD Validity Checker (Flag Codes 10–15 as Invalid)

MediumLogic CircuitBuild

Binary-Coded Decimal (BCD) uses 4 bits to represent decimal digits 0 through 9. The codes 1010 through 1111 (10 through 15 in decimal) are invalid BCD — they have no valid decimal digit interpretation. In BCD arithmetic circuits and display decoders (such as 7-segment drivers), detecting and flagging these invalid codes is essential for correct operation. This problem tests your ability to derive a minimal sum-of-products expression for the invalid-code detector.

Your task is to implement a BCD validity checker. Given a 4-bit input D = {D3, D2, D1, D0} (D3 is MSB), output INVALID = 1 when the input represents a decimal value 10 through 15, and INVALID = 0 for values 0 through 9.

The invalid codes are: 1010, 1011, 1100, 1101, 1110, 1111. All share the property that D3=1 and at least one of D2 or D1 is 1. The minimal SOP from a Karnaugh map is INVALID = D3 AND D2 + D3 AND D1, which simplifies to INVALID = D3 AND (D2 OR D1).

Worked examples: D=1010 (10): D3=1, D2=0, D1=1 → INVALID=1. D=1001 (9): D3=1, D2=0, D1=0 → INVALID=0 (9 is valid BCD). D=1100 (12): D3=1, D2=1 → INVALID=1. D=0111 (7): D3=0 → INVALID=0.

| Signal | Direction | Width | Description | |--------|-----------|-------|-------------| | D3 | input | 1 | MSB of the 4-bit BCD digit | | D2 | input | 1 | Bit 2 of the digit | | D1 | input | 1 | Bit 1 of the digit | | D0 | input | 1 | LSB of the digit (does not affect validity) | | INVALID| output | 1 | 1 when input is not a valid BCD digit (10–15) |

Constraints

  • The circuit is purely combinational. No clock or state.
  • D0 does not affect the output — both 1000 (8) and 1001 (9) are valid BCD. Connecting D0 to any logic is unnecessary.
  • The optimal solution uses 4 components: 1 OR (D2 OR D1), 1 AND (D3 AND that result). That is 2 gates. However to also correctly handle that D3·D2 and D3·D1 cover the cases, you may implement as 2 AND + 1 OR = 3 gates, or factor to 1 OR + 1 AND = 2 gates.
  • All 16 input combinations are valid test inputs. For inputs 0–9, INVALID must be 0. For inputs 10–15, INVALID must be 1.

Topics

combinationalbcdvaliditykmapsop

Solve this problem

Place the gates, wire them up and watch the signals settle. Every submission runs on the same simulation engine that grades it.

This problem is part of Codiode Pro. The statement above is free to read.

Sign in to solveSee what Pro unlocks

The circuit builder and code editor need a desktop screen. On a phone, read the problem here and open it on a laptop to solve.

Related problems

  • Binary to HexEasy
  • 1-to-4 Demultiplexer from AND and NOT GatesEasy
  • 2-to-4 Line Decoder with Active-High EnableEasy
  • Hex Nibble to BinaryEasy
  • Odd Parity Bit Generator for 3-bit DataEasy
  • Full Adder from Half AddersEasy
  • Modulo ArithmeticMedium
  • Two's Complement: Encode a Negative DecimalEasy

Browse all problems · Learning tracks