Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CSE 320 Design and Synthesis of Digital Hardware

Fall 22

Final Project - Dice Game

This assignment is to design a digital system that will play a game of dice. Rules for the game are described below. Please read this document and make sure you understand rules and specifica<ons.

A player rolls two dice. Roll of the dice can be simulated using counters. You can use two   counters   coun<ng   from   1   to   6.   Each   counter   counts   in   the   sequence 1,2,3,4,5,6,1,… (simula<ng each side of dice).  Here are the rules of the game:

Rules:

1.   On the rst roll of dice, player wins if the sum is 7 or 11. The player loses if the sum is 2, 3 or 12. Otherwise, the sum determines the number of subsequent chances the player will get to play the game.  We refer to this value as Trials.

2.   On the second and subsequent  rolls of the dice, the  player wins  if the sum equals the points from the previous roll of the dice and loses if the sum equals

7 or the number of trails exceeds Trials.

Task 1

Construct a nite state  machine (FSM) for the dice game controller. The  FSM takes Roll_BuXon1,  Roll_BuXon2,  Roll_Counter1,  Roll_Counter2  and  reset  as  inputs.  It produces Diceout1, Diceout2 and result as outputs.

 

A[er rolling dice, the sum is tested. When Roll_BuXon1 is pushed, the FSM takes the current value of  Roll_Counter1 and outputs  it as  Diceout1. When  Roll_BuXon2  is  pushed, the  FSM takes the current value of Roll_Counter2 and outputs it as Diceout2. The sum is calculated as (Diceout1 + Diceout2). In the rst chance, if sum is 7 or 11, the player wins and if it is 2, 3 or 12 the player

loses. Otherwise, player gets number of chances equal to the sum obtained in the rst try              to

roll dice again. On the second or subsequent roll of dice, the player wins if the sum equals the points from the previous dice roll and loses if the sum is equal to 7 or chances gets over.

The basic FSM for dice roll to get sum is given below.

Task 2

You need to implement your FSM into Verilog. Demonstrate that your algorithm works by simula<on.

Task 3

In this part of assignment, you need to design and implement system shown in gure below using mixed Behavioral/RTL Verilog. This mixed level Verilog would be a structural descrip<on at the       block level, with the behavior of each block given as an algorithm. The gure below shows the      block diagram of system you need to implement.

 

Dice Game: It is the controller that you implemented in task 2.

Dice 1 Count/Dice 2 Count: This is a counter module which simulates the roll of dice. As explained earlier, the counter counts from 1 to 6 and restarts. The sequence of the counter is 1, 2, 3, 4, 5, 6, 1, 2, .... The counter takes clock and reset as input and gives the counter value as output. The module defini<on for counter is as follows.

Module Counter(

input CLK, RST,

output [0:2] Roll_Counter1 );

Seven Segment Interface: You need to output value of both dice i.e. DICE_OUT1 and DICE_OUT2 on seven segment display. You also need to show !WIN” if player wins, !LOSE” if player loses and !ROLL” asking player to roll dice. There are eight seven segment digits on Nexys 4 DDR board. You need to use six seven segment digits for this assignment. Use four seven segment digits to show !LOSE”,  !WIN”  or  !ROLL”.  Use  two  seven  segment  digits  to  show  value  of  DICE_OUT1  and DICE_OUT2.  Read  sec<on  !10.1  Seven-Segment  Display”  of  Nexys  4  DDR  reference  manual to understand the func<oning of seven-segment display and build a Verilog module to interface your Dice game with seven segment LEDs on FPGA.

You need to implement your whole design on FPGA. The constraints for inputs and outputs are given as follow.

 

What to Turn in for Grading

The submission should be done online on Canvas. Compress the submission folder into a zip         archive file named projectDicegame_yourFirstName-yourLastName.zip. Submission folder should contain the following:

1.   Your Finite State Machine (FSM) in PDF format.

2.   The project folder containing your Verilog les and Testbench.