master
cxz66666 2021-01-03 22:28:37 +08:00
parent cb4df25fd2
commit 7e687a2659
7 changed files with 183 additions and 18 deletions

View File

@ -0,0 +1,53 @@
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 01/03/2021 09:18:36 PM
// Design Name:
// Module Name: SEG_DRV
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module SEG_DRV(
input clk,
input [ 31: 0 ] num,
input ena,
input [ 7: 0 ] point,
output S_DT,
output S_CLK,
output S_CLR,
output S_EN
);
wire [ 63: 0 ] dto;
MYMC14495 m1( .D0( num[ 0 ] ), .D1( num[ 1 ] ), .D2( num[ 2 ] ), .D3( num[ 3 ] ), .LE( ~ena ), .point( point[ 0 ] ), .a( dto[ 0 ] ), .b( dto[ 1 ] ), .c( dto[ 2 ] ), .d( dto[ 3 ] ), .e( dto[ 4 ] ), .f( dto[ 5 ] ), .g( dto[ 6 ] ), .p( dto[ 7 ] ) );
MYMC14495 m2( .D0( num[ 4 ] ), .D1( num[ 5 ] ), .D2( num[ 6 ] ), .D3( num[ 7 ] ), .LE( ~ena ), .point( point[ 1 ] ), .a( dto[ 8 ] ), .b( dto[ 9 ] ), .c( dto[ 10 ] ), .d( dto[ 11 ] ), .e( dto[ 12 ] ), .f( dto[ 13 ] ), .g( dto[ 14 ] ), .p( dto[ 15 ] ) );
MYMC14495 m3( .D0( num[ 8 ] ), .D1( num[ 9 ] ), .D2( num[ 10 ] ), .D3( num[ 11 ] ), .LE( ~ena ), .point( point[ 2 ] ), .a( dto[ 16 ] ), .b( dto[ 17 ] ), .c( dto[ 18 ] ), .d( dto[ 19 ] ), .e( dto[ 20 ] ), .f( dto[ 21 ] ), .g( dto[ 22 ] ), .p( dto[ 23 ] ) );
MYMC14495 m4( .D0( num[ 12 ] ), .D1( num[ 13 ] ), .D2( num[ 14 ] ), .D3( num[ 15 ] ), .LE( ~ena ), .point( point[ 3 ] ), .a( dto[ 24 ] ), .b( dto[ 25 ] ), .c( dto[ 26 ] ), .d( dto[ 27 ] ), .e( dto[ 28 ] ), .f( dto[ 29 ] ), .g( dto[ 30 ] ), .p( dto[ 31 ] ) );
MYMC14495 m5( .D0( num[ 16 ] ), .D1( num[ 17 ] ), .D2( num[ 18 ] ), .D3( num[ 19 ] ), .LE( ~ena ), .point( point[ 4 ] ), .a( dto[ 32 ] ), .b( dto[ 33 ] ), .c( dto[ 34 ] ), .d( dto[ 35 ] ), .e( dto[ 36 ] ), .f( dto[ 37 ] ), .g( dto[ 38 ] ), .p( dto[ 39 ] ) );
MYMC14495 m6( .D0( num[ 20 ] ), .D1( num[ 21 ] ), .D2( num[ 22 ] ), .D3( num[ 23 ] ), .LE( ~ena ), .point( point[ 5 ] ), .a( dto[ 40 ] ), .b( dto[ 41 ] ), .c( dto[ 42 ] ), .d( dto[ 43 ] ), .e( dto[ 44 ] ), .f( dto[ 45 ] ), .g( dto[ 46 ] ), .p( dto[ 47 ] ) );
MYMC14495 m7( .D0( num[ 24 ] ), .D1( num[ 25 ] ), .D2( num[ 26 ] ), .D3( num[ 27 ] ), .LE( ~ena ), .point( point[ 6 ] ), .a( dto[ 48 ] ), .b( dto[ 49 ] ), .c( dto[ 50 ] ), .d( dto[ 51 ] ), .e( dto[ 52 ] ), .f( dto[ 53 ] ), .g( dto[ 54 ] ), .p( dto[ 55 ] ) );
MYMC14495 m8( .D0( num[ 28 ] ), .D1( num[ 29 ] ), .D2( num[ 30 ] ), .D3( num[ 31 ] ), .LE( ~ena ), .point( point[ 7 ] ), .a( dto[ 56 ] ), .b( dto[ 57 ] ), .c( dto[ 58 ] ), .d( dto[ 59 ] ), .e( dto[ 60 ] ), .f( dto[ 61 ] ), .g( dto[ 62 ] ), .p( dto[ 63 ] ) );
SEG_P2S m9( .clk( clk ), .data_in( dto ), .ena( ena ), .S_DT( S_DT ), .S_CLK( S_CLK ), .S_CLR( S_CLR ), .S_EN( S_EN ) );
endmodule

View File

@ -0,0 +1,79 @@
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 01/03/2021 09:20:53 PM
// Design Name:
// Module Name: SEG_P2S
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module SEG_P2S( clk,
data_in,
ena,
S_DT,
S_CLK,
S_CLR,
S_EN );
parameter WIDTH = 64;
parameter DELAY = 12;
input clk;
input ena;
input [ WIDTH - 1: 0 ] data_in;
output S_DT;
output S_CLK;
output S_CLR;
output S_EN;
wire s_clk, s_data;
reg out_ena;
assign S_CLK = s_clk;
assign S_DT = s_data;
assign S_EN = out_ena;
assign S_CLR = 1'b1;
reg [ WIDTH: 0 ] shift;
reg [ DELAY - 1: 0 ] counter = -1;
wire s_clk_Ena;
assign s_clk_Ena = | shift[ WIDTH - 1: 0 ];
assign s_clk = ~clk && s_clk_Ena;
assign s_data = shift[ WIDTH ];
always @ ( posedge clk or negedge ena ) begin
if ( ena == 0 ) begin
shift <= 0;
counter <= 0;
out_ena <= 1'b1;
end
else if ( s_clk_Ena ) begin
shift <= { shift[ WIDTH - 1: 0 ], 1'b0 };
end
else begin
if ( & counter ) begin
shift <= { data_in, 1'b1 };
out_ena <= 1'b0;
end
else begin
out_ena <= 1'b1;
end
counter <= counter + 1'b1;
end
end
endmodule

View File

@ -60,7 +60,17 @@ always @( posedge clk ) begin
2'b11:
num <= { 4'b1000, 4'b1000, 4'b1000, 4'b1000, 4'b1000, 4'b1000, 4'b1000, 4'b1000 };
default num <= 0;
endcase
end
SEG_DRV m_SEG_DRV(
.clk( clk ),
.num( num ),
.ena( 1'b1 ),
.point( 8'b0000_0000 ),
.S_DT( seg_sout ),
.S_CLK( seg_clk ),
.S_CLR( seg_clrn ),
.S_EN( SEG_PEN )
);
endmodule

View File

@ -81,7 +81,7 @@ wire [ 3: 0 ] scorea2, scoreb2;
wire [ 3: 0 ] scorec1, scorec2;
wire [ 3: 0 ] scored1, scored2;
wire [ 3: 0 ] player1_HP, player2_HP;
wire [ 3: 0 ] player1_HP_infinity, player2_HP_infinity;
wire [ 15: 0 ] LED_classic, LED_infinity;
wire [ 7: 0 ] score_classic, score_infinity;
wire [ 4: 0 ] timer;
@ -200,7 +200,9 @@ game_logic_infinity u_game_logic_infinity(
.gameover_infinity( gameover_infinity ),
.led_infinity( LED_infinity ),
.score_infinity( score_infinity ),
.timeup( timeup )
.timeup( timeup ),
.HP1_value( player1_HP_infinity ),
.HP2_value( player2_HP_infinity )
);
@ -667,6 +669,8 @@ vga_data_heart_gametips u_vga_data_heart_gametips(
.gameover_infinity( gameover_infinity ),
.HP1_value( player1_HP ),
.HP2_value( player2_HP ),
.HP1_value_infinity( player1_HP_infinity ),
.HP2_value_infinity( player2_HP_infinity ),
.score_classic( score_classic ),
.vgaData( heart_gametips_data )
);

View File

@ -39,7 +39,8 @@ module game_logic_infinity(
input item_test,
input item_invincible,
output reg [ 3: 0 ] HP1_value,
output reg [ 3: 0 ] HP2_value,
output reg [ 4: 0 ] timer,
output reg gameover_infinity,
@ -67,8 +68,8 @@ initial begin
score2 <= 0;
add_flag <= 0;
item_flag <= 0;
HP1_value <= 2;
HP2_value <= 2;
HP1_value <= 3;
HP2_value <= 3;
timeup <= 0;
end
@ -86,8 +87,8 @@ always @( posedge clk ) begin
HP2_value <= HP2_value;
end
if ( enable_game_infinity == 1'b0 ) begin
HP1_value <= 2;
HP2_value <= 2;
HP1_value <= 3;
HP2_value <= 3;
end
mytank1_state_last <= mytank1_state;
mytank2_state_last <= mytank2_state;
@ -144,7 +145,7 @@ always @( posedge clk ) begin
else begin
if ( score1 < scorea1 + scoreb1 + scorec1 + scored1 ) begin
if ( add_flag == 0 && timer > 0 && timer < 16 ) begin
timer <= timer + 4;
timer <= timer + 3;
cnt <= 0;
add_flag = 1;
end
@ -154,7 +155,7 @@ always @( posedge clk ) begin
end
if ( score2 < scorea2 + scoreb2 + scorec2 + scored2 ) begin
if ( add_flag == 0 && timer > 0 && timer < 16 ) begin
timer <= timer + 4;
timer <= timer + 3;
cnt <= 0;
add_flag = 1;
end

View File

@ -31,6 +31,8 @@ module vga_data_heart_gametips(
input gameover_infinity,
input [ 3: 0 ] HP1_value,
input [ 3: 0 ] HP2_value,
input [ 3: 0 ] HP1_value_infinity,
input [ 3: 0 ] HP2_value_infinity,
input [ 7: 0 ] score_classic,
output [ 11: 0 ] vgaData
);
@ -46,11 +48,11 @@ always @( posedge clk ) begin
heart_reg2 <= 0;
end
else if ( mode == 1 || mode == 2 ) begin
if ( vgaH >= 5 && vgaH < 25 && vgaV >= 180 && vgaV < 300 && ( vgaV - 180 ) < HP1_value * 20 ) begin
if ( vgaH >= 5 && vgaH < 25 && vgaV >= 180 && vgaV < 300 && ( vgaV - 180 ) < ( mode == 1 ? HP1_value : HP1_value_infinity ) * 20 ) begin
addra_heart_pic1 <= ( vgaH - 5 ) + ( ( vgaV - 180 ) % 20 ) * 20;
heart_reg1 <= heart_pic1;
end
else if ( vgaH >= 615 && vgaH < 635 && vgaV >= 180 && vgaV < 300 && ( vgaV - 180 ) < HP2_value * 20 ) begin
else if ( vgaH >= 615 && vgaH < 635 && vgaV >= 180 && vgaV < 300 && ( vgaV - 180 ) < ( mode == 1 ? HP2_value : HP2_value_infinity ) * 20 ) begin
addra_heart_pic2 <= ( vgaH - 615 ) + ( ( vgaV - 180 ) % 20 ) * 20;
heart_reg2 <= heart_pic2;
end

View File

@ -453,6 +453,22 @@
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PSRCDIR/sources_1/new/SEG_DRV.v">
<FileInfo>
<Attr Name="AutoDisabled" Val="1"/>
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="implementation"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<File Path="$PSRCDIR/sources_1/new/SEG_P2S.v">
<FileInfo>
<Attr Name="AutoDisabled" Val="1"/>
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="implementation"/>
<Attr Name="UsedIn" Val="simulation"/>
</FileInfo>
</File>
<Config>
<Option Name="DesignMode" Val="RTL"/>
<Option Name="TopModule" Val="Top"/>
@ -502,7 +518,7 @@
<File Path="$PSRCDIR/utils_1/imports/impl_1/Top_routed.dcp">
<FileInfo>
<Attr Name="ImportPath" Val="$PRUNDIR/impl_1/Top_routed.dcp"/>
<Attr Name="ImportTime" Val="1609673282"/>
<Attr Name="ImportTime" Val="1609679531"/>
<Attr Name="UsedIn" Val="synthesis"/>
<Attr Name="UsedIn" Val="implementation"/>
<Attr Name="UsedInSteps" Val="impl_1"/>