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.