data/full_repos/permissive/149231262/Verilog_pingpong/pong.v
1: b'%Error: data/full_repos/permissive/149231262/Verilog_pingpong/pong.v:14: Cannot find file containing module: \'clk_wiz_0\'\nclk_wiz_0 thepll(.clk_in1(clkl16), .clk_out1(clk), .reset(), .locked());\n^~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/149231262/Verilog_pingpong,data/full_repos/permissive/149231262/clk_wiz_0\n             data/full_repos/permissive/149231262/Verilog_pingpong,data/full_repos/permissive/149231262/clk_wiz_0.v\n             data/full_repos/permissive/149231262/Verilog_pingpong,data/full_repos/permissive/149231262/clk_wiz_0.sv\n             clk_wiz_0\n             clk_wiz_0.v\n             clk_wiz_0.sv\n             obj_dir/clk_wiz_0\n             obj_dir/clk_wiz_0.v\n             obj_dir/clk_wiz_0.sv\n%Error: data/full_repos/permissive/149231262/Verilog_pingpong/pong.v:16: Cannot find file containing module: \'hvsync_generator\'\nhvsync_generator syncgen(.clk(clk), .vga_h_sync(vga_h_sync), .vga_v_sync(vga_v_sync), .inDisplayArea(inDisplayArea), .CounterX(CounterX), .CounterY(CounterY));\n^~~~~~~~~~~~~~~~\n%Warning-WIDTH: data/full_repos/permissive/149231262/Verilog_pingpong/pong.v:65: Operator EQ expects 32 or 7 bits on the LHS, but LHS\'s SEL generates 6 bits.\n                                                                               : ... In instance pong\nwire border = (CounterX[9:3]==0) || (CounterX[9:3]==79) || (CounterY[8:3]==0) || (CounterY[8:3]==99);   \n                                                                                               ^~\n                ... Use "/* verilator lint_off WIDTH */" and lint_on around source to disable this message.\n%Error: Exiting due to 2 error(s), 1 warning(s)\n'
module pong(clkl16, vga_h_sync, vga_v_sync, vga_R, vga_G, vga_B, btn0, btn3);
input clkl16;
output vga_h_sync, vga_v_sync, vga_R, vga_G, vga_B;
input btn0, btn3;

wire inDisplayArea;
wire [9:0] CounterX;
wire [8:0] CounterY;

wire clk;

clk_wiz_0 thepll(.clk_in1(clkl16), .clk_out1(clk), .reset(), .locked());

hvsync_generator syncgen(.clk(clk), .vga_h_sync(vga_h_sync), .vga_v_sync(vga_v_sync), .inDisplayArea(inDisplayArea), .CounterX(CounterX), .CounterY(CounterY));





  
  

reg [8:0] PaddlePosition;
wire btn0;
wire btn3;

reg [19:0] count;
wire countmax = (count==800000);
always @(posedge clk)
begin
if(countmax)
	begin
	count <= 0;
		if(btn0)
		begin
			if(~&PaddlePosition)
				PaddlePosition <= PaddlePosition + 1;
		end
		else if(btn3)
		begin
			if(|PaddlePosition)
				PaddlePosition <= PaddlePosition - 1;
		end
	end
else
	count <= count + 1;
end


reg [9:0] ballX;
reg [8:0] ballY;
reg ball_inX, ball_inY;

always @(posedge clk)
if(ball_inX==0) ball_inX <= (CounterX==ballX) & ball_inY; else ball_inX <= !(CounterX==ballX+16);

always @(posedge clk)
if(ball_inY==0) ball_inY <= (CounterY==ballY); else ball_inY <= !(CounterY==ballY+16);

wire ball = ball_inX & ball_inY;


wire border = (CounterX[9:3]==0) || (CounterX[9:3]==79) || (CounterY[8:3]==0) || (CounterY[8:3]==99);
wire paddle = (CounterX>=PaddlePosition+8) && (CounterX<=PaddlePosition+120) && (CounterY[8:4]==27);
wire BouncingObject = border | paddle;

reg ResetCollision;
always @(posedge clk) ResetCollision <= (CounterY==500) & (CounterX==0);

reg CollisionX1, CollisionX2, CollisionY1, CollisionY2;
always @(posedge clk) if(ResetCollision) CollisionX1<=0; else if(BouncingObject & (CounterX==ballX   ) & (CounterY==ballY+ 8)) CollisionX1<=1;
always @(posedge clk) if(ResetCollision) CollisionX2<=0; else if(BouncingObject & (CounterX==ballX+16) & (CounterY==ballY+ 8)) CollisionX2<=1;
always @(posedge clk) if(ResetCollision) CollisionY1<=0; else if(BouncingObject & (CounterX==ballX+ 8) & (CounterY==ballY   )) CollisionY1<=1;
always @(posedge clk) if(ResetCollision) CollisionY2<=0; else if(BouncingObject & (CounterX==ballX+ 8) & (CounterY==ballY+16)) CollisionY2<=1;


wire UpdateBallPosition = ResetCollision;

reg ball_dirX, ball_dirY;
always @(posedge clk)
if(UpdateBallPosition)
begin
	if(~(CollisionX1 & CollisionX2))
	begin
		ballX <= ballX + (ball_dirX ? -1 : 1);
		if(CollisionX2) ball_dirX <= 1; 
		else if(CollisionX1) ball_dirX <= 0;
	end

	if(~(CollisionY1 & CollisionY2))
	begin
		ballY <= ballY + (ball_dirY ? -1 : 1);
		if(CollisionY2) ball_dirY <= 1;
		else if(CollisionY1) ball_dirY <= 0;
	end
end 


wire R = BouncingObject | ball | (CounterX[3] ^ CounterY[3]);
wire G = BouncingObject | ball;
wire B = BouncingObject | ball;

reg vga_R, vga_G, vga_B;
always @(posedge clk)
begin
	vga_R <= R & inDisplayArea;
	vga_G <= G & inDisplayArea;
	vga_B <= B & inDisplayArea;
end

endmodule
module pong(clkl16, vga_h_sync, vga_v_sync, vga_R, vga_G, vga_B, btn0, btn3);

input clkl16;
output vga_h_sync, vga_v_sync, vga_R, vga_G, vga_B;
input btn0, btn3;

wire inDisplayArea;
wire [9:0] CounterX;
wire [8:0] CounterY;

wire clk;

clk_wiz_0 thepll(.clk_in1(clkl16), .clk_out1(clk), .reset(), .locked());

hvsync_generator syncgen(.clk(clk), .vga_h_sync(vga_h_sync), .vga_v_sync(vga_v_sync), .inDisplayArea(inDisplayArea), .CounterX(CounterX), .CounterY(CounterY));





  
  

reg [8:0] PaddlePosition;
wire btn0;
wire btn3;

reg [19:0] count;
wire countmax = (count==800000);
always @(posedge clk)
begin
if(countmax)
	begin
	count <= 0;
		if(btn0)
		begin
			if(~&PaddlePosition)
				PaddlePosition <= PaddlePosition + 1;
		end
		else if(btn3)
		begin
			if(|PaddlePosition)
				PaddlePosition <= PaddlePosition - 1;
		end
	end
else
	count <= count + 1;
end


reg [9:0] ballX;
reg [8:0] ballY;
reg ball_inX, ball_inY;

always @(posedge clk)
if(ball_inX==0) ball_inX <= (CounterX==ballX) & ball_inY; else ball_inX <= !(CounterX==ballX+16);

always @(posedge clk)
if(ball_inY==0) ball_inY <= (CounterY==ballY); else ball_inY <= !(CounterY==ballY+16);

wire ball = ball_inX & ball_inY;


wire border = (CounterX[9:3]==0) || (CounterX[9:3]==79) || (CounterY[8:3]==0) || (CounterY[8:3]==99);
wire paddle = (CounterX>=PaddlePosition+8) && (CounterX<=PaddlePosition+120) && (CounterY[8:4]==27);
wire BouncingObject = border | paddle;

reg ResetCollision;
always @(posedge clk) ResetCollision <= (CounterY==500) & (CounterX==0);

reg CollisionX1, CollisionX2, CollisionY1, CollisionY2;
always @(posedge clk) if(ResetCollision) CollisionX1<=0; else if(BouncingObject & (CounterX==ballX   ) & (CounterY==ballY+ 8)) CollisionX1<=1;
always @(posedge clk) if(ResetCollision) CollisionX2<=0; else if(BouncingObject & (CounterX==ballX+16) & (CounterY==ballY+ 8)) CollisionX2<=1;
always @(posedge clk) if(ResetCollision) CollisionY1<=0; else if(BouncingObject & (CounterX==ballX+ 8) & (CounterY==ballY   )) CollisionY1<=1;
always @(posedge clk) if(ResetCollision) CollisionY2<=0; else if(BouncingObject & (CounterX==ballX+ 8) & (CounterY==ballY+16)) CollisionY2<=1;


wire UpdateBallPosition = ResetCollision;

reg ball_dirX, ball_dirY;
always @(posedge clk)
if(UpdateBallPosition)
begin
	if(~(CollisionX1 & CollisionX2))
	begin
		ballX <= ballX + (ball_dirX ? -1 : 1);
		if(CollisionX2) ball_dirX <= 1; 
		else if(CollisionX1) ball_dirX <= 0;
	end

	if(~(CollisionY1 & CollisionY2))
	begin
		ballY <= ballY + (ball_dirY ? -1 : 1);
		if(CollisionY2) ball_dirY <= 1;
		else if(CollisionY1) ball_dirY <= 0;
	end
end 


wire R = BouncingObject | ball | (CounterX[3] ^ CounterY[3]);
wire G = BouncingObject | ball;
wire B = BouncingObject | ball;

reg vga_R, vga_G, vga_B;
always @(posedge clk)
begin
	vga_R <= R & inDisplayArea;
	vga_G <= G & inDisplayArea;
	vga_B <= B & inDisplayArea;
end

endmodule