Q- Implement the 4-bit ADDER and SUBTRACTOR in a single circuit where we select one of the two using a select pin SEL.
Ans: The following circuit would work as required: In this circuit we use property of XOR gate by which XOR gate acts as a inverter when we have one input as 1.
When sel = 0 we get B1B2B3B4 un-complimented through XOR gate and also we have carry to circuit as 0 hence we get the result as sum of A and B
Y = A + B
When sel = 0 we get B1B2B3B4 complimented through XOR gate (as one input of XOR gate is 1) and also we have carry to circuit as 1 hence we get the result as difference of A and B
Y = A – B