data/full_repos/permissive/115487336/mycode/Whac-A-Mole/button.v
data/verilator_xmls/5fe0e31a-1736-4693-9b9c-fadf813a7387.xml
module button(
	input clk,
	input rst_n,
	input button,
	output reg buttonpress
);


reg [19:0] count;
reg en;
reg update;


always@(posedge clk or posedge rst_n)
begin
	if(rst_n)
	begin
		count <= 20'h0;
		en<=1'b0;
		update <= 1'b0;
		buttonpress <= 1'b0;
	end
	else
	begin
		buttonpress <= 1'b0;
		if(button)
		begin
			if(count == 20'd9_99999)
			begin
				en <= 1'b1;
			end
			else
			begin
				count <= count + 20'h1;
				en <= 1'b0;
			end
		end
		else
		begin
			count <= 20'h0;
			en <= 1'b0;
			update <= 1'b0;
		end
		if(en && !update)
		begin
			buttonpress <= 1'b1;
			update <= 1'b1;
		end
	end
end
endmodule
module button(
	input clk,
	input rst_n,
	input button,
	output reg buttonpress
);



reg [19:0] count;
reg en;
reg update;


always@(posedge clk or posedge rst_n)
begin
	if(rst_n)
	begin
		count <= 20'h0;
		en<=1'b0;
		update <= 1'b0;
		buttonpress <= 1'b0;
	end
	else
	begin
		buttonpress <= 1'b0;
		if(button)
		begin
			if(count == 20'd9_99999)
			begin
				en <= 1'b1;
			end
			else
			begin
				count <= count + 20'h1;
				en <= 1'b0;
			end
		end
		else
		begin
			count <= 20'h0;
			en <= 1'b0;
			update <= 1'b0;
		end
		if(en && !update)
		begin
			buttonpress <= 1'b1;
			update <= 1'b1;
		end
	end
end
endmodule