The topic
Sequential logic locking hides the correct behavior in the state machine. The key is applied one byte per clock. A wrong byte sends the UART transmitter into a locked state that it can leave only by reset.
Where it belongs
Course: Digital logic.
Teach this after: finite-state machines and the UART frame. Students should already be able to simulate a state machine. This lab does not need the adder labs. It is written and has not been graded yet.
Files and how to use them
There is no slide deck. The manual is the assignment. Students simulate the transmitter first, then add the lock.
- Lab manual. The frame figure, the report checklist, and the discussion questions. Use it as the in-class handout. It states the verification sequence the testbench has to cover.
- UART.vhdl. A working transmitter. Idle, start bit, data bits, and stop bit are already there.
- UART_tb.vhdl. The testbench starter. Students extend it for the correct sequence and a wrong value in each position.
Video lectures
These are links, not files stored with the module. Play one in class, or send the link to students.
Further reading
Optional papers for the instructor, or for a student who wants to read past the assignment.
- Chakraborty and Bhunia, “HARPOON: An Obfuscation-Based SoC Design Methodology for Hardware Protection,” IEEE Transactions on Computer-Aided Design, vol. 28, no. 10, pp. 1493–1502, 2009. Sequential obfuscation by adding states. This lab is the UART-sized version of that idea.
- Hoque, Chakraborty, and Bhunia, “Hardware Obfuscation and Logic Locking: A Tutorial Introduction,” IEEE Design & Test, vol. 37, no. 3, pp. 59–77, 2020. The tutorial this lab was adapted from. The PDF is not redistributed here.
The exercise
The starter is a working UART transmitter. Its state machine has idle, start bit, data bits, and stop bit. The line idles high, the start bit pulls it low, eight data bits leave least-significant bit first, and a stop bit returns the line high. There is no parity bit in this lab. Students simulate that machine first. They then add a lock in front of it.
Outcome
The correct sequence walks three key states and enters idle, and the transmitter runs. Any wrong value enters a locked state that holds the transmit line high and has no exit except reset. The student explains why a key applied over several clocks is different from the single combinational key in the adder lab, and why the locked state has no outgoing transition except reset.
Part I. The unlocked transmitter
Identify the states, simulate with the provided testbench, and produce a timing diagram of tx_start, tx, state_track, and data_in. Be able to answer why idle is high, why start is low, the order of the data bits, and what makes the machine leave idle.
Part II. The lock
Add three key states, S0, S1, and S2, and a LOCKED state. Reset now lands in the first key state, not in idle. Three 8-bit key values must arrive one per clock while key_valid is high, and the comparison runs only then. The manual is explicit that without key_valid the machine would compare on every clock and could lock itself when nobody is entering a key. A wrong value at any position goes to LOCKED and stays there until reset. The original transmitter is reachable only after the sequence succeeds.
The verification sequence specified in the student manual is AA, then BB, then CC. The testbench has to cover that sequence and a wrong value in each of the three positions.
- Correct sequence: S0, S1, S2, idle, and a normal frame follows.
- Wrong first key: S0, then locked.
- Wrong second key: S0, S1, then locked.
- Wrong third key: S0, S1, S2, then locked.
Waveforms show key_valid, key_seq, state_track, data_in, and tx_start. The starter leaves commented task markers where the states, the key constants, the new ports, and the testbench changes belong. BAUD_DIV is 868 in the starter, which is the divider the supplied transmitter already uses.



