Home › Practice › RTL Design › One circuit, two jobs

One circuit, two jobs

EasyRTLcombinationalarithmetic

A calculator chip has room for only one adder. You have to make that one adder able to subtract too.

Concept first. Subtracting b is the same as adding the opposite of b. In the previous problem you saw that the opposite of a two's-complement number is "flip every bit, then add one". So a - b can be computed with the same adder, if you can flip the bits of b only when subtracting, and sneak in one extra +1. Look for a gate that passes a bit through unchanged for one control value and inverts it for the other, and look for a free place in an adder where a +1 can go in.

What to build.

Solve in your browser →

No install and no sign-up needed. You write your answer in the editor and Nishkam checks it.

More in this track

← Flip and add oneA dial that changes one bit at a time →