Loading simulator…
The predefined circuit already contains the 4-bit FullAdder, B-conditioning XOR gates, and status-logic gates. Complete the missing connections as follows.
Connect the same SUB signal to all four B-conditioning XOR gates and to the FullAdder carry input Ci.
BX0 = B0 XOR SUB
BX1 = B1 XOR SUB
BX2 = B2 XOR SUB
BX3 = B3 XOR SUB
Ci = SUB
This makes the same datapath perform both operations:
SUB = 0 → BX = B, Ci = 0 → S = A + B
SUB = 1 → BX = NOT B, Ci = 1 → S = A + NOT(B) + 1 = A - B
Connect the FullAdder carry-out Co and SUB to the CB XOR gate.
CB = Co XOR SUB
Therefore:
SUB = 0 → CB = Co → carry-out
SUB = 1 → CB = NOT(Co) → unsigned borrow
Use the sign bits A3, BX3, and S3.
Overflow = NOT(A3 XOR BX3) AND (A3 XOR S3)
A3 XOR BX3 checks whether the two effective operands have different signs.
After inversion, it becomes 1 when their signs are the same.A3 XOR S3 becomes 1 when the result sign differs from A.
Overflow is asserted only when both conditions are true.
Connect the result MSB directly to Negative.
Negative = S3
A 4-bit two's-complement result is negative whenever its MSB is 1.
Connect all four result bits to the supplied OR network and invert the final OR result.
Zero = NOT(S0 OR S1 OR S2 OR S3)
Thus Zero = 1 only when:
S[3:0] = 0000
The completed circuit now performs 4-bit addition/subtraction and produces CB, Overflow, Zero, and Negative from the same shared arithmetic datapath.