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

Output

Problem information

Author: Jordi Cortadella

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

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