Hades logoHades applet banner
Binary Adder/Subtractor (4 bit)

applet icon

The image above shows a thumbnail of the interactive Java applet embedded into this page. Unfortunately, your browser is not Java-aware or Java is disabled in the browser preferences. To start the applet, please enable Java and reload this page. (You might have to restart the browser.)

Circuit Description

A four-bit adder/subtractor demonstration. While it is perfectly possible to design a custom circuit for the subtraction operation, it is much more common to re-use an existing adder and to replace a subtraction by a two-complement's addition.

The applet shows how this is done. Click the input switches or type the 's' bindkey to control the Sub/nAdd switch, and '1' .. '8' to control the A and B inputs.

When the Sub/nAdd input is low (0), the XOR-gates act as non-inverting buffers, and the carry-input to the adder is 0. Therefore, the adder calculates a four-bit sum plus carry-out:

 (Cout,S3,S2,S1,S0) = (A3,A2,A1,A0) + (B3,B2,B1,B0)

If the Sub/nAdd input is high (1), the XOR-gates act as inverting buffers, and the carry-input to the adder is 1.

 (Cout,S3,S2,S1,S0) = (A3,A2,A1,A0) - (B3,B2,B1,B0)

Print version | Run this demo in the Hades editor (via Java WebStart)
Usage | FAQ | About | License | Feedback | Tutorial (PDF) | Referenzkarte (PDF, in German)
Impressum http://tams-www.informatik.uni-hamburg.de/applets/hades/webdemos/20-arithmetic/40-addsub/add-sub.html