Digital Lock Security System
Advanced security system using NOT and AND gates. Specific combination required to unlock. Demonstrates complex boolean logic implementation.
学べること
- Compare two multi-bit buses using per-bit XNOR.
- AND-reduce per-bit matches for an all-bits-equal signal.
- Recognise XNOR's role as the single-bit equality detector.
- Apply the XNOR-AND pattern in cache tags, address decoding, and locks.
- Understand why pure XNOR matching is insufficient for cryptographic security.
仕組み
A digital lock verifies a multi-bit password against a stored value and unlocks only when every bit matches. The circuit uses per-bit XNOR comparison (XOR followed by NOT, or a direct XNOR gate) plus an AND-reduce: every bit must match for the unlock signal to fire.
For a 4-bit password, four XNORs compare each input bit to its expected value. The AND of all four XNORs is high only when every comparison reports "match." This is the same pattern as a bus equality comparator — but with one of the buses being the stored password (typically wired as constants).
More advanced locks add features: an enable input that gates the unlock (locked mode vs. armed mode), a mismatch counter that triggers a lockout after N failed attempts, or a timeout that re-locks after a delay. The core matching logic stays the same — XNOR per bit, AND across all bits.
Real electronic locks add cryptographic protection (challenge-response, signed tokens) so an attacker can't simply read the wires. Pure XNOR matching is suitable for educational and low-security applications.
真理値表
Stored password is fixed at 1010 (= 10 decimal). Lock fires only when input bits exactly match.
| 入力 | 出力 | ||||
|---|---|---|---|---|---|
| I3 | I2 | I1 | I0 | Unlock | |
| 0 | 0 | 0 | 0 | 0 | Wrong password |
| 1 | 0 | 1 | 0 | 1 | Match — unlock |
| 1 | 0 | 1 | 1 | 0 | One bit wrong (LSB) — locked |
| 0 | 1 | 0 | 1 | 0 | Inverted password — locked (max mismatch) |
| 1 | 1 | 1 | 0 | 0 | One bit wrong (bit 2) — locked |
ブール式
Per-bit XNOR with the stored password bit Pi.
AND-reduce across all per-bit matches. Single mismatch sinks the unlock.
順を追って試す
上の埋め込み回路で入力を設定し、期待される結果と一致するか確認しましょう。
- 1I = 0000期待値:
Unlock = 0観察ポイント: All zeros doesn't match the stored password (1010). Lock stays closed. - 2I = 1010期待値:
Unlock = 1観察ポイント: All four bits match — the unlock light turns on. The single permitted combination of 16. - 3I = 1011期待値:
Unlock = 0観察ポイント: One bit off (LSB). The XNOR for bit 0 reports mismatch; the AND drops to 0; lock stays closed. - 4I = 0101期待値:
Unlock = 0観察ポイント: Inverted from the password (every bit wrong). Maximum mismatch. Unlock stays low.
使用コンポーネント
実世界での応用
Combination lock keypads. A user enters a code; per-digit XNOR comparators verify each digit against the stored combination.
Address decoders. Memory-mapped peripherals respond when their address bus matches a hardcoded base — implemented as XNOR-AND comparators.
Password verification in microcontrollers. A bootloader reads an EEPROM password and compares it against user input via the same XNOR-AND pattern.
Cache tag matching. Cache lookups compare the address tag against stored tags; a match (all-XNORs-high) means cache hit.
State-machine condition matching. A FSM transitions when the input pattern matches a stored expected pattern — same XNOR-AND verifier.