Half Adder

A half adder. Takes two inputs, i_a and i_b, and adds them together to generate a sum output, o_sum, and a carry bit output, o_carry.

Parameters

  • None

Ports

  • i_a input a

  • i_b input b

  • o_sum output sum

  • o_carry output carry

Source Code

half_adder.sv
 1`ifndef LIBSV_MATH_HALF_ADDER
 2`define LIBSV_MATH_HALF_ADDER
 3
 4module half_adder (
 5    input  logic i_a,
 6    input  logic i_b,
 7    output logic o_sum,
 8    output logic o_carry
 9);
10
11    assign o_sum   = i_a ^ i_b;
12    assign o_carry = i_a & i_b;
13
14endmodule
15
16`endif  /* LIBSV_MATH_HALF_ADDER */