data/full_repos/permissive/177353332/src/smdsixbutton.v
 line:10: before: "="
1: b'%Warning-WIDTH: data/full_repos/permissive/177353332/src/smdsixbutton.v:58: Operator SUB expects 14 bits on the RHS, but RHS\'s CONST \'2\'h1\' generates 2 bits.\n                                                                          : ... In instance smdsixbutton\n    clk_counter <= clk_counter - 2\'b1;\n                               ^\n                ... Use "/* verilator lint_off WIDTH */" and lint_on around source to disable this message.\n%Error: Exiting due to 1 warning(s)\n'
module smdsixbutton (
	input clk,
	input p7,
	output reg [5:0] p = 6'b111111,
	input up,
	input dw,
	input lf,
	input rg,
	input a,
	input b,
	input c,
	input st,
	input x,
	input y,
	input z,
	input md,
	input hm
);

parameter TIMEOUT = 14'd8000;


reg [13:0] clk_counter = TIMEOUT;

reg [1:0] hi_count = 2'b0;

reg mode_set = 1'b0;
reg three_button_mode = 1'b0;

reg last_p7_1 = 1'b0;
reg last_p7_2 = 1'b0;

always @(posedge clk) begin
	last_p7_1 <= p7;
	last_p7_2 <= last_p7_1;

	if(!mode_set) begin
		three_button_mode <= !md;
		mode_set <= 1'b1;
	end

	if(!three_button_mode) begin
		if (clk_counter == 0) begin
			$display("Reset!");
			clk_counter <= TIMEOUT;
			hi_count <= 0;
		end else begin
			if (last_p7_1 && !last_p7_2) begin
				hi_count <= hi_count + 2'b1;
				clk_counter <= TIMEOUT;
			end else begin
				clk_counter <= clk_counter - 2'b1;
			end
		end
	end
end

always @(*) begin
	$display("hi_count=%d", hi_count);
	case ({hi_count, last_p7_2})
		3'b000: p = {up, dw, 1'b0, 1'b0, a, st};
		3'b001: p = {up, dw, lf, rg, b, c};
		3'b010: p = {up, dw, 1'b0, 1'b0, a, st};
		3'b011: p = {up, dw, lf, rg, b, c};
		3'b100: p = {1'b0, 1'b0, 1'b0, 1'b0, a, st};
		3'b101: p = {up, dw, lf, rg, b, c};
		3'b110: p = {hm, 1'b1, 1'b1, 1'b1, a, st};
		3'b111: p = {z, y, x, md, 1'b1, 1'b1};
	endcase
end

endmodule
module smdsixbutton (
	input clk,
	input p7,
	output reg [5:0] p = 6'b111111,
	input up,
	input dw,
	input lf,
	input rg,
	input a,
	input b,
	input c,
	input st,
	input x,
	input y,
	input z,
	input md,
	input hm
);


parameter TIMEOUT = 14'd8000;


reg [13:0] clk_counter = TIMEOUT;

reg [1:0] hi_count = 2'b0;

reg mode_set = 1'b0;
reg three_button_mode = 1'b0;

reg last_p7_1 = 1'b0;
reg last_p7_2 = 1'b0;

always @(posedge clk) begin
	last_p7_1 <= p7;
	last_p7_2 <= last_p7_1;

	if(!mode_set) begin
		three_button_mode <= !md;
		mode_set <= 1'b1;
	end

	if(!three_button_mode) begin
		if (clk_counter == 0) begin
			$display("Reset!");
			clk_counter <= TIMEOUT;
			hi_count <= 0;
		end else begin
			if (last_p7_1 && !last_p7_2) begin
				hi_count <= hi_count + 2'b1;
				clk_counter <= TIMEOUT;
			end else begin
				clk_counter <= clk_counter - 2'b1;
			end
		end
	end
end

always @(*) begin
	$display("hi_count=%d", hi_count);
	case ({hi_count, last_p7_2})
		3'b000: p = {up, dw, 1'b0, 1'b0, a, st};
		3'b001: p = {up, dw, lf, rg, b, c};
		3'b010: p = {up, dw, 1'b0, 1'b0, a, st};
		3'b011: p = {up, dw, lf, rg, b, c};
		3'b100: p = {1'b0, 1'b0, 1'b0, 1'b0, a, st};
		3'b101: p = {up, dw, lf, rg, b, c};
		3'b110: p = {hm, 1'b1, 1'b1, 1'b1, a, st};
		3'b111: p = {z, y, x, md, 1'b1, 1'b1};
	endcase
end

endmodule