module demo_sound2( input clock, output [7:0]key_code, input k_tr ); reg [15:0]tmp; wire [15:0]tmpa; reg tr; reg [15:0]step; wire [15:0]step_r; reg [7:0]TT; reg[5:0]st; reg go_end; ////////Music Processing//////// always @(negedge k_tr or posedge clock) begin if (!k_tr) begin step=0; st=0; tr=0; end else if (steptmpa) go_end=1; else tmp=tmp+1; end assign key_code= ( tmp < ( tmpa-1 ) )? key_code1 : 8'hf0 ;//KEY release// endmodule