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).
module add_sub4(a, b, op, result);
input [3:0] a, b;
input op;
output [3:0] result;a and b are the two 4-bit
operands.
op indicates the type of operation (0 for addition,
1 for subtraction).
result is the 4-bit result of the operation (mod
16).
Author: Jordi Cortadella
Generation: 2026-02-03T12:11:48.387Z
© Jutge.org, 2006–2026.
https://jutge.org