SIMPLIFIED BLOCK DIAGRAM

4-Bit Add/Sub with Automatic 2's Complement
CIRCUIT ARCHITECTURE A[3:0] B[3:0] SA SB STAGE 1 XOR GATES A' = A XOR SA B' = B XOR SB Cin = SA OR SB (Conditional Inversion) STAGE 2 4-BIT ADDER Sum1 = A' + B' + Cin (Main Addition with +1 for single 2's comp) A', B', Cin STAGE 3 4-BIT ADDER Final = Sum1 + 0 + (SA∧SB) (Adds +1 only when both SA and SB are 1) Sum1 SA AND SB Result[3:0] Inverts bits when SA or SB = 1 Adds +1 when SA OR SB = 1 Adds +1 when SA AND SB = 1

HOW IT WORKS - SIMPLE EXPLANATION

🔹 STAGE 1: Prepare the numbers

XOR gates either pass the number through (when control = 0) or invert all bits (when control = 1)

This is the FIRST STEP of 2's complement: invert the bits

🔹 STAGE 2: Add with +1 if needed

The first adder adds the two prepared numbers

The carry input is set to 1 when either SA or SB is 1

This is the SECOND STEP of 2's complement: add 1

This works perfectly for scenarios 1, 2, and 3!

🔹 STAGE 3: Fix scenario 4

When BOTH SA and SB are 1, we need TWO 2's complements

Stage 2 only added +1, so we're SHORT by 1

The second adder adds that missing +1 only when (SA AND SB) = 1

For other scenarios, it just passes the result through (adds +0)

KEY INSIGHT: Second Adder = Result + 0000 + (SA AND SB)
• When SA AND SB = 0: adds nothing (pass through)
• When SA AND SB = 1: adds +1 (fixes scenario 4)

OPERATION TRUTH TABLE

SA SB Operation Stage 1 Output Stage 2 Output Stage 3 Adds Final Result
0 0 X + Y A, B A + B + 0 +0 X + Y ✓
0 1 X - Y A, NOT B A + (NOT B) + 1 +0 X - Y ✓
1 0 -X + Y NOT A, B (NOT A) + B + 1 +0 -X + Y ✓
1 1 -X - Y NOT A, NOT B (NOT A) + (NOT B) + 1 +1 -X - Y ✓

WHY THIS IS BETTER THAN A MUX

A multiplexer (MUX) is like a switch that selects between two inputs. You haven't learned about it yet, so we use what you already know: adders!

By feeding 0000 to one input of the second adder, we effectively get:

Second Adder Output = First Input + 0 + Carry In

This is just adding 0 or 1 based on the carry in, which is exactly what we need.

Same result, simpler components!