Logism: Add/Subtract 4-bit Oscillation Apparent Problem


I currently have a problem within my circuit design of 4-bit adder that has a function of subtraction in Logisim. My 4-bit adder has an output of 5-bit with maximum of decimal 30 (Because 1111 (15) + 1111(15) = (11110). In my addition process, all went well without any problems.

Below is the image of the adder. 0 means addition in the left-side input.

But after changing the input to 1 so that I can have a subtraction function, an error occurred and it still display 16 in my screen as shown below.

Any help is very much appreciated. Thank you.

Best Answer

Why do you feed the carry out back around to the carry in when you're subtracting? That doesn't seem right, and that's the feedback path that's causing the "oscillation" (which basically means that the simulator can't find a self-consistent output state).

To negate a number, you need to invert all of its bits — which is what I assume the upper-left block is doing — and then add one to it, which is normally done by setting the carry-in of the adder to 1 — unconditionally. There's no reason to have the AND gate or the connection from carry-out.