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.