data/full_repos/permissive/180199545/PlaySound/frequency_generator.v
1: b'%Warning-WIDTH: data/full_repos/permissive/180199545/PlaySound/frequency_generator.v:35: Operator DIV expects 17 bits on the RHS, but RHS\'s VARREF \'frequency\' generates 10 bits.\n                                                                                       : ... In instance frequency_generator\n   max_time = 17\'d100000 / frequency;\n                         ^\n                ... Use "/* verilator lint_off WIDTH */" and lint_on around source to disable this message.\n%Warning-WIDTH: data/full_repos/permissive/180199545/PlaySound/frequency_generator.v:35: Operator ASSIGN expects 10 bits on the Assign RHS, but Assign RHS\'s DIV generates 17 bits.\n                                                                                       : ... In instance frequency_generator\n   max_time = 17\'d100000 / frequency;\n            ^\n%Error: Exiting due to 2 warning(s)\n'
module frequency_generator (
	input reset,
	input sys_clk,
	input [9:0] frequency,
	output Out
	);
	
	reg wave_out;
	reg [9:0] timer;
	reg [9:0] max_time;
	

	always @ (posedge sys_clk)
	begin
		if(reset)
		begin
			wave_out <= 1'b0;
		end
		else
		begin
			max_time = 17'd100000 / frequency;
			timer <= timer + 1;
			if(timer >= max_time)
				begin
					timer <= 10'd0;
					wave_out <= ~wave_out;
				end
		end
	end
	
	assign Out = wave_out;

endmodule
module frequency_generator (
	input reset,
	input sys_clk,
	input [9:0] frequency,
	output Out
	);

	
	reg wave_out;
	reg [9:0] timer;
	reg [9:0] max_time;
	

	always @ (posedge sys_clk)
	begin
		if(reset)
		begin
			wave_out <= 1'b0;
		end
		else
		begin
			max_time = 17'd100000 / frequency;
			timer <= timer + 1;
			if(timer >= max_time)
				begin
					timer <= 10'd0;
					wave_out <= ~wave_out;
				end
		end
	end
	
	assign Out = wave_out;

endmodule