I'm working on a programming project and need an explanation and answer to help me learn.
design and implement a simple game on NEXYS 4 DDR FPGA boards. The Boards include eight 7-segments, 16 Switches, 16 Leds, and (5+2) push buttons as below. (CPU RESET and PROG are also push buttons)
Description: In this game you play the role of a police to arrest a thief. Police's and the thief's locations are shown with (XP,YP) and (Xt,Yt) coordinates, where all indexes are in range of [0,15] (inclusive).
First you need to initialize the coordinate of police and thief. The thief's location should be entered via the 8 switches (SW[15:8]) and police's location is entered by other 8 switches (SW[7:0]).
SW[15:12] ==> Xt
SW[11:8]
SW[7:4]
SW[3:0]
==> Yt==> XP==> YP
After you set the switches to the desired locations, the locations of police and thief should be shown in the 7-segments as below. The seven segment #7 shows the X index of the thief's location and 7-segments #6 shows his Y location. The 7-segments #5 and #4 show the police location (Xp,Yp), respectively. All these four 7-segments should show the location in hexadecimal format. For example, if the location of thief and police are (14,9), and (3,10), respectively the number that each 7-segment should show are:
1
7-segnent #7 ==> E
7-segnent #6 ==> 9
7-segnent #5 ==> 3
7-segnent #4 ==> A
The game starts by pushing reset button (BTNC). The locations should be loaded in appropriate registers in your design after BTNC is pushed. Now you can move the police by pushing BTNU (move up), BTND (move down), BTNR (move right), and BTNL (move left). Each push moves the police one location in the related direction.
The number of steps (moves) the police takes should be counted. To do so, there should be a counter in your design that whenever you push one of the BTNU, BTND, BTNR, and BTNL it counts up by 1. This value of this counter should be shown in 7-segment #1 and #0 (in Fig. 2) in decimal format. For example, if the move buttons have been hit for 15 times totally, the 7-segments should be turned on like this:
o 7-segnent #1 ==> 1o 7-segnent #0 ==> 5
Not that the thief's location is constant, but the police's location should be updated whenever each move happens, and so the related seven-segments needs to be updated accordingly. In fact, the thief location doesn't change but the police location and the number of moves (number of pushed buttons counter) should be updated dynamically and their 7- segment should show the current status.
In each move, the police can go 1 location to left, right, bottom or up using the push buttons. If Police reaches to the thief location, then game is over. However, you need to follow the following rules:
2
o The aim is that the police arrest the thief using shortest path or near shortest paths, i..e, if shortest path needs N moves (N times pressing push buttons) for police, then if police reaches to the thief location with at most N+5 push, the police wins and all the LES are blinking with 1Hz frequency.
o If the police reaches to the thief's location with more than N+5 pushes (where N is the shortest path between them), the game is over but with a fail so all LEDs should show turn off.
o If police has not reached to the thief's location yet but the path so far he moved is more than N+5 then again he fails and all LEDs should turn off.
Note that it is assumed that after starting the moves, the center button and switches are not pushed (you do not need to consider the case that center button is pushed after the first move started).
If the police is on the borders ,i.e.,Xp=15,Xp=0,Yp=0, orYp=15 and the new movement is towards out of the shown grid, the police will stuck in his current position. However, the pushed buttons counter should be increased by 1 by any push (even if not move because of reaching to the boarder). To make it more obvious, suppose that the police is on (15,6), and you push the PTNR, so he cannot go further than 15 and will still in (15,6)
part 2
you need to implement the Snakes and Ladders game on the NEXYS 4 DDR FPGA board. The Boards include eight 7-segments, 16 Switches, 16 LEDs, and (5+2) push buttons as below. (CPU RESET and PROG are also push buttons)Game Rules:Figure 1 shows the play board. As seen the X and Y positions range between 0 to 9 for each player. If the player lands up at the head of the snake, the player moves down to the tail of the snake. If the player lands at the bottom of the ladder, the player moves to the top of the ladder. For example, if a player reaches to location (1, 3) that is related to position 39 in Figure 1, he/she should move to location (2,0) shown by 3 through the snake. However, if a player reaches to location (1,0) that is position 2, he/she should move to the location (2,2) that is position 23 through the ladder.Please consider the following notes. The notes are based on the FPGA board schematic shown in Figure 2. 2 Figure 2: NEXYS 4 DDR FPGA board
The game is started on the push of switch 7 from off to on (i.e., down to up). Ifthe switch 7 is off the game should be reset to initial state.• The game is played between two players. Both players start at position (0,0).•
The player one starts first by rolling of the dice.• The dice value is a random number between one and six. To throw the dice,player one uses switch 15 and player 2 uses switch 0 (as shown in Figure 2). Youcan implement the dice by generating a random number via a counter countingbetween 1 and 6 running under the system clock frequency (CLK100MHZ).When switch 15 or switch 0 changes from off to on (i.e., down to up), the countervalue is captured as the dice value. Note that for the next dice throwing, youshould move the switch from on to off first and then off to on.•
After the dice is thrown by each player, he/she moves on the board by using pushbuttons to move up, down, left or right (See push buttons in Figure 2). Note thatthe dice value for each player should be shown on the related 7-SEG discussedbelow.Example: Suppose the player 1 is at position 8 on the board and the dice roll upis 6. The player needs to move to position 14. For doing so, player 1 will pressthe right push button twice, followed by pressing the up push button once,followed up by pressing the left button triple times.•
After each player is done with the movements, by using the push buttons, he/sheshould press the center push button to indicate that the turn is over.• If the player moved correctly via the push buttons, his/her location (X and Ypositions) is updated on the seven segments (discussed later). However, if themoves are considered as wrong (after the push of center push button), the gameis over and the player loses it.•
Any player reaches first to the location (0,9), wins the game.•
In case, the player one wins the game, the LED 15 blinks, and if the player twowins the game, the LED 0 blinks.3Note on dice throwing:• When you move the switch from off to on you may have a transient change(glitch) in the signal related to the switch. So, you should use a filter for yourswitches as well as all push buttons. You already have the filter.v fromassignment 3.Seven SegmentsFigure 3: Eight Seven-segments included in the FPGAThe eight seven-segments included in the board are numbered from zero to sevenstarting from right. They show values as below:•
The 7SEG 7 and 7SEG 6 show the location of the first player at each time (Xcoordinate and Y coordinate, respectively), each between 0 and 9.• The 7-SEG 5 shows the dice number for player 1 (between 1 and 6).•
The 7SEG 4 and 7SEG 0 are not used.• The 7SEG 3 and 7SEG 2 show the location of the second player (X coordinateand Y coordinate, respectively), each between 0 and 9.•
The 7-SEG 1 shows the dice number for player 2 (between 1 and 6).Snake and Ladder Locations:Use the module (memory.v) given to you for uploading the locations of the snakes andladder. You should instantiate that module in your top module.To instantiate that module, you can include the following line in your top module:memory inst (.Address(mem_addr), .Data(mem_out));Here, mem_addr is a 4-bit address and mem_out is a 16-bit data.The lines 9 to 24 in memory.v indicate the start and stop coordinates for snakes andladders. In each line, the first and second 4 bits show the X and Y position of the starting4point of a snake or a ladder, respectively. In addition, the third and forth 4 bits representthe X, and Y locations of the stopping point of the same snake/ladder.For example, if we have 00010011001000001, it shows a snake going from (1,3) to(2,0). This entry is snake (as the destination is lower then source), but you don’t needto know if it is a ladder or snake. Your algorithm behaves the same for ladders andsnakes.Note that you should be able to use any map for ladder/snake positions in your code. Itmeans that if the values uploaded as the ladder/snake locations through memory.v file(that you were given) is changed, your implementation should operate properly basedon the new map. However, for the sake of simplicity, we assume that at most, thenumber of snakes and ladder, together, is 16. So, the code that you write should begeneric in a sense that it should work for any positions of snakes and ladders (totally upto 16).Deliverables•
Complete implemented project.•
A report explaining your design. The report should include a complete diagramof the design and a brief explanation of each part of design (not explaining thequestion).10-point Bonus (Due Tuesday Oct. 26)You get 10 extra point if you implement the dice throwing parts and showing the valueson the related seven segments for both players.
Collepals.com Plagiarism Free Papers
Are you looking for custom essay writing service or even dissertation writing services? Just request for our write my paper service, and we'll match you with the best essay writer in your subject! With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Get ZERO PLAGIARISM, HUMAN WRITTEN ESSAYS
Why Hire Collepals.com writers to do your paper?
Quality- We are experienced and have access to ample research materials.
We write plagiarism Free Content
Confidential- We never share or sell your personal information to third parties.
Support-Chat with us today! We are always waiting to answer all your questions.