BCD Adder with Dual Correction Conditions
Financial systems, digital clocks, and legacy display drivers rely on Binary-Coded Decimal (BCD) to maintain exact base-10 representations without floating-point rounding errors. A BCD adder computes the sum of two BCD digits and applies a correction factor if the result falls outside the valid 0-9 range.
Add two 4-bit BCD inputs A and B with a 1-bit carry-in Cin. The output S must be the valid 4-bit BCD sum, and Cout must indicate a decimal carry. A correction factor of 6 (0110) must be added to the intermediate binary sum if the initial sum exceeds 9, or if the initial binary addition generated a carry-out.
| A | B | Cin | Cout | S | Notes | |-----|-----|-------|--------|-----|-------| | 4 | 5 | 0 | 0 | 9 | Valid BCD, no correction | | 5 | 5 | 0 | 1 | 0 | Sum is 10. Corrected to 0 with carry | | 8 | 9 | 0 | 1 | 7 | Sum is 17. Binary carry out is 1. Corrected to 7 with carry | | 9 | 9 | 1 | 1 | 9 | Sum is 19. Binary carry out is 1. Corrected to 9 with carry |
Constraints
- Combinational logic only.
- Implement exactly two 4-bit binary adders: one for the initial sum and one for the correction addition.
- Explicitly implement the correction detection logic:
correct = Cout_bin OR (S_bin[3] AND (S_bin[2] OR S_bin[1])). - The final
Coutmust be asserted if the correction condition is met.
Topics
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.
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.