data/full_repos/permissive/430260837/movingSquare.v
1: b'%Warning-WIDTH: data/full_repos/permissive/430260837/movingSquare.v:38: Operator GTE expects 33 bits on the LHS, but LHS\'s VARREF \'VCounter\' generates 10 bits.\n                                                                      : ... In instance movingSquare\n  if(VCounter >= top && VCounter <= bottom) begin\n              ^~\n                ... Use "/* verilator lint_off WIDTH */" and lint_on around source to disable this message.\n%Warning-WIDTH: data/full_repos/permissive/430260837/movingSquare.v:38: Operator LTE expects 33 bits on the LHS, but LHS\'s VARREF \'VCounter\' generates 10 bits.\n                                                                      : ... In instance movingSquare\n  if(VCounter >= top && VCounter <= bottom) begin\n                                 ^~\n%Warning-WIDTH: data/full_repos/permissive/430260837/movingSquare.v:52: Operator GTE expects 33 bits on the LHS, but LHS\'s VARREF \'VCounter\' generates 10 bits.\n                                                                      : ... In instance movingSquare\n   if(VCounter >= top && VCounter <= bottom) begin\n               ^~\n%Warning-WIDTH: data/full_repos/permissive/430260837/movingSquare.v:52: Operator LTE expects 33 bits on the LHS, but LHS\'s VARREF \'VCounter\' generates 10 bits.\n                                                                      : ... In instance movingSquare\n   if(VCounter >= top && VCounter <= bottom) begin\n                                  ^~\n%Warning-WIDTH: data/full_repos/permissive/430260837/movingSquare.v:96: Operator ASSIGN expects 33 bits on the Assign RHS, but Assign RHS\'s VARREF \'middle\' generates 10 bits.\n                                                                      : ... In instance movingSquare\n    dH = middle;\n       ^\n%Error: Exiting due to 5 warning(s)\n'
module movingSquare(

	input [9:0] HCounter,
	input [9:0] VCounter,
	input clk,
	input switch,
	input desClock,
	
	input [9:0] middle,
	
	input enable,
	
	input reset,
	
	output reg startDesClock,
	output reg result,
	output reg destroyed,
	output reg [32:0] dH,
	output reg [32:0] dV, 
	output scoreToggle, 
	output healthToggle
	);

	

	
	reg [32:0] top = 33'd35;
	reg [32:0] bottom = 33'd65;
	
	reg [9:0] midSpan = 10'd5;
	reg [9:0] increment = 10'd5;

	reg scoreToggleTemp = 1'b0;
	reg healthToggleTemp = 1'b0;
	
	always @ (HCounter or VCounter) begin 
	if(!enable) begin
		if(VCounter >= top && VCounter <= bottom) begin
			if(HCounter >= (middle - midSpan) && HCounter <= (middle + midSpan)) begin
				result = 1;
			end else begin
				result = 0;
			end
		end else begin 
			result = 0;
		end
	end
	end
	
	always @ (posedge VCounter) begin
		if(!enable) begin
			if(VCounter >= top && VCounter <= bottom) begin

				midSpan <= midSpan + increment;
				increment <= increment - 10'd1;
			end else begin

				midSpan <= 10'd5;
				increment <= 10'd5;
			end
			
			if(bottom == 515) begin 

				healthToggleTemp = 1'b1;
			end
			else begin 
				healthToggleTemp = 1'b0;
			end
		end else begin
			healthToggleTemp = 1'b0;
		end
		if(!reset) begin
			healthToggleTemp = 1'b1;
		end
	end
	
	always @ (posedge clk) begin
		if(!enable && reset) begin

			if(((bottom >= 33'd376 && bottom <= 33'd416) || (top >= 33'd376 && top <= 33'd416)) && switch == 1) begin 
				destroyed <= 1'b1;
				scoreToggleTemp = 1'b1;
			end else begin
				scoreToggleTemp = 1'b0;
			end
			if(desClock == 1) begin
				startDesClock <= 0;
			end

			if((top < 33'd515) && (destroyed == 1'b0)) begin 
				top = top + 33'd1;
				bottom = bottom + 33'd1;
			end 
			else if(destroyed == 1'b1 || (top >= 33'd515))begin

				dH = middle;
				if(destroyed == 1'b1) begin
					dV = top + 33'd15;
				end else begin
					dV = 33'd514;


					
				end
				
				top = 33'd35;
				bottom = 33'd65;
				startDesClock <= 1;
				destroyed <= 1'b0;
			end
		end else begin
			scoreToggleTemp = 1'b0;
		end
		if(!reset) begin
			top = 33'd35;
			bottom = 33'd65;
			scoreToggleTemp = 1'b1;
		end
	end
	
	assign scoreToggle = scoreToggleTemp;
	assign healthToggle = healthToggleTemp;
	
endmodule
module movingSquare(

	input [9:0] HCounter,
	input [9:0] VCounter,
	input clk,
	input switch,
	input desClock,
	
	input [9:0] middle,
	
	input enable,
	
	input reset,
	
	output reg startDesClock,
	output reg result,
	output reg destroyed,
	output reg [32:0] dH,
	output reg [32:0] dV, 
	output scoreToggle, 
	output healthToggle
	);


	

	
	reg [32:0] top = 33'd35;
	reg [32:0] bottom = 33'd65;
	
	reg [9:0] midSpan = 10'd5;
	reg [9:0] increment = 10'd5;

	reg scoreToggleTemp = 1'b0;
	reg healthToggleTemp = 1'b0;
	
	always @ (HCounter or VCounter) begin 
	if(!enable) begin
		if(VCounter >= top && VCounter <= bottom) begin
			if(HCounter >= (middle - midSpan) && HCounter <= (middle + midSpan)) begin
				result = 1;
			end else begin
				result = 0;
			end
		end else begin 
			result = 0;
		end
	end
	end
	
	always @ (posedge VCounter) begin
		if(!enable) begin
			if(VCounter >= top && VCounter <= bottom) begin

				midSpan <= midSpan + increment;
				increment <= increment - 10'd1;
			end else begin

				midSpan <= 10'd5;
				increment <= 10'd5;
			end
			
			if(bottom == 515) begin 

				healthToggleTemp = 1'b1;
			end
			else begin 
				healthToggleTemp = 1'b0;
			end
		end else begin
			healthToggleTemp = 1'b0;
		end
		if(!reset) begin
			healthToggleTemp = 1'b1;
		end
	end
	
	always @ (posedge clk) begin
		if(!enable && reset) begin

			if(((bottom >= 33'd376 && bottom <= 33'd416) || (top >= 33'd376 && top <= 33'd416)) && switch == 1) begin 
				destroyed <= 1'b1;
				scoreToggleTemp = 1'b1;
			end else begin
				scoreToggleTemp = 1'b0;
			end
			if(desClock == 1) begin
				startDesClock <= 0;
			end

			if((top < 33'd515) && (destroyed == 1'b0)) begin 
				top = top + 33'd1;
				bottom = bottom + 33'd1;
			end 
			else if(destroyed == 1'b1 || (top >= 33'd515))begin

				dH = middle;
				if(destroyed == 1'b1) begin
					dV = top + 33'd15;
				end else begin
					dV = 33'd514;


					
				end
				
				top = 33'd35;
				bottom = 33'd65;
				startDesClock <= 1;
				destroyed <= 1'b0;
			end
		end else begin
			scoreToggleTemp = 1'b0;
		end
		if(!reset) begin
			top = 33'd35;
			bottom = 33'd65;
			scoreToggleTemp = 1'b1;
		end
	end
	
	assign scoreToggle = scoreToggleTemp;
	assign healthToggle = healthToggleTemp;
	
endmodule