item图片烧进去了,但是逻辑还没写完整。,,

This commit is contained in:
2021-01-05 23:49:36 +08:00
parent 7e687a2659
commit 9310777b6a
58 changed files with 825266 additions and 27 deletions
+16 -8
View File
@@ -24,9 +24,10 @@ module Random(
input clk,
input rst_n,
input [ 1: 0 ] flag,
output reg [ 1: 0 ] random
output reg [ 1: 0 ] random,
output reg [ 14: 0 ] random_14
);
reg [ 7: 0 ] rand_num;
reg [ 14: 0 ] rand_num;
always @( * ) begin
case ( flag )
2'b00:
@@ -43,21 +44,28 @@ end
initial begin
rand_num = 8'b1111_1111;
rand_num = 15'b1111_1111_1111_111;
end
always@( posedge clk ) begin
if ( !rst_n ) begin
rand_num <= 8'b1111_1111;
rand_num <= 15'b1111_1111_1111_111;
end
else begin
rand_num[ 0 ] <= rand_num[ 7 ];
rand_num[ 0 ] <= rand_num[ 14 ];
rand_num[ 1 ] <= rand_num[ 0 ];
rand_num[ 2 ] <= rand_num[ 1 ];
rand_num[ 3 ] <= rand_num[ 2 ];
rand_num[ 4 ] <= rand_num[ 3 ] ^ rand_num[ 7 ];
rand_num[ 5 ] <= rand_num[ 4 ] ^ rand_num[ 7 ];
rand_num[ 6 ] <= rand_num[ 5 ] ^ rand_num[ 7 ];
rand_num[ 4 ] <= rand_num[ 3 ] ^ rand_num[ 14 ];
rand_num[ 5 ] <= rand_num[ 4 ] ^ rand_num[ 14 ];
rand_num[ 6 ] <= rand_num[ 5 ] ^ rand_num[ 14 ];
rand_num[ 7 ] <= rand_num[ 6 ];
rand_num[ 9 ] <= rand_num[ 7 ];
rand_num[ 8 ] <= rand_num[ 8 ] ^ rand_num[ 14 ];
rand_num[ 10 ] <= rand_num[ 9 ];
rand_num[ 11 ] <= rand_num[ 10 ];
rand_num[ 12 ] <= rand_num[ 11 ] ^ rand_num[ 14 ];
rand_num[ 13 ] <= rand_num[ 12 ];
rand_num[ 14 ] <= rand_num[ 13 ];
end
end
+7 -7
View File
@@ -125,7 +125,7 @@ game_mode u_game_mode(
.clk( clk ),
.btn_confirm( BTNC ),
.btn_mode_sel( SW[ 0 ] ),
.btn_return( BTNU ), //the under button is used for return to the game
.btn_return( BTNU ), //the under button is used for return to the game
.gameover_classic( gameover_classic ),
.gameover_infinity( gameover_infinity ),
.enable_shell1( enable_enermy1_bullet ),
@@ -271,7 +271,7 @@ tank_display u_tank2_display(
.tankDir( player2_tank_dir ),
.tank_destroyed( ~player2_tank_en ),
.mode( mode ),
.tank_revive( player1_revive ),
.tank_revive( player2_revive ),
.player_enermy( 1'b0 ),
.vgaH( vgaH ),
.vgaV( vgaV ),
@@ -284,7 +284,7 @@ tank_display enermy1_tank_display(
.tankDir( enermy1_tank_dir ),
.tank_destroyed( ~enermy1_tank_en ),
.mode( mode ),
.tank_revive( player1_revive ),
.tank_revive( enermy1_revive ),
.player_enermy( 1'b1 ),
.vgaH( vgaH ),
.vgaV( vgaV ),
@@ -298,7 +298,7 @@ tank_display enermy2_tank_display(
.tankDir( enermy2_tank_dir ),
.tank_destroyed( ~enermy2_tank_en ),
.mode( mode ),
.tank_revive( player1_revive ),
.tank_revive( enermy2_revive ),
.player_enermy( 1'b1 ),
.vgaH( vgaH ),
.vgaV( vgaV ),
@@ -311,7 +311,7 @@ tank_display enermy3_tank_display(
.tankDir( enermy3_tank_dir ),
.tank_destroyed( ~enermy3_tank_en ),
.mode( mode ),
.tank_revive( player1_revive ),
.tank_revive( enermy3_revive ),
.player_enermy( 1'b1 ),
.vgaH( vgaH ),
.vgaV( vgaV ),
@@ -324,7 +324,7 @@ tank_display enermy4_tank_display(
.tankDir( enermy4_tank_dir ),
.tank_destroyed( ~enermy4_tank_en ),
.mode( mode ),
.tank_revive( player1_revive ),
.tank_revive( enermy4_revive ),
.player_enermy( 1'b1 ),
.vgaH( vgaH ),
.vgaV( vgaV ),
@@ -707,7 +707,7 @@ SegAndLed u_SegAndLed(
.score_classic( score_classic ),
.score_infinity( score_infinity ),
.timer( timer ),
.default_num( num ), //when mode ==00(before begin mode) then output num ,you can also use it as debug
.default_num( num ), //when mode ==00(before begin mode) then output num ,you can also use it as debug
.enable_game_classic( enable_game_classic ),
.enable_game_infinity( enable_game_infinity ),
.player1_tank_en( player1_tank_en ),
+20 -7
View File
@@ -24,7 +24,7 @@ module enermy_control(
input clk_8Hz,
input clk_2Hz,
input clk_10ms,
input [ 1: 0 ] flag, //00 01 10 11 four tanks
input [ 1: 0 ] flag, //00 01 10 11 four tanks
input [ 10: 0 ] player1_H,
input [ 10: 0 ] player1_V,
input [ 10: 0 ] player2_H,
@@ -78,7 +78,7 @@ assign enermy_moving = enermy_tank_en;
initial begin
enermy_fire <= 1'b0;
counter_num <= flag;
counter_num <= 0;
rand <= flag[ 0 ];
Continue <= 0;
Continue_num <= 0;
@@ -88,7 +88,8 @@ Random u_Random(
.clk( clk_10ms ),
.rst_n( 1'b1 ),
.flag( flag ),
.random( rand_num )
.random( rand_num ),
.random_14()
);
always @( posedge clk_2Hz ) begin
if ( !player1_bullet_dir[ 2 ] && !Continue ) begin
@@ -196,7 +197,7 @@ always @( posedge clk_2Hz ) begin
endcase
end
else begin
if ( Continue ) begin
enermy_fire <= 1'b0;
if ( rand ) begin
if ( enermy_V + TANK_HEIGHT / 2 <= chase_tank_V ) begin
@@ -235,7 +236,21 @@ always @( posedge clk_2Hz ) begin
end
if ( counter_num % 4 != flag ) begin
enermy_dir_feedback <= enermy_dir_feedback_tmp;
if ( enermy_dir_feedback == 2'b00 && enermy_V == 0 ) begin
enermy_dir_feedback <= rand_num[ 1: 0 ];
end
else if ( enermy_dir_feedback == 2'b01 && tank_DBound >= HEIGHT ) begin
enermy_dir_feedback <= rand_num[ 1: 0 ];
end
else if ( enermy_dir_feedback == 2'b10 && enermy_H == 0 ) begin
enermy_dir_feedback <= rand_num[ 1: 0 ];
end
else if ( enermy_dir_feedback == 2'b11 && tank_RBound >= WIDTH ) begin
enermy_dir_feedback <= rand_num[ 1: 0 ];
end
else begin
enermy_dir_feedback <= enermy_dir_feedback_tmp;
end
end
else begin
enermy_dir_feedback <= rand_num[ 1: 0 ];
@@ -252,6 +267,4 @@ always @( posedge clk_2Hz ) begin
end
end
endmodule
+162
View File
@@ -0,0 +1,162 @@
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 01/05/2021 10:54:29 PM
// Design Name:
// Module Name: item_logic
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module item_logic(
input clk,
input clk_4Hz,
input enable_reward,
input enable_game_classic,
input enable_game_infinity,
input [ 10: 0 ] player1_tank_H,
input [ 10: 0 ] player1_tank_V,
input player1_tank_en,
input [ 1: 0 ] player1_tank_dir,
input [ 10: 0 ] player2_tank_H,
input [ 10: 0 ] player2_tank_V,
input [ 1: 0 ] player2_tank_dir,
input player2_tank_en,
input [ 10: 0 ] VGA_h,
input [ 10: 0 ] VGA_V,
input reset_n,
output reg item_invincible,
output reg item_addtime,
output reg item_frozen,
output reg item_addHP,
output reg which_player,
output [ 11: 0 ] VGA_data
);
wire [ 1: 0 ] item_type;
wire [ 10: 0 ] random_xpos, random_ypos;
reg [ 31: 0 ] cnt_num;
wire set_require;
reg set_finish;
wire [ 11: 0 ] VGA_data_information;
assign VGA_data_reward = VGA_data_information;
initial begin
cnt_num <= 0;
item_invincible <= 0;
item_addtime <= 0;
item_frozen <= 0;
item_addHP <= 0;
which_player <= 0;
end
wire player1_tank_get, player1_tank_tmp;
wire player2_tank_get, player2_tank_tmp;
parameter TANK_WIDTH = 32;
parameter TANK_HEIGHT = 32;
parameter ITEM_WIDTH = 20;
parameter ITEM_HEIGHT = 20;
object_collide_detection tank1_item(
player1_tank_H, player1_tank_V, player1_tank_en, player1_tank_dir,
TANK_HEIGHT, TANK_WIDTH,
random_xpos, random_ypos, set_require , player1_tank_dir,
ITEM_HEIGHT, ITEM_WIDTH,
player1_tank_get, player1_tank_tmp
);
//player2 's tank
object_collide_detection tank2_item(
player2_tank_H, player2_tank_V, player2_tank_en, player2_tank_dir,
TANK_HEIGHT, TANK_WIDTH,
random_xpos, random_ypos, set_require , player1_tank_dir,
ITEM_HEIGHT, ITEM_WIDTH,
player2_tank_get, player2_tank_tmp
);
always @( posedge clk ) begin
if ( enable_reward ) begin
if ( player1_tank_get || player2_tank_get ) begin
case ( item_type )
1: begin
if ( enable_game_classic ) begin
item_addHP <= 1'b1;
which_player <= player2_tank_get;
end
if ( enable_game_infinity ) begin
item_addtime <= 1'b1;
which_player <= player2_tank_get;
end
end
2: begin
item_frozen <= 1'b1;
which_player <= player2_tank_get;
end
3: begin
item_invincible <= 1'b1;
which_player <= player2_tank_get;
end
default : begin
item_addHP <= 1'b0;
item_addtime <= 1'b0;
item_frozen <= 1'b0;
item_invincible <= 1'b0;
end
endcase
set_finish <= 1'b1;
end
else begin
set_finish <= 1'b0;
end
if ( item_invincible ) begin
cnt <= cnt + 1;
if ( cnt >= 500000000 ) begin
item_invincible <= 1'b0;
cnt <= 0;
end
end
if ( item_addHP ) begin
cnt <= cnt + 1;
if ( cnt >= 5000 ) begin
item_addHP <= 1'b0;
cnt <= 0;
end
end
if ( item_addtime ) begin
cnt <= cnt + 1;
if ( cnt >= 5000 ) begin
item_addtime <= 1'b0;
cnt <= 0;
end
end
if ( item_frozen ) begin
cnt <= cnt + 1;
if ( cnt >= 300000000 ) begin
item_frozen <= 1'b0;
cnt <= 0;
end
end
end
end
item_random_generator u_item_random_generator(
);
endmodule
@@ -0,0 +1,34 @@
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 01/05/2021 10:41:37 PM
// Design Name:
// Module Name: item_random_generator
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module item_random_generator(
input clk,
input clk_4Hz,
input set_finish,
input enable,
output reg dout,
output reg set_require,
output reg [ 1: 0 ] item_type,
output [ 10: 0 ] random_xpos,
output [ 10: 0 ] random_ypos
);
endmodule
+9 -5
View File
@@ -26,11 +26,11 @@ module tank_display(
input tank_destroyed,
input [ 2: 0 ] mode,
input tank_revive,
input player_enermy, //player is 0 and enermy is 1
input player_enermy, //player is 0 and enermy is 1
input [ 10: 0 ] vgaH,
input [ 10: 0 ] vgaV, // Current VGA position
input [ 10: 0 ] vgaV, // Current VGA position
input [ 10: 0 ] tankH,
input [ 10: 0 ] tankV, // Current Y of tank
input [ 10: 0 ] tankV, // Current Y of tank
output [ 11: 0 ] tankData
);
@@ -58,9 +58,13 @@ wire [ 11: 0 ] tankDownData_enermy;
wire [ 11: 0 ] outData;
wire [ 11: 0 ] outData_enermy;
wire [ 11: 0 ] outData_star;
assign tankAddr = tank_en ? ( ( vgaV - tankV ) * TANK_WIDTH + ( vgaH - tankH ) ) : 1'b0;
invincible_star_32_32 u_invincible_star_32_32(
.addra( tankAddr ), .clka( clk ), .douta( outData_star ), .ena( 1'b1 )
);
tank_left_img tank_left( .addra( tankAddr ), .clka( clk ), .douta( tankLeftData ), .ena( 1'b1 ) );
tank_right_img tank_right( .addra( tankAddr ), .clka( clk ), .douta( tankRightData ), .ena( 1'b1 ) );
tank_up_img tank_up( .addra( tankAddr ), .clka( clk ), .douta( tankUpData ), .ena( 1'b1 ) );
@@ -77,6 +81,6 @@ tank_data_selector tank_select( .clk( clk ), .UP( tankUpData ), .DOWN( tankDownD
.RIGHT( tankRightData ), .Dir( tankDir ), .tankData( outData ) );
tank_data_selector e_tank_select( .clk( clk ), .UP( tankUpData_enermy ), .DOWN( tankDownData_enermy ), .LEFT( tankLeftData_enermy ),
.RIGHT( tankRightData_enermy ), .Dir( tankDir ), .tankData( outData_enermy ) );
assign tankData = ( tank_en & ~tank_destroyed ) ? ( player_enermy ? outData_enermy : outData ) : 0;
assign tankData = ( ( tank_en & ~tank_destroyed ) ? ( player_enermy ? outData_enermy : outData ) : 0 ) | ( tank_revive ? outData_star : 0 );
endmodule