
This is a purely combinational 8-bit prime number detector. It tests every number from 0 to 255 in hardware using a 256-bit lookup table (one bit per number, pre-computed at synthesis time). The result is available with zero latency — no clock required.
The 7-segment display shows the lower hex nibble of the input number (0–F), and the decimal point lights up when the number is prime. There are 54 primes in the range 0–255, from 2 up to 251.
The entire design uses ~100 logic gates: a 256-bit ROM for the prime lookup and a 16-entry hex decoder for the display.
ui[7:0] to any number using the DIP switches.Try scanning through numbers by flipping switches — you can find all 54 primes between 0 and 255by watching the decimal point.
Some interesting numbers to try:
| Number | Prime? | Notes |
|---|---|---|
| 2 | yes | Smallest prime; only even prime |
| 7 | yes | |
| 9 | no | 3 × 3 — a common mistake |
| 127 | yes | Mersenne prime (2⁷ − 1) |
| 128 | no | 2⁷ |
| 251 | yes | Largest prime ≤ 255 |
| 255 | no | 3 × 5 × 17 |
None required. The 7-segment display is built into the TinyTapeout demo board.
| # | Input | Output | Bidirectional |
|---|---|---|---|
| 0 | Number bit 0 (LSB) | Segment a | |
| 1 | Number bit 1 | Segment b | |
| 2 | Number bit 2 | Segment c | |
| 3 | Number bit 3 | Segment d | |
| 4 | Number bit 4 | Segment e | |
| 5 | Number bit 5 | Segment f | |
| 6 | Number bit 6 | Segment g | |
| 7 | Number bit 7 (MSB) | Decimal point (1 = prime) |