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

Adder Subtractor Mode Control

MediumLogic CircuitBuild

Hardware reuse is the foundation of ALU design. Dedicated circuits for addition and subtraction waste silicon when a single adder can perform both operations via two's complement arithmetic.

The mode control circuit receives two 4-bit inputs A and B, and a 1-bit mode selector M. It outputs a 4-bit result S and a 1-bit carry-out Cout.

| M | Operation | S | |-----|-----------|---------| | 0 | Addition | A + B | | 1 | Subtraction | A - B |

Subtraction is achieved by converting B to its two's complement representation: inverting all bits of B and adding 1. The control bit M must orchestrate both the conditional inversion of B and the initial addition of the lowest bit.

Constraints

  • Use exactly one 4-bit adder.
  • Use XOR gates for the conditional inversion of input B.
  • Do not use dedicated subtraction blocks.
  • Connect the mode control bit M directly to the carry-in of the adder.

Topics

ArithmeticALUHardware Reuse

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

  • Half Adder Using Only XOR and ANDEasy
  • Floating Point Exception FlagsMedium
  • 1-Bit ALU SliceMedium
  • 4-bit Carry Lookahead BlockHard
  • BCD Adder Correction BlockMedium
  • IEEE 754 Mantissa Alignment ShifterHard
  • Four-Bit Bus AdderEasy
  • Debugging Twos Complement OverflowMedium

Browse all problems · Learning tracks