A Dice Game on a CPLD

.

front  front2

front3

A dice game was implemented on a development board designed for the XC9572 CPLD. This board was designed by our mentor Asst. Prof. D.V Gadre along with our college senior Ayan Roy. The dice game was a problem given by Asst. Prof. Gadre to his class to emphasise on the concept of Algorithmic State Machines.

In designing this game, our aim was to divide this digital design problem into the control path and the data path. The data flow path provides inputs to the control flow path i.e. the state machine.

 

control path 

The game starts in the ‘reset’ state, where it waits for a switch input. On a switch press, the counters are enabled. Two counters simulate the throw of a dice. One counter runs at clk (1 KHz) and the second one runs at clk/6. On releasing this switch, the data flow path checks the sum of the two dice. If the sum equals 3, 5, or 7 the player wins. If it equals 2, 4, or 6 the player loses. In all other cases, the player goes to stage two. On reaching stage two, the game waits for another throw of the dice. If the new throw equals the previous throw, the player wins, otherwise the player loses. The data flow path is shown in the following figure:   
data path
Fig: The data flow path of the game of dice.

You can also view the VHDL code here.