4-bit adder/subtractor X42916


Statement
 

pdf   zip

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).

Information
Author
Jordi Cortadella
Language
English
Official solutions
Verilog
User solutions
Verilog