begin
alu_result_v := alu_state;
addcarry := (others => '0');
- addcarry(0):= (alu_state.status.carry and addc) or sub;
+ addcarry(0):= (alu_state.status.carry and addc) or (sub and not(addc));
if sub = '1' then
carry_res := unsigned('0' & left_operand)+unsigned('0' & not(right_operand))+addcarry;
else