data/full_repos/permissive/179439333/src/sound-module/SampleMixer.v
1: b'%Warning-WIDTH: data/full_repos/permissive/179439333/src/sound-module/SampleMixer.v:32: Operator SUB expects 16 bits on the LHS, but LHS\'s VARREF \'modulationValue\' generates 8 bits.\n                                                                                      : ... In instance SampleMixer\n     mixSample1 = ((~sample1 + 16\'d1) > (((~sample1 + 16\'d1) >> 16\'d6) * (modulationValue - 16\'d64))) ?\n                                                                                          ^\n                ... Use "/* verilator lint_off WIDTH */" and lint_on around source to disable this message.\n%Warning-WIDTH: data/full_repos/permissive/179439333/src/sound-module/SampleMixer.v:33: Operator SUB expects 16 bits on the LHS, but LHS\'s VARREF \'modulationValue\' generates 8 bits.\n                                                                                      : ... In instance SampleMixer\n      ~((~sample1 + 16\'d1) - (((~sample1 + 16\'d1) >> 16\'d6) * (modulationValue - 16\'d64))) + 16\'d1 :\n                                                                               ^\n%Warning-WIDTH: data/full_repos/permissive/179439333/src/sound-module/SampleMixer.v:38: Operator SUB expects 16 bits on the RHS, but RHS\'s VARREF \'modulationValue\' generates 8 bits.\n                                                                                      : ... In instance SampleMixer\n     mixSample1 = ((~sample1 + 16\'d1) > (((~sample1 + 16\'d1) >> 16\'d6) * (16\'d64 - modulationValue))) ?\n                                                                                 ^\n%Warning-WIDTH: data/full_repos/permissive/179439333/src/sound-module/SampleMixer.v:39: Operator SUB expects 16 bits on the RHS, but RHS\'s VARREF \'modulationValue\' generates 8 bits.\n                                                                                      : ... In instance SampleMixer\n      ~((~sample1 + 16\'d1) - (((~sample1 + 16\'d1) >> 16\'d6) * (16\'d64 - modulationValue))) + 16\'d1 :\n                                                                      ^\n%Warning-WIDTH: data/full_repos/permissive/179439333/src/sound-module/SampleMixer.v:47: Operator SUB expects 16 bits on the LHS, but LHS\'s VARREF \'modulationValue\' generates 8 bits.\n                                                                                      : ... In instance SampleMixer\n     mixSample1 = (sample1 > ((sample1 >> 16\'d6) * (modulationValue - 16\'d64))) ?\n                                                                    ^\n%Warning-WIDTH: data/full_repos/permissive/179439333/src/sound-module/SampleMixer.v:48: Operator SUB expects 16 bits on the LHS, but LHS\'s VARREF \'modulationValue\' generates 8 bits.\n                                                                                      : ... In instance SampleMixer\n      (sample1 - ((sample1 >> 16\'d6) * (modulationValue - 16\'d64))) :\n                                                        ^\n%Warning-WIDTH: data/full_repos/permissive/179439333/src/sound-module/SampleMixer.v:53: Operator SUB expects 16 bits on the RHS, but RHS\'s VARREF \'modulationValue\' generates 8 bits.\n                                                                                      : ... In instance SampleMixer\n     mixSample1 = (sample1 > ((sample1 >> 16\'d6) * (16\'d64 - modulationValue))) ?\n                                                           ^\n%Warning-WIDTH: data/full_repos/permissive/179439333/src/sound-module/SampleMixer.v:54: Operator SUB expects 16 bits on the RHS, but RHS\'s VARREF \'modulationValue\' generates 8 bits.\n                                                                                      : ... In instance SampleMixer\n      (sample1 - ((sample1 >> 16\'d6) * (16\'d64 - modulationValue))) :\n                                               ^\n%Warning-WIDTH: data/full_repos/permissive/179439333/src/sound-module/SampleMixer.v:61: Operator SUB expects 16 bits on the RHS, but RHS\'s VARREF \'modulationValue\' generates 8 bits.\n                                                                                      : ... In instance SampleMixer\n   mixSample2 = ((~sample2 + 16\'d1) > (((~sample2 + 16\'d1) >> 16\'d6) * (16\'d127 - modulationValue))) ?\n                                                                                ^\n%Warning-WIDTH: data/full_repos/permissive/179439333/src/sound-module/SampleMixer.v:62: Operator SUB expects 16 bits on the RHS, but RHS\'s VARREF \'modulationValue\' generates 8 bits.\n                                                                                      : ... In instance SampleMixer\n    ~((~sample2 + 16\'d1) - (((~sample2 + 16\'d1) >> 16\'d6) * (16\'d127 - modulationValue))) + 16\'d1 :\n                                                                     ^\n%Warning-WIDTH: data/full_repos/permissive/179439333/src/sound-module/SampleMixer.v:67: Operator SUB expects 16 bits on the RHS, but RHS\'s VARREF \'modulationValue\' generates 8 bits.\n                                                                                      : ... In instance SampleMixer\n   mixSample2 = (sample2 > ((sample2 >> 16\'d6) * (16\'d127 - modulationValue))) ?\n                                                          ^\n%Warning-WIDTH: data/full_repos/permissive/179439333/src/sound-module/SampleMixer.v:68: Operator SUB expects 16 bits on the RHS, but RHS\'s VARREF \'modulationValue\' generates 8 bits.\n                                                                                      : ... In instance SampleMixer\n    (sample2 - ((sample2 >> 16\'d6) * (16\'d127 - modulationValue))) :\n                                              ^\n%Error: Exiting due to 12 warning(s)\n'
module SampleMixer(
	input [15:0] sample0,
	input [15:0] sample1,
	input [15:0] sample2,
	input [7:0] modulationValue,
	output [15:0] renderedSample
);

reg [15:0] mixSample0 = 0;
reg [15:0] mixSample1 = 0;
reg [15:0] mixSample2 = 0;

always @(sample0 or sample1 or sample2 or modulationValue)
begin
	if (sample0[15] == 1'b1)
		begin
			mixSample0 = ((~sample0 + 16'd1) > (((~sample0 + 16'd1) >> 16'd6) * modulationValue)) ?
				~((~sample0 + 16'd1) - (((~sample0 + 16'd1) >> 16'd6) * modulationValue)) + 16'd1 :
				16'd0;
		end
	else
		begin
			mixSample0 = (sample0 > ((sample0 >> 16'd6) * modulationValue)) ?
				(sample0 - ((sample0 >> 16'd6) * modulationValue)) :
				16'd0;
		end
	
	if (sample1[15] == 1'b1)
		begin
			if (modulationValue >= 64)
				begin
					mixSample1 = ((~sample1 + 16'd1) > (((~sample1 + 16'd1) >> 16'd6) * (modulationValue - 16'd64))) ?
						~((~sample1 + 16'd1) - (((~sample1 + 16'd1) >> 16'd6) * (modulationValue - 16'd64))) + 16'd1 :
						16'd0;
				end
			else
				begin
					mixSample1 = ((~sample1 + 16'd1) > (((~sample1 + 16'd1) >> 16'd6) * (16'd64 - modulationValue))) ?
						~((~sample1 + 16'd1) - (((~sample1 + 16'd1) >> 16'd6) * (16'd64 - modulationValue))) + 16'd1 :
						16'd0;
				end
		end
	else
		begin
			if (modulationValue >= 64)
				begin
					mixSample1 = (sample1 > ((sample1 >> 16'd6) * (modulationValue - 16'd64))) ?
						(sample1 - ((sample1 >> 16'd6) * (modulationValue - 16'd64))) :
						16'd0;
				end
			else
				begin
					mixSample1 = (sample1 > ((sample1 >> 16'd6) * (16'd64 - modulationValue))) ?
						(sample1 - ((sample1 >> 16'd6) * (16'd64 - modulationValue))) :
						16'd0;
				end
		end
		
	if (sample2[15] == 1'b1)
		begin
			mixSample2 = ((~sample2 + 16'd1) > (((~sample2 + 16'd1) >> 16'd6) * (16'd127 - modulationValue))) ?
				~((~sample2 + 16'd1) - (((~sample2 + 16'd1) >> 16'd6) * (16'd127 - modulationValue))) + 16'd1 :
				16'd0;
		end
	else
		begin
			mixSample2 = (sample2 > ((sample2 >> 16'd6) * (16'd127 - modulationValue))) ?
				(sample2 - ((sample2 >> 16'd6) * (16'd127 - modulationValue))) :
				16'd0;
		end
end

assign renderedSample = mixSample0 + mixSample1 + mixSample2;

endmodule
module SampleMixer(
	input [15:0] sample0,
	input [15:0] sample1,
	input [15:0] sample2,
	input [7:0] modulationValue,
	output [15:0] renderedSample
);


reg [15:0] mixSample0 = 0;
reg [15:0] mixSample1 = 0;
reg [15:0] mixSample2 = 0;

always @(sample0 or sample1 or sample2 or modulationValue)
begin
	if (sample0[15] == 1'b1)
		begin
			mixSample0 = ((~sample0 + 16'd1) > (((~sample0 + 16'd1) >> 16'd6) * modulationValue)) ?
				~((~sample0 + 16'd1) - (((~sample0 + 16'd1) >> 16'd6) * modulationValue)) + 16'd1 :
				16'd0;
		end
	else
		begin
			mixSample0 = (sample0 > ((sample0 >> 16'd6) * modulationValue)) ?
				(sample0 - ((sample0 >> 16'd6) * modulationValue)) :
				16'd0;
		end
	
	if (sample1[15] == 1'b1)
		begin
			if (modulationValue >= 64)
				begin
					mixSample1 = ((~sample1 + 16'd1) > (((~sample1 + 16'd1) >> 16'd6) * (modulationValue - 16'd64))) ?
						~((~sample1 + 16'd1) - (((~sample1 + 16'd1) >> 16'd6) * (modulationValue - 16'd64))) + 16'd1 :
						16'd0;
				end
			else
				begin
					mixSample1 = ((~sample1 + 16'd1) > (((~sample1 + 16'd1) >> 16'd6) * (16'd64 - modulationValue))) ?
						~((~sample1 + 16'd1) - (((~sample1 + 16'd1) >> 16'd6) * (16'd64 - modulationValue))) + 16'd1 :
						16'd0;
				end
		end
	else
		begin
			if (modulationValue >= 64)
				begin
					mixSample1 = (sample1 > ((sample1 >> 16'd6) * (modulationValue - 16'd64))) ?
						(sample1 - ((sample1 >> 16'd6) * (modulationValue - 16'd64))) :
						16'd0;
				end
			else
				begin
					mixSample1 = (sample1 > ((sample1 >> 16'd6) * (16'd64 - modulationValue))) ?
						(sample1 - ((sample1 >> 16'd6) * (16'd64 - modulationValue))) :
						16'd0;
				end
		end
		
	if (sample2[15] == 1'b1)
		begin
			mixSample2 = ((~sample2 + 16'd1) > (((~sample2 + 16'd1) >> 16'd6) * (16'd127 - modulationValue))) ?
				~((~sample2 + 16'd1) - (((~sample2 + 16'd1) >> 16'd6) * (16'd127 - modulationValue))) + 16'd1 :
				16'd0;
		end
	else
		begin
			mixSample2 = (sample2 > ((sample2 >> 16'd6) * (16'd127 - modulationValue))) ?
				(sample2 - ((sample2 >> 16'd6) * (16'd127 - modulationValue))) :
				16'd0;
		end
end

assign renderedSample = mixSample0 + mixSample1 + mixSample2;

endmodule