๐ XOR Gate
| A | B | A โ B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
- XOR outputs 1 only when inputs differ between 2-inputs
- Acts as a bitwise difference detector
Conditional Inverter
A โ 0โ preserves AA โ 1โ inverts A
This makes XOR ideal for circuits where inversion is controlled by a single flag, like Add/Sub.
Parity Checker
- XOR of all bits in a word โ 1 if odd number of 1s
- Used in error detection and parity generation
Bit Masking
- Toggle specific bits using XOR with a mask
- Example:
value โ 0xFFโ bitwise inversion
๐ง Application: Add/Subtract Circuit
| Component | Role in Addition | Role in Subtraction |
|---|---|---|
| XOR gates | Pass-through Y | Invert Y |
| Carry-in | 0 | 1 (adds the +1) |
| Full adders | Add X and Y' | Add X and $ \overline{Y} + 1 $ |
- XOR gates conditionally invert Y based on
Add/Sub - Carry-in completes the twoโs complement transformation
๐ง Motivation Summary
- XOR is not just a logic gateโitโs a semantic switch
- Enables minimal, elegant control logic without branching
- Perfect for arithmetic, masking, toggling, and parity
Last updated on