SDSP Add Procedure


   PROCEDURE add (result : INOUT bit_32;
               op1, op2 : IN INTEGER;
               V, N, Z : OUT BIT) IS
   BEGIN
     IF op2 > 0 and op1 > integer'high-op2 THEN   -- positive overflow
       int_to_bits(((integer'low+op1)+op2)-integer'high-1, result);
       V := '1';
     ELSIF op2 < 0 and op1 < integer'low-op2 THEN -- negative overflow
       int_to_bits(((integer'high+op1)+op2)-integer'low+1, result);
       V := '1';
     ELSE
       int_to_bits(op1 + op2, result);
       V := '0';
     END IF;
     N := result(31);
     Z := bool_to_bit(result = X"0000_0000");
   END add;