module: adder2_full_uint
description: 
timing_sensitivity: 
parameters:  int n
inputs:  int in1, int in2
outputs:  int sum, int carry
classes:  
static_variables:  int max_val, int mask_val, int max_out_val
init:  
sum = 0;
carry = 0;
if (n < 1)
   {
    printf("error in 'adder2_full_uint':  n must be >= 1\n");
    printf("  -> in this case, n = %d\n", n);
    exit(1);
   }
else if (n > 30)
   {
    printf("error in 'adder2_full_uint':  n must be <= 30\n");
    printf("  -> in this case, n = %d\n", n);
    exit(1);
   }
max_val = (1<<(n+1))-1;
max_out_val = (1<<n)-1;
mask_val = (1<<n);

code:
long long sum_temp;


if (in1 < 0)
   {
    printf("error in 'adder2_full_uint':  in1 must be >= 0\n");
    printf("  -> in this case, in1 = %d\n", in1);
    exit(1);
   }
if (in2 < 0)
   {
    printf("error in 'adder2_full_uint':  in2 must be >= 0\n");
    printf("  -> in this case, in2 = %d\n", in2);
    exit(1);
   }
if (in1 > max_val)
   {
    printf("error in 'adder2_full_uint':  in1 must be <= max_val\n");
    printf("  -> in this case, in1 = %d\n", in1);
    printf("     max_val = %d\n",max_val);
    exit(1);
   }
if (in2 > max_val)
   {
    printf("error in 'adder2_full_uint':  in2 must be <= max_val\n");
    printf("  -> in this case, in2 = %d\n", in2);
    printf("     max_val = %d\n",max_val);
    exit(1);
   }

sum_temp = in1 + in2;
if (sum_temp > max_val)
   {
    printf("error in 'adder2_full_uint':  in1+in2 must be <= max_val\n");
    printf("  -> in this case, in1 = %d\n", in1);
    printf("                   in2 = %d\n", in2);
    printf("     max_val = %d\n",max_val);
    exit(1);
   }

sum = in1 + in2;
carry = (sum & mask_val) == 0 ? 0 : 1;
sum = sum & max_out_val;
