Codiode

Adder Subtractor Mode Control

MediumLogic CircuitBuildFree

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.

Free to solve. A Codiode account keeps your progress.

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.

Part of Arithmetic and ALU Design

Problem 2 of 32 in the Arithmetic and ALU Design track.

Related problems

Browse all problems · Digital logic design practice problems · Learning tracks

Solve this on a laptopSend yourself the link and continue there.