data/full_repos/permissive/427179968/sensors_input.v
1: b'%Warning-WIDTH: data/full_repos/permissive/427179968/sensors_input.v:15: Operator ADD expects 12 bits on the LHS, but LHS\'s VARREF \'sensor1\' generates 8 bits.\n                                                                       : ... In instance sensors_input\n  sum = sensor1 + sensor2 + sensor3 + sensor4;\n                ^\n                ... Use "/* verilator lint_off WIDTH */" and lint_on around source to disable this message.\n%Warning-WIDTH: data/full_repos/permissive/427179968/sensors_input.v:15: Operator ADD expects 12 bits on the RHS, but RHS\'s VARREF \'sensor2\' generates 8 bits.\n                                                                       : ... In instance sensors_input\n  sum = sensor1 + sensor2 + sensor3 + sensor4;\n                ^\n%Warning-WIDTH: data/full_repos/permissive/427179968/sensors_input.v:15: Operator ADD expects 12 bits on the RHS, but RHS\'s VARREF \'sensor3\' generates 8 bits.\n                                                                       : ... In instance sensors_input\n  sum = sensor1 + sensor2 + sensor3 + sensor4;\n                          ^\n%Warning-WIDTH: data/full_repos/permissive/427179968/sensors_input.v:15: Operator ADD expects 12 bits on the RHS, but RHS\'s VARREF \'sensor4\' generates 8 bits.\n                                                                       : ... In instance sensors_input\n  sum = sensor1 + sensor2 + sensor3 + sensor4;\n                                    ^\n%Warning-WIDTH: data/full_repos/permissive/427179968/sensors_input.v:19: Operator SUB expects 12 bits on the RHS, but RHS\'s VARREF \'sensor1\' generates 8 bits.\n                                                                       : ... In instance sensors_input\n   sum = sum - sensor1;\n             ^\n%Warning-WIDTH: data/full_repos/permissive/427179968/sensors_input.v:20: Operator SUB expects 12 bits on the RHS, but RHS\'s VARREF \'sensor3\' generates 8 bits.\n                                                                       : ... In instance sensors_input\n   sum = sum - sensor3;\n             ^\n%Warning-WIDTH: data/full_repos/permissive/427179968/sensors_input.v:25: Operator SUB expects 12 bits on the RHS, but RHS\'s VARREF \'sensor2\' generates 8 bits.\n                                                                       : ... In instance sensors_input\n   sum = sum - sensor2;\n             ^\n%Warning-WIDTH: data/full_repos/permissive/427179968/sensors_input.v:26: Operator SUB expects 12 bits on the RHS, but RHS\'s VARREF \'sensor4\' generates 8 bits.\n                                                                       : ... In instance sensors_input\n   sum = sum - sensor4;\n             ^\n%Warning-WIDTH: data/full_repos/permissive/427179968/sensors_input.v:36: Operator DIV expects 32 or 12 bits on the RHS, but RHS\'s VARREF \'number_of_sensors\' generates 3 bits.\n                                                                       : ... In instance sensors_input\n    sum = (sum / number_of_sensors) + 1;\n               ^\n%Warning-WIDTH: data/full_repos/permissive/427179968/sensors_input.v:38: Operator DIV expects 12 bits on the RHS, but RHS\'s VARREF \'number_of_sensors\' generates 3 bits.\n                                                                       : ... In instance sensors_input\n    sum = (sum / number_of_sensors);\n               ^\n%Warning-WIDTH: data/full_repos/permissive/427179968/sensors_input.v:44: Operator DIV expects 32 or 12 bits on the RHS, but RHS\'s VARREF \'number_of_sensors\' generates 3 bits.\n                                                                       : ... In instance sensors_input\n    sum = (sum / number_of_sensors) + 1;\n               ^\n%Warning-WIDTH: data/full_repos/permissive/427179968/sensors_input.v:46: Operator DIV expects 12 bits on the RHS, but RHS\'s VARREF \'number_of_sensors\' generates 3 bits.\n                                                                       : ... In instance sensors_input\n    sum = (sum / number_of_sensors);\n               ^\n%Warning-WIDTH: data/full_repos/permissive/427179968/sensors_input.v:52: Operator ASSIGNW expects 8 bits on the Assign RHS, but Assign RHS\'s VARREF \'sum\' generates 12 bits.\n                                                                       : ... In instance sensors_input\n assign height = sum;\n               ^\n%Error: Exiting due to 13 warning(s)\n'
module sensors_input (
   output   [7 : 0]   height,
   input    [7 : 0]   sensor1,
   input    [7 : 0]   sensor2,
   input    [7 : 0]   sensor3,
   input    [7 : 0]   sensor4);

	reg [2:0] number_of_sensors;
	reg [11:0] sum;

	always @(*) begin

		sum = sensor1 + sensor2 + sensor3 + sensor4;
		number_of_sensors = 4;

		if (sensor1  == 0 || sensor3 == 0) begin
			sum = sum - sensor1;
			sum = sum - sensor3;
			number_of_sensors = number_of_sensors - 2;
		end

		if (sensor2  == 0 || sensor4 == 0) begin
			sum = sum - sensor2;
			sum = sum - sensor4;
			number_of_sensors = number_of_sensors - 2;
		end
		
		if (number_of_sensors == 0) begin
			sum = 0;
		end

		if (number_of_sensors == 2) begin
			if (sum[0] == 1) begin
				sum = (sum / number_of_sensors) + 1;
			end else begin
				sum = (sum / number_of_sensors);
			end
		end
		
		if (number_of_sensors == 4) begin
			if (sum[1] == 1) begin
				sum = (sum / number_of_sensors) + 1;
			end else begin
				sum = (sum / number_of_sensors);
			end
		end		
		
	end

	assign height = sum;
	
endmodule
module sensors_input (
   output   [7 : 0]   height,
   input    [7 : 0]   sensor1,
   input    [7 : 0]   sensor2,
   input    [7 : 0]   sensor3,
   input    [7 : 0]   sensor4);


	reg [2:0] number_of_sensors;
	reg [11:0] sum;

	always @(*) begin

		sum = sensor1 + sensor2 + sensor3 + sensor4;
		number_of_sensors = 4;

		if (sensor1  == 0 || sensor3 == 0) begin
			sum = sum - sensor1;
			sum = sum - sensor3;
			number_of_sensors = number_of_sensors - 2;
		end

		if (sensor2  == 0 || sensor4 == 0) begin
			sum = sum - sensor2;
			sum = sum - sensor4;
			number_of_sensors = number_of_sensors - 2;
		end
		
		if (number_of_sensors == 0) begin
			sum = 0;
		end

		if (number_of_sensors == 2) begin
			if (sum[0] == 1) begin
				sum = (sum / number_of_sensors) + 1;
			end else begin
				sum = (sum / number_of_sensors);
			end
		end
		
		if (number_of_sensors == 4) begin
			if (sum[1] == 1) begin
				sum = (sum / number_of_sensors) + 1;
			end else begin
				sum = (sum / number_of_sensors);
			end
		end		
		
	end

	assign height = sum;
	
endmodule