
Vaccines lose potency faster as they warm up. The reaction rate behind that degradation grows exponentially with temperature (Arrhenius law: rate is proportional to exp(-Ea/RT)), so heat damage adds up over time. This chip keeps a running total of that damage, like the heat-sensitive monitors on vaccine vials, and shows green, yellow or red.
The circuit is drawn in Wokwi with basic logic gates, flip-flops and multiplexers (no code): https://wokwi.com/projects/480322745306619905
Inputs and outputs
| Pin | Function |
|---|---|
ui_in[2:0] |
temperature code (0-7) |
ui_in[4:3] |
discard limit: 128, 256, 512 or 1000 |
ui_in[5] |
test mode: 1 = one step per clock, 0 = one step per 60 clocks (one minute at 1 Hz) |
ui_in[7] |
display mode: 0 = traffic light, 1 = the 7-segment display shows the letter of the block the vial is in |
rst_n |
new vial: clears the total |
uo_out[0] |
green (safe) |
uo_out[1] |
yellow (warning) |
uo_out[2] |
red (discard) |
uo_out[3] |
buzzer |
In display mode (ui_in[7] = 1), uo_out[6:0] become the segments a to g of a 7-segment display and uo_out[7] its dot (lit when red). With ui_in[7] = 0 the pins work as listed above and uo_out[7:4] stay 0.
Damage table. Logic gates decode the temperature code into the damage per step. The damage roughly doubles with each warmer bin.
| Code | Temperature | Damage per step |
|---|---|---|
| 0 | below 2 °C | 0 |
| 1 | 2-8 °C | 0 |
| 2 | 8-15 °C | 1 |
| 3 | 15-20 °C | 2 |
| 4 | 20-25 °C | 4 |
| 5 | 25-30 °C | 8 |
| 6 | 30-37 °C | 16 |
| 7 | above 37 °C | 32 |
Blocks
Tick generator: 6 flip-flops form a divide-by-60 counter that turns a 1 Hz clock into one step per minute. In test mode (ui_in[5] = 1) an OR gate bypasses it, so every clock is a step.
Damage decoder: AND and NOT gates turn the temperature code into the damage (1, 2, 4, 8, 16 or 32), and only let it through on a tick while the vial is not red.
Accumulator: 11 flip-flops hold the running total. A chain of XOR, AND and OR gates adds the damage on each tick (a ripple-carry adder that starts at the bit chosen by the temperature).
Comparators and limit mux: OR and AND gates compare the total with the thresholds. The limit pins ui_in[4:3] drive two 4-to-1 multiplexers (each built from three 2-to-1 muxes) that pick the discard threshold (128, 256, 512 or 1000) and the warning threshold (half of it).
Alarm: a flip-flop latches the discard state, and the accumulator stops once it is set, so cooling the vial can't undo it. Gates then light one LED: red = latch, yellow = warning AND NOT red, green = NOT (warning OR red). The buzzer follows red.
Display block: OR, AND and NOT gates work out which block the vial is in, and four 2-to-1 muxes controlled by ui_in[7] switch the output pins between the traffic light and the segments of the letter.
Display mode letters. The letter says how far the vial has gone through the blocks above. The dot is lit when the vial is red.
| Letter | Block | Meaning |
|---|---|---|
| A | tick generator | only the clock runs: the temperature is below 2 °C and no damage is stored |
| b | damage decoder | the temperature is damaging (code 2-7) but nothing is stored yet |
| C | accumulator | damage is stored, still below the warning level |
| d | comparators | warning or discard (dot = red) |
In total there are 18 flip-flops (6 + 11 + 1), 10 two-way multiplexers and 106 logic gates. The weights and limits are example values. Real ones come from the vaccine maker's stability data.
You can run the same tests in simulation or on the demo board.
Demo board
ui_in[5] = 1 (test mode) and ui_in[4:3] = 00 (limit 128). Put the temperature code on ui_in[2:0] for each row below, and reset before each row.Simulation
Open the Wokwi project (link above) and press the play button. Use the DIP switches for ui_in (switch 8 is the display mode), the RESET button for rst_n, and read the green, yellow, red and buzzer LEDs or the 7-segment display. Set the clock to 10 Hz and turn on switch 6 (ui_in[5], test mode) to follow the table below.
The test folder has a reference model of the traffic light (src/project.v, display mode off) and cocotb tests (make -B in test). They check the rows of the table below and compare every temperature code and limit with a Python model. The gate-level circuit gives the same result clock by clock, and its display mode was checked against the standard 7-segment codes of A, b, C and d.
Display check
Set ui_in[7] = 1. After a reset, a cold vial (code 000) shows A and never changes. With test mode, limit 128 and code 111 the display shows b, C, d, d and then d with the dot (red), one letter per clock. With code 010 it shows b for one clock, C for 63 clocks and then d. Cooling the vial (code 000) keeps C, because the damage is remembered; reset goes back to A.
Expected results
| Code | Clocks after reset | Expected |
|---|---|---|
| 001 | 20 | green only |
| 111 | 2 | yellow |
| 111 | 4 | red + buzzer |
| 101 | 8 / 16 | yellow / red |
| 100 | 16 / 32 | yellow / red |
| 111, then 001 | 4, then 10 more | stays red |
Limit check: with ui_in[4:3] = 01 (limit 256) and code 111, yellow appears after 4 clocks and red after 8.
Real-time check: set ui_in[5] = 0 and the clock to 1 Hz. With code 111, yellow appears after 120 clocks (2 minutes) and red after 240 (4 minutes).
Pass: every row matches, and reset always returns to green only.
Green, yellow and red LEDs (with resistors) on uo_out[0], uo_out[1] and uo_out[2], and a buzzer on uo_out[3]. The demo board's DIP switches supply the temperature code, and its 7-segment display is wired to the eight output pins: with ui_in[7] = 0 segments a to d mirror the traffic light, so you can test before wiring any LEDs, and with ui_in[7] = 1 it shows the block letter. In display mode the LEDs and the buzzer see the segment signals, so switch it off (or unplug them) when the monitor is in use. A real temperature sensor with comparators can replace the switches later.
| # | Input | Output | Bidirectional |
|---|---|---|---|
| 0 | temp_code[0] | green / seg a | |
| 1 | temp_code[1] | yellow / seg b | |
| 2 | temp_code[2] | red / seg c | |
| 3 | limit_sel[0] | buzzer / seg d | |
| 4 | limit_sel[1] | seg e (display mode) | |
| 5 | test_mode | seg f (display mode) | |
| 6 | seg g (display mode) | ||
| 7 | display_mode | dp = red (display mode) |