Back to Hub

Interactive Logic Gate Breadboard

Logic gates are fundamental physical building blocks in digital circuits that process binary signals (0 and 1) according to Boolean algebra rules. Combining simple gates like AND, OR, and NOT allows computers to perform arithmetic and execute program decisions.

Challenge:
Add:
Preset:
Tactile Wiring: Click output pin → click input pin to wire. Click any wire to cut/delete it. Drag connected input pins to move connections.
Wires: 0

Live Circuit Truth Table

Dynamically evaluates all 2n binary states for your active circuit above. Active row highlights green.
Click any row to test inputs

Bitwise Logic Operations & Bitmasks

While circuit breadboards wire single 1-bit wires, CPUs contain 8-bit registers that process entire bytes simultaneously. Bitwise logic applies Boolean rules (AND, OR, XOR, NOT) to every bit position in parallel. This is how computer systems perform bitmasking, check hardware status flags, route network packets with subnet masks, and perform encryption.

INTERACTIVE STUDIO 8-Bit Parallel Logic & Masking Register

Flip bits in Register A and Register B / Mask, then toggle the operation to see the bitwise result and column-by-column breakdown.

Operation:
Popular Bitmasks:
Register A
Dec: 0 Hex: 0x00
AND (A & Mask)
Register B (Bitmask)
Dec: 0 Hex: 0x00
Result Register
Dec: 0 Hex: 0x00
Bitwise Column Evaluation (Bit 7 → Bit 0) Calculated bit by bit in parallel
PATTERN 1: MASKING & FILTERING Bitwise AND (&)

Clearing Bits with AND

• Truth Rule: 1 AND 1 = 1, while anything AND 0 = 0.
• How Masking Works: To isolate or extract specific bits, place 1s in the mask where you want to keep data, and 0s where you want to erase data.
• Real-World Example (Networking): A Subnet Mask (e.g. 255.255.255.0 / 11111111.11111111.11111111.00000000) is bitwise ANDed with an IP address to instantly separate the Network ID from the Host ID!

Mental Shortcut: X AND 1 = X (preserves bit), but X AND 0 = 0 (clears bit).
PATTERN 2: ENABLING FLAGS Bitwise OR (|)

Setting Bits with OR

• Truth Rule: Anything OR 1 = 1, while X OR 0 = X.
• How Setting Flags Works: To force a specific bit ON without disturbing other bits in the register, bitwise OR with a mask that has a 1 only at that position.
• Real-World Example (OS Permissions): File systems store permissions (Read, Write, Execute) as single bits. Running chmod +w ORs the Write flag bit into the permission register.

Mental Shortcut: X OR 1 = 1 (forces bit ON), while X OR 0 = X (leaves bit unchanged).
PATTERN 3: TOGGLING & CIPHERS Bitwise XOR (^)

Flipping Bits & The XOR Cipher

• Truth Rule: X XOR 1 = NOT X (inverts the bit), while X XOR 0 = X (leaves it alone).
• Symmetric Encryption: If you XOR a secret message with a key: Cipher = Message XOR Key. Applying the exact same key again recovers the original message: Cipher XOR Key = Message!
• Graphics & Game Cursors: Old video game consoles used XOR to draw mouse cursors over pixels without needing to save the background in memory—drawing it a second time perfectly erased it.

Mental Shortcut: A XOR A = 0, and (A XOR B) XOR B = A (self-reversing).
PATTERN 4: ONES' COMPLEMENT Bitwise NOT (~)

Inverting Every Bit (Unary)

• Truth Rule: NOT only takes one input (Unary). Every 0 becomes 1, and every 1 becomes 0.
• Hardware Connection: Bitwise NOT is the exact first step when calculating Two's Complement to store negative numbers in an ALU: -X = (~X) + 1.
• Exam Technique: Ensure you flip every single bit in the full 8-bit register, including all leading zeroes!

Example: ~ (0000 0111) = 1111 1000. Adding 1 gives 1111 1001 (−7).

Bitmask Mastery Missions

Apply the correct operation and bitmask to solve real-world CPU hardware challenges.

0 / 4 Missions Solved ⭐

Boolean Logic Revision & Exam Traps

Essential definitions, gate symbols, truth tables, and past-paper mark scheme rules for Paper 2 (§3.4.3). Master the 4 core AQA gates, order of precedence, and logic notation.

RULE 1: THE 4 CORE AQA GATES Paper 2 §3.4.3

Standard AQA Logic Gate Symbols

• AND Gate: D-shaped symbol. Outputs 1 only when BOTH inputs are 1 (A · B).
• OR Gate: Curved pointed shield. Outputs 1 when AT LEAST ONE input is 1 (A + B).
• NOT Gate: Triangle with an inversion circle/bubble. Inverts the input (¬A or A̅).
• XOR Gate (Exclusive OR): Curved shield with an extra distinct curved input line. Outputs 1 when inputs are DIFFERENT (A ⊕ B).

Symbol Check: Memorize the distinct physical shapes. An AND gate has flat vertical inputs and a semicircle front. An OR gate has a curved indented back and pointed nose.
RULE 2: TRUTH TABLE LAYOUT Paper 2 §3.4.3

The 2n Rule & Binary Sequence

• Row Count: A circuit with n inputs always requires exactly 2n rows.
  • 2 inputs (A, B) → 22 = 4 rows (00, 01, 10, 11).
  • 3 inputs (A, B, C) → 23 = 8 rows (000, 001, 010 ... 111).
• Strict Binary Order: Always list input combinations in ascending binary order (0, 1, 2, 3...) to avoid skipping combinations and losing marks.

Exam Technique: When writing a 3-input table (A, B, C), make A alternate in blocks of 4 (0000 1111), B in blocks of 2 (00 11 00 11), and C alternate every row (0 1 0 1 0 1 0 1).
RULE 3: EXAM TRAPS Paper 2 §3.4.3

OR vs XOR & Bracket Precedence

• The OR vs XOR Trap: When A=1 and B=1, an OR gate outputs 1, but an XOR gate outputs 0! XOR means "one or the other, BUT NOT BOTH".
• Order of Precedence: Just like BIDMAS in maths, evaluate Brackets first, then NOT, then AND, and finally OR / XOR.
• Intermediate Columns: Always create working columns for bracketed sub-expressions to prevent compounding errors.

Warning: The little inversion circle on a NOT, NAND, or NOR gate inverts the signal. Missing or overlooking that tiny circle flips every single bit in your final mark scheme row!
RULE 4: REAL-WORLD CIRCUITS Paper 2 §3.4.3

1-Bit Adders in the CPU ALU

• Half Adder: Takes two 1-bit inputs (A and B).
  • Sum = A XOR B (0+0=0, 1+0=1, 0+1=1, 1+1=0)
  • Carry = A AND B (0+0=0, 1+0=0, 0+1=0, 1+1=1)
• Full Adder: Adds two bits A, B PLUS a carry-in from a previous column (Cin). Constructed from two Half Adders and an OR gate.

Key takeaway: Computers don't have magical addition calculators—they are made from billions of microscopic silicon transistors wired into logic gates just like this.
RULE 5: PAST-PAPER MODEL ANSWER Paper 2 §3.4.3

Past Exam Question • 4 Marks

A security system triggers an alarm (Q) when sensor A is active (1) AND sensor B is inactive (0), OR when sensor C is active (1). Write the Boolean expression and state the output when A=1, B=1, C=0.

View Model Answer & Mark Scheme
• Mark 1: Correct expression: Q = (A AND NOT B) OR C
• Mark 2: Substitute inputs: Q = (1 AND NOT 1) OR 0
• Mark 3: Simplify sub-terms: (1 AND 0) OR 0 → 0 OR 0
• Mark 4: Final evaluation: Q = 0 (Alarm does NOT trigger).