HDLbits
Browse Problems

Verification/Reading Simulations

Find the Bug: Add/Subtract

medium
debuggingarithmetic

Compute a+b when subtract is zero and a-b when it is one, returning a nine-bit result. Use two’s-complement subtraction so borrow behavior is visible in the high bit.