Skip to content

Implemented a classic number game in verilog, 24 points. Given 4 numbers from 0 to 9, by adding, subtracting, multiplying and dividing to get 24, there are 10 questions.

Notifications You must be signed in to change notification settings

junneng-my/24points-game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

24points-game

Implemented a classic number game in verilog, 24 points. Given 4 numbers from 0 to 9, by adding, subtracting, multiplying and dividing to get 24, there are 10 questions.
The software use is quartus prime lite 20.1 and modelsim.
The hardware should be DE2i-150 board. Use Cyclone IV GX EP4CGX150DF31C7.

For example, 1,1,1,8, do 1+1=2,then 2+1=3, then 3*8=24.

Table show the question and the solution.
image

Step to play the game

  1. Set st1 to high.
  2. Set the selected switch represent the number(k1/k2/k3/k4 represent the number 1/2/3/4 ) to high to store first value.
  3. Set st2 to high.
  4. Set previous selected (k1/k2/k3/k4) to low.
  5. Set the selected(k1/k2/k3/k4)represent the number to high to store second value.
  6. Set st3 to high.
  7. Set previous selected (k1/k2/k3/k4) to low.
  8. Set one of the (plus/minus/divide/multiply) to high to do calculation.
  9. Set st4 to high.
  10. Set previous selected (plus/minus/divide/multiply) to low.
  11. Set the selected (k1/k2/k3/k4) represent the number to high to store third value.
  12. Set st5 to high.
  13. Set previous selected (k1/k2/k3/k4) to low.
  14. Set selected (plus/minus/divide/multiply) to high to do calculation.
  15. Set st6 high.
  16. Set previous selected (plus/minus/divide/multiply) to low.
  17. Set the selected (k1/k2/k3/k4) represent the number to high to store forth value.
  18. Set st7 to high.
  19. Set the previous selected (k1/k2/k3/k4) to low.
  20. Set the selected (plus/minus/divide/multiply) to high to do calculation.
  21. Set all (plus,minus,divide,multiply), (k1,k2,k3,k4),(st1,st2,st3,st4,st5,st6,st7) to zero, then repeat from step 1 to 20 to answer next question.
  22. After solve all 10 questions or press wrong can set reset to high to reset the game.

Example step to solve questions 1

  1. Set st1 to high.
  2. Set k4 to high.
  3. Set st2 to high.
  4. Set k4 to low.
  5. Set k3 to high.
  6. Set st3 to high.
  7. Set k3 to low.
  8. Set add to high.
  9. Set st4 to high.
  10. Set add to low.
  11. Set k2 to high.
  12. Set st5 to high.
  13. Set k2 to low.
  14. Set add to high.
  15. Set st6 high.
  16. Set add to low.
  17. Set k1 to high.
  18. Set st7 to high.
  19. set k1 to low.
  20. Set multiply to high The given 4 number should shown on the seven segment display start from right to left. The result of the calculation will show on the hex4 for first digit and hex5 for second digit. If the game is at the first question the led 0 will light up. If the game finish first question going to question 2 the led 0 and led 1 light up together. So if game complete until questions 10, led 0 until led 9 will all light up.

Here is the testbench result game_tb1 the y_5 shown is tens digit, and y_4 is digits, it shown in seven segment value which is 24. The questions at the end change to 1126.
image

pin planner
game_pin_planner1 game_pin_planner2
variable function explanation
image
image
image

Future Improvement

  1. use top down design to separate different function to submodule for easy debug and test the code.
  2. use simple cpu design to run this game.

About

Implemented a classic number game in verilog, 24 points. Given 4 numbers from 0 to 9, by adding, subtracting, multiplying and dividing to get 24, there are 10 questions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published