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

4-Bit 2's Complement Adder/Subtractor

HardLogic CircuitBuild

Arithmetic logic units compute both addition and subtraction using the same datapath to save silicon area. A unified adder/subtractor block conditionally negates one operand and leverages the carry-in bit to complete a two's complement conversion in a single pass.

The circuit computes A + B when mode is 0, and A - B when mode is 1. The operation uses two's complement arithmetic to perform the subtraction.

| mode | Operation | S | Cout | |--------|-----------|-----|--------| | 0 | Add | A + B | Carry from MSB | | 1 | Subtract | A - B | Carry from MSB |

Constraints

  • Combinational logic only.
  • Use exactly one 4-bit adder structure.
  • Do not instantiate separate dedicated adder and subtractor blocks multiplexed together.
  • Derive the subtraction using two's complement arithmetic on the B input.

Topics

arithmeticalutwos-complement

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