Voters press one candidate button (one-hot) and confirm with the confirm button.
Each valid confirm adds a vote to the selected candidate and increments the total vote count.
Modes:
00 → Voting: Store votes only.
01 → Counting: Display the winning candidate (one-hot) + total votes (debug).
10 → Reset: Clear all vote counters.
11 → Test: Show debug vote count only.
Reset: Set mode = 10 to clear all votes.
Vote: Switch to mode = 00, press a candidate button + confirm. Repeat for multiple votes.
Count: Switch to mode = 01, check winner output matches the highest-voted candidate, and debug = total votes % 8.
Test: Switch to mode = 11, ensure only debug output shows.
Reset again: Verify all counters clear back to zero.
Mode (ui_in[7:6] ) |
Action | Winner Output (uo_out[3:0] ) |
Voting Complete (uo_out[4] ) |
Debug (uo_out[7:5] ) |
---|---|---|---|---|
00 (Voting) |
Store votes | 0000 |
0 |
Total votes % 8 |
01 (Counting) |
Show result | One-hot winner | 1 |
Total votes % 8 |
10 (Reset) |
Clear all | 0000 |
0 |
000 |
11 (Test) |
Debug only | 0000 |
0 |
Total votes % 8 |
None
# | Input | Output | Bidirectional |
---|---|---|---|
0 | voter | winner | |
1 | voter | winner | |
2 | voter | winner | |
3 | voter | winner | |
4 | confirm | voting_complete | |
5 | rst | debug | |
6 | mode | debug | |
7 | mode | debug |