4-bit adder/subtractor

Design a circuit that performs the addition or subtraction of two 4-bit
numbers. The result (mod 16) must be represented in 4 bits also. The
circuit has an input (op) that indicates which operation must be
performed (0 for addition, 1 for subtraction).

Specification

    module add_sub4(a, b, op, result);
        input [3:0] a, b;
        input op;
        output [3:0] result;

Input

- a and b are the two 4-bit operands.

- op indicates the type of operation (0 for addition, 1 for
  subtraction).

Output

- result is the 4-bit result of the operation (mod 16).

Problem information

Author: Jordi Cortadella

Generation: 2026-02-03T12:11:48.387Z

© Jutge.org, 2006–2026.
https://jutge.org
