QUESTION 1: In this part of the project you will implement Matchsticks game in Verilog.
Matchsticks is a puzzle game for two players. Several matchsticks are placed in a line and players take turns removing one, two, or three matches from the table. You cant take any more than three matches on any one turn, you have to take at least one, and you can never put any back. The object is to force your opponent to take the last matchstick.
You will use a 44 keypad and 7 segment display as input and output devices. At the beginning of the game, you will enter how many matches to be used in the game and then press *. Number of total matches will be seen on 7 segment display. After that, first player starts to take matches. The first player will enter how many matches to be taken. The numbers can be 1, 2 or 3. Other than these numbers wont be accepted. When the first player push #, the number will be subtructed from total matches and second player starts to play. At the end, one of the players will take last match and he will be the looser. The winner will be seen on 7 segment display like #1 or #2.
You will use 3 modules in this project, main module, seven segment module and keypad module. Notice that at the end of the game, when we have 1 or 2 matches it is not possible to enter 2 or 3 respectively.
Bonus: Draw your guess about the circuit your verilog code generates. Recall that if..else if..else and case statements are converted into multiplexers.
QUESTION 2:
- a) Realize Bird in Logisim and in Verilog. In the Verilog realization, you have to connect register 0 to a 7-segment display, which should show the hexadecimal number in register 0 continually. You can use the Verilog code given for Reptile in the website as a starting point.
- b) Modify the assembler of Reptile given in the website to translate assembly for bird.
- c) Write a program for bird which has a variable LIM, which is assigned to an integer in your program. Your program must calculate
1 + 2*2 + 3 + 4*4 + 5 + + LIM*LIM if LIM is even
1 + 2*2 + 3 + 4*4 + 5 + + LIM if LIM is odd
after each sum, you have to update register 0, ie, register 0 must contain
1
1+2*2
1 + 2*2 + 3
1 + 2*2 + 3 + 4*4
1 + 2*2 + 3 + 4*4 + 5
in progression.
Terminate your program with an infinite loop instruction, ie,
loop jmp loop
Your program must contain a subroutine which can take the square of a number. Use that subroutine to compute terms like 2*2, 3*3, 4*4 etc.
In verilog, your project must work when the clock is connected to the pushbutton, and also when it is connected to the 50 MHz system clock. Pushbutton will make your life very easy when you debug your project.
In logisim also, your project must work when the clock is supplied by ctrl-T commands or when connected to the 4KHz system clock..
Reviews
There are no reviews yet.