FPGA digital lock
A password-protected digital lock built on an Intel DE10-Standard FPGA board. You enter a code with the board's switches and push buttons, and LEDs show whether the lock is locked or unlocked. I chose this as my ECE 1100 Discovery Project to learn FPGA programming, digital logic, and finite-state machine design by building something I could hold and test.
The problem
Locks are everywhere: doors, safes, lockers, and the access panels on buildings. Most electronic locks run on a microcontroller, where software reads the keypad and decides what to do. I wanted to understand how the same behavior can be built directly in hardware, with no processor and no program running line by line. An FPGA lets me describe the lock as digital logic, so every input is checked by circuits that react on each clock cycle. The question I set out to answer was simple: can I design a lock whose entire behavior lives in a finite-state machine, and make it reliable enough to trust?
The process
I started by drawing the lock as a state diagram before writing any code. Each state stands for how much of the code has been entered correctly so far. A correct input moves the machine forward one state, a wrong input sends it back to the start, and reaching the final state unlocks the lock. A reset button returns everything to the locked state at any time.
Next I wrote the design in SystemVerilog in Intel Quartus Prime. I split it into sequential logic, which stores the current state on each clock edge, and combinational logic, which decides the next state from the current state and the inputs. I mapped the inputs and outputs to the board: the switches and push buttons for entering the code and resetting, and the LEDs for showing locked or unlocked.
To check the design, I simulated it before loading it onto the board. I tested the correct code, wrong codes, a wrong entry partway through a correct sequence, and resets in the middle of entry. After simulation, I programmed the FPGA and repeated the same tests by hand on the real hardware.
The outcome
The project is still in progress. So far I have a working state diagram, a SystemVerilog design, and tests for valid and invalid code sequences and for reset behavior, both in simulation and on the board. The biggest lesson has been how much planning matters in hardware: once the state diagram was right, the code followed from it, and most of my bugs came from cases I had not drawn yet. Next, I plan to make the code changeable instead of fixed, add a lockout after too many wrong attempts, and record a demo video of the lock running on the board for the Discovery Project Showcase.
Photos and a demo video of the lock running on the board are coming soon.