dhd lab project csl316 aarcheryrchery

24
DHD LAB PROJECT CSL316 ARCHERY ARCHERY Nitin Jain Kunal Rajvanshi 2003CS50218 2003CS10168 Group 4 Group 4 Instructor : Prof. M. Balakrishnan Teaching Assistant : Rahul Jain

Upload: others

Post on 13-Feb-2022

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: DHD LAB PROJECT CSL316 AARCHERYRCHERY

DHD LAB PROJECT CSL316

ARCHERYARCHERY

Nitin Jain Kunal Rajvanshi 2003CS50218 2003CS10168 Group 4 Group 4

Instructor : Prof. M. Balakrishnan Teaching Assistant : Rahul Jain

Page 2: DHD LAB PROJECT CSL316 AARCHERYRCHERY

AIM: To make a one player, 2 level shooting game using the FPGA board and the 8*8 LED MATRIX. INPUT/OUTPUT :

LEVEL

SHOOT

UP/DN

STOP

GAME PLAYED ON LED MATRIX

RESET

SHOOTING GAME

SCORE, NUMBER OF BULLETS (on seven segment display)

INPUTS 1) RESET : Used by user to reset shooting game. 2) STOP, UP/DN: These signals are used by user to move his shooting gun on the LED matrix display 3) SHOOT : Used to shoot the balloons 4) LEVEL: Used to change level of the game.At present we provide

two levels in our game.Implemented using Dip Switch Note: All input signals (except for LEVEL) are implemented using push buttons. FUNCTIONALITY On the LED matrix user can play a shooting game.There will be a gun which the user can move using appropriate input signals.User is required to shoot the balloons displayed on the LED display using the shoot signal.Once a balloon is shot it vanishes and the score is incremented.The score is displayed on the seven segment display alongwith the number of bullets remaining.User is provided only a limited number of bullets and the game finishes when all the balloons are shot.There is also a false balloon and game ends if user accidentally hits that balloon.

Page 3: DHD LAB PROJECT CSL316 AARCHERYRCHERY

In level 2 there is only a single balloon but unlike level 1 this balloon also fires bullets randomly towards the User’s gun.If User gets hit then the game finishes.On the contrary if User succeeds in shooting the balloon then the user wins the game. OUTPUTS: 1) Shooting game is played on the LED display 2) Score is continuously shown on the Seven Segment Display 3) Number of bullets remaining is also shown on Seven Segment Display PB1, PB2, PB3, and PB4: Push buttons for input signals

INPUT OUTPUT DIAGRAM

Rows[7..0] Columns[7..0] SCORE

INPUTS

Computational Hub

Dip switch (to change level)

PB4 PB3 PB2 PB1

Page 4: DHD LAB PROJECT CSL316 AARCHERYRCHERY

Computational Hub

LEVEL

To LED

LEVEL 1

SCORE

LEVEL 2

Page 5: DHD LAB PROJECT CSL316 AARCHERYRCHERY

No. of Bullets Left

Score (No. of balloons hit)

LEVEL 1

Bullet

False Balloon

Good Balloon

Person

The balloons in level 1 keep on falling down and wrap around. There is 1 false balloon along with 3 good balloons. The person can only shoot one bullet at once. Once the bullet hits a balloon that balloon is blown away. But if we hit the false balloon the person looses.

Page 6: DHD LAB PROJECT CSL316 AARCHERYRCHERY

LEVEL 2

Bullet from the person

Bullet from the enemy balloon

Enemy Balloon

Person

The person can move up and down and shoot at the enemy balloon. The enemy balloon can also shoot at the person in a fashion in which the balloon traces the person’s position and then shoots at that position tracing the position every time

Page 7: DHD LAB PROJECT CSL316 AARCHERYRCHERY

DESIGN SPECIFICATIONS . LEVEL 1 The issues handled.

1) Movement of the person: This is handled by the up/down and stop button. It is made with the help of a counter by keeping track of the extent of the up and down movements.

2) Movement of the balloons: This is taken care of by using a counter in which the balloon moves with different speed levels.

3) Firing Bullets: The bullets are fired by the person and are kept track of by the state machine.

4) Hitting the balloons: Whenever the balloon is hit . i.e. the rows and cols of bullet and the balloon match , then the balloon is switched off. In case of hitting the false balloon, a wall is created and the bullets of the person are turned off. This hitting of the balloon is taken care of by keeping comparators and then latching the hit value.

5) Limited No. of Bullets : The person is provided with limited no. of bullets in this level. The person is unable to shoot when he has exhausted this number.

6) Score : A Rom is kept in which the scores are kept which are to be sent to the 7 segment display.

LEVEL 2

1) Movement of the person: This is handled by the up/down and stop button. It is made with the help of a counter by keeping track of the extent of the up and down movements.

2) Movement of the balloon: This is taken care of by using a counter in which the balloon moves.

3) Firing Bullets: The bullets are fired by the person and are kept track

of by the state machine. The bullets are also fired by the balloon where at every warp around the row value of the person is latched and then the bullet is fired by the balloon towards the person every round.

Page 8: DHD LAB PROJECT CSL316 AARCHERYRCHERY

The movement of this bullet is again kept track of with the help of a state machine.

4) Hitting the balloon: Whenever the balloon is hit. i.e. the rows and cols of bullet and the balloon match , then the balloon is switched off.

5) Hitting the person : When the bullet fired by the balloon hits the

person then the person dies. TOP LEVEL MACROS

1) L1 MACRO

RST: reset signal which resets the game OBALLOONHIT: high if balloon0 is hit 1BALLOONHIT: high if balloon1 is hit 2BALLOONHIT: high if balloon2 is hit SCORE [0-7]: 8 bit signal sent to seven segment display to keep track

of how many balloons have been hit. This macro keeps track of score by looking at how many balloons have been hit

Page 9: DHD LAB PROJECT CSL316 AARCHERYRCHERY

2) L2 MACRO

BALLOONVALUE [0-7]: refers to the present row of balloon BALLVALUE [0-7]: refers to the present row of ball shot by user BALLOONCOORDINATE [0-7]: refers to the column of balloon BALLCOORDINATE [0-7]: refers to the column of ball shot by user BALLOONHIT: goes high if (balloon value=ball value) and

(Balloon coordinate=ball coordinate) This macro keeps track of whether balloon (including bad balloon) has been hit or not A similar Macro keeps track of whether person has been hit or not (This can happen only in level 2) 3) L3 MACRO

HIT : high if balloon is hit RESET : resets game GND : ground signal BALLOONVALUE [0-7] : present row of balloon BALLOONCOORDINATE [0-7]: present column of balloon

Page 10: DHD LAB PROJECT CSL316 AARCHERYRCHERY

If the balloon is hit then the balloon is turned off .This is ensured by looking at HIT and passing ground signal if balloon is hit. If a bad balloon is hit then the entire column corresponding to bad balloon is turned on.

4) L4 MACRO

INPTUPERSON [0-2] : gives the row of the person BALLOONLEV2HIT : high if level2 balloon is hit RESET : resets the game CLK15 BULLETCOORDINATE [0-7]: column for the bullet shot by level 2

balloon BULLET2VALUE [0-7]: the row for the bullet shot by level 2 balloon BALLOONLEV2VALUE [0-7]: row of level2 balloon BALLOONLEV2COORDINATE [0-7]: column of level2 balloon This macro decides row of bullet shot by level2 balloon on the basis of the position of person. Also if level2 balloon is hit then it is turned off. Also now there can be no bullets emerging from level2 balloon.

Page 11: DHD LAB PROJECT CSL316 AARCHERYRCHERY

5) L5 MACRO

This level is mainly to keep track of level 1 balloons and bullets position The inputs given are Stop, Up/Down, Reset and CLK. The outputs are the Balloon Rows and Columns along with the person’s Row and Column. The rows and columns are given in a decoded form. The bullets row and column are also outputted from this macro. We also get a GND signal from this macro

Page 12: DHD LAB PROJECT CSL316 AARCHERYRCHERY

ROM LISTINGS The various ROM listings are as follows: 1) ROM 1

This is the scoring rom in which the score that has to go to the 7Segment Led display. Corresponding to the BCD digit, A refers to the 8 bit signal is sent to the display. This particular rom refers to the number of bullets hit by the person. Memory File DATA 0000:01111110 , 0001:00110000 , 0010:00110000 , 0011:01101101, 0100:00110000 , 0101:01101101,0110:01101101,0111:01111001

Page 13: DHD LAB PROJECT CSL316 AARCHERYRCHERY

2) ROM 2

This is the bullets rom in which the number of bullets used by the person is given and the corresponding value is got which goes on the LED 7 segment display.

Memory File DATA 0000:01111110 , 0001:00110000 , 0010:00110000 , 0011:01101101, 0100:00110000 , 0101:01101101,0110:01101101,0111:01111001

Division of Outputs to the LED through a Mux

Level 1:

Page 14: DHD LAB PROJECT CSL316 AARCHERYRCHERY

All the inputs from the level1 are passed from the multiplexor.The SEL signal is coming from the counter . This enables us to divide the clock into selecting various inputs. 1) Levrow , Levcol : This signal correspond to the levels and the rows that

are being selected. 2) Value : This suffix corresponds to the row value of the input. 3) Coordinate: This suffix corresponds to the column value of the input. 4) Person: This is the signal from the movement of the person. 5) ith Hit : These are for the ith balloons. These are coming from a

multiplexor which sends their real value or Ground value corresponding to if they have been hit. 6) BadBalloon : This is the false Balloon.

Page 15: DHD LAB PROJECT CSL316 AARCHERYRCHERY

LEVEL 2 These inputs are divided according to a value coming from a counter.

Same logic is also applied for the 2nd level.

1) Value Person: This corresponds to the value whether the person has been hit or not. If the person has been hit then a VCC on all 8 bits are sent .

2) HitLev2 : This corresponds the the enemy balloon which is there. If that balloon is hit then that balloon disappears. 3) Ball : This is the bullet which the person can fire. 4) Bullet2 : Enemy’s Bullet.

Page 16: DHD LAB PROJECT CSL316 AARCHERYRCHERY

Simulation and Timing Diagram State Machine

This state machine was coded in VHDL . The code is given at the end of the File: In the following timing diagram the state machine which has been described above (used for the bullets) has been shown. This was done at the time of testing the state machine. Signals Are: 1) Reset : This is to reset the state machine. 2) Shoot : This is the shoot signal given by the user.

Page 17: DHD LAB PROJECT CSL316 AARCHERYRCHERY

3) Stop : This is the stop signal given by the user. 4) Clk_15DIV : This is the clock at which the state machine

operates. 5) Qi : This is the output of the ith state. It basically Indicates which state you are in.

As we can see from the timing diagram the machine goes into the first state as soon as the reset signal goes high. When we receive the stop and start both as 1 together the machine makes a transition into the next state. At every clock pulse thereafter the machine goes in to the next state finally coming back to the first state. PERSON MOVEMENT This timing diagram relates to the movement of the person. 1) Person Value (7..0) : This is the row coordinate of the person according to Led Display. The person has a head and a one LED Body. 2) BalloonValue(7..0) : This is the column of the first balloon which is there. 3) UP : This is the signal given by the user to move up or down. 4) Stop : This is the signal for the stopping of the person. 5) Shooting : Signal given by the user to make person shoot. 6) Clk15 : This is the clock which is divided further to enable enable the movement of the person.

Page 18: DHD LAB PROJECT CSL316 AARCHERYRCHERY

As we can see from the above simulation initially the user sends to signal up . Thus the row values of the person keep on changing according to movement of the person(06-0C). When the up signal is not there the person moves in the other direction. (0C-18). Whenever we have a stop signal this means that the person will just stay there and not move. Again when we withdraw the stop signal we get that the person moves in the direction earlier which he was moving. The value of the balloon keeps on changing with the clock . As the balloon keeps on doing a wrap around.

Design Report And Specifications

Design Summary: Number of CLBs: 271 out of 400 67% NOTE: (Report given in the conclusion about the CLB usage) CLB Flip Flops: 112 4 input LUTs: 346 3 input LUTs: 97 (3 used as route-throughs) 16X1 ROMs: 24 Number of bonded IOBs: 41 out of 61 67% IOB Flops: 0 IOB Latches: 0 Number of pullups: 12 out of 112 10%

Page 19: DHD LAB PROJECT CSL316 AARCHERYRCHERY

Number of TBUFs: 120 out of 880 13% Number of OSC: 1 out of 1 100% Total equivalent gate count for design: 4227 Additional JTAG gate count for IOBs: 1968 Timing summary: Constraints cover 1814 paths, 491 nets, and 1613 connections (100.0% coverage) Design statistics: Minimum period: 27.519ns (Maximum frequency: 36.339MHz) Maximum combinational path delay: 39.659ns Maximum net delay: 23.727ns UCF FILE SPECIFICATION RA corresponds to the rows of the LED 8*8. RB is permanently to by ground. C refers to the column select of the LED 8*8. ################################ #CN14 to CN12 # ################################ NET RA<0> LOC= P35; NET RA<1> LOC= P45; NET RA<2> LOC= P68; NET RA<3> LOC= P38; NET RA<4> LOC= P39; NET RA<5> LOC= P67; NET RA<6> LOC= P66; NET RA<7> LOC= P69; NET RB<0> LOC= P40; NET RB<1> LOC= P47; NET RB<2> LOC =P48; NET RB<3> LOC =P49;

Page 20: DHD LAB PROJECT CSL316 AARCHERYRCHERY

NET RB<4> LOC =P37; NET RB<5> LOC =P36; NET RB<6> LOC =P44; NET RB<7> LOC =P46; ################################ #CN17 to CN09 # ################################ NET C<0> LOC =P60; NET C<1> LOC =P61; NET C<2> LOC =P62; NET C<3> LOC =P65; NET C<4> LOC =P56; NET C<5> LOC =P57; NET C<6> LOC =P58; NET C<7> LOC =P59; ################################ #CN21 to 7 SEGMENT LED # ################################ NET STATE<0> LOC=P83;## These are the values for the Segments a,b,c,d,e,f,g,dp NET STATE<1> LOC=P82; NET STATE<2> LOC=P81; NET STATE<3> LOC=P80; NET STATE<4> LOC=P79; NET STATE<5> LOC=P77; NET STATE<7> LOC=P84; NET DE0 LOC =P3; ## This selects which 7 segment LED display to light up. NET DE1 LOC =P4; NET DE2 LOC =P5;

Page 21: DHD LAB PROJECT CSL316 AARCHERYRCHERY

#################################### #CN 13 for INPUT (CN10) # #################################### NET STOP LOC =P14; NET UP LOC =P15; NET SHOOTING LOC= P16; NET RESET LOC =P17; NET LEVEL1 LOC =P20; Design Report , Improvements and Conclusion This game could be easily extended to include many more features. e.g. A level 3 could include the enemies coming from various directions in the Led Display. The person then has to shoot them and prevent from hitting them. 1) Another possible refinement in the design could be less usage of the decoders. Every time we have to send an input to the Led Display the 3 bits of the row and the column have to be decoded. A possible refinement could be that instead of decoding every time we could decode right at the end after the inputs pass through from the Multiplexer( The inputs are selected though the clock division). This way many CLB’s could get saved. But the reason we did not use the decoder at the end was that a Led positioned at 0*0 would always be lit up. As when we try to decode 000 we get 10000000 . This was we are effectively sending 1 signal to row and column of the first LED most of the time. This would not have looked good. As our design easily fit into the existing 400 CLB’s we did not worry about this decoding much. 2)We would have ideally wanted to display this on a VGA output but due to the lack of time, we had to stick to the LED display. For the VGA display output we needed to have had an experience in coding in VC++.

Page 22: DHD LAB PROJECT CSL316 AARCHERYRCHERY

3) The score cannot be shown properly on the LED 7 segment . All the pins for the Channel 21 do not work fine . Therefore because of this constaint we could not use the LCD panel to initialize it and display the score on that. STATEMACHINE Code for the state machine. library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_arith.all; use IEEE.std_logic_unsigned.all; library SYNOPSYS; use SYNOPSYS.attributes.all; entity statemachine is port ( CLK_A: in STD_LOGIC; RST: in STD_LOGIC; STOP: in STD_LOGIC; SHOOT: in STD_LOGIC; Q1: out STD_LOGIC; Q2: out STD_LOGIC; Q3: out STD_LOGIC; Q4: out STD_LOGIC; Q5: out STD_LOGIC; Q6: out STD_LOGIC; Q7: out STD_LOGIC; Q8: out STD_LOGIC ); end statemachine; architecture arch of statemachine is -- SYMBOLIC ENCODED state machine: Sreg0 type Sreg0_type is (S1, S2, S3, S4, S5, S6,S7,S8); signal Sreg0: Sreg0_type; signal tq1,tq2,tq3,tq4,tq5,tq6,tq7,tq8 : std_logic; begin -- concurrent signals assignments

Page 23: DHD LAB PROJECT CSL316 AARCHERYRCHERY

Sreg0_machine: process (CLK_A) begin Q1<= tq1; Q2<= tq2; Q3<= tq3; Q4<= tq4; Q5<= tq5; Q6<= tq6; Q7<= tq7; Q8<= tq8; if CLK_A'event and CLK_A = '1' then if RST = '1' then Sreg0 <= S1; tq1 <= '1';tq2<='0';tq3<='0';tq4<='0';tq5<='0';tq6<='0';tq7<='0';tq8<='0'; else case Sreg0 is when S1 => if (not(SHOOT='1' and STOP ='1')) then Sreg0 <= S1;tq1 <= '1'; elsif (STOP= '1' and SHOOT ='1') then Sreg0 <= S2;tq2 <= '1';tq1 <= '0'; end if; when S2 => Sreg0 <= S3;tq2 <= '0';tq3 <= '1'; when S3 => Sreg0 <= S4;tq3 <= '0';tq4 <= '1'; when S4 => Sreg0 <= S5;tq4 <= '0';tq5 <= '1'; when S5 => Sreg0 <= S6;tq5 <= '0';tq6 <= '1'; when S6 => Sreg0 <= S7;tq6 <= '0';tq7 <= '1'; when S7 => Sreg0 <= S8;tq7 <= '0';tq8 <= '1'; when S8 => Sreg0 <= S1;tq8 <= '0';tq1 <= '1'; when others => null; end case; end if; end if; end process; end arch;

Page 24: DHD LAB PROJECT CSL316 AARCHERYRCHERY