data/full_repos/permissive/113002755/verilog/asteroid_8x8.v
1: b'%Error: data/full_repos/permissive/113002755/verilog/asteroid_8x8.v:38: Cannot find file containing module: \'asteroidSprites\'\nasteroidSprites as\n^~~~~~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/113002755/verilog,data/full_repos/permissive/113002755/asteroidSprites\n             data/full_repos/permissive/113002755/verilog,data/full_repos/permissive/113002755/asteroidSprites.v\n             data/full_repos/permissive/113002755/verilog,data/full_repos/permissive/113002755/asteroidSprites.sv\n             asteroidSprites\n             asteroidSprites.v\n             asteroidSprites.sv\n             obj_dir/asteroidSprites\n             obj_dir/asteroidSprites.v\n             obj_dir/asteroidSprites.sv\n%Warning-WIDTH: data/full_repos/permissive/113002755/verilog/asteroid_8x8.v:130: Operator ASSIGNW expects 5 bits on the Assign RHS, but Assign RHS\'s SUB generates 11 bits.\n                                                                               : ... In instance asteroid_8x8\nassign col = iVGA_X - pos_X;\n           ^\n                ... Use "/* verilator lint_off WIDTH */" and lint_on around source to disable this message.\n%Warning-WIDTH: data/full_repos/permissive/113002755/verilog/asteroid_8x8.v:133: Operator ASSIGNW expects 5 bits on the Assign RHS, but Assign RHS\'s SUB generates 11 bits.\n                                                                               : ... In instance asteroid_8x8\nassign row = iVGA_Y - pos_Y;\n           ^\n%Warning-WIDTH: data/full_repos/permissive/113002755/verilog/asteroid_8x8.v:147: Operator ASSIGN expects 11 bits on the Assign RHS, but Assign RHS\'s CONST \'10\'h3ff\' generates 10 bits.\n                                                                               : ... In instance asteroid_8x8\n pos_X = 10\'b1111111111;\n       ^\n%Warning-WIDTH: data/full_repos/permissive/113002755/verilog/asteroid_8x8.v:148: Operator ASSIGN expects 11 bits on the Assign RHS, but Assign RHS\'s CONST \'10\'h3ff\' generates 10 bits.\n                                                                               : ... In instance asteroid_8x8\n pos_Y = 10\'b1111111111;\n       ^\n%Warning-WIDTH: data/full_repos/permissive/113002755/verilog/asteroid_8x8.v:175: Operator ASSIGN expects 11 bits on the Assign RHS, but Assign RHS\'s CONST \'10\'h3ff\' generates 10 bits.\n                                                                               : ... In instance asteroid_8x8\n  pos_X = 10\'b1111111111;\n        ^\n%Warning-WIDTH: data/full_repos/permissive/113002755/verilog/asteroid_8x8.v:176: Operator ASSIGN expects 11 bits on the Assign RHS, but Assign RHS\'s CONST \'10\'h3ff\' generates 10 bits.\n                                                                               : ... In instance asteroid_8x8\n  pos_Y = 10\'b1111111111;\n        ^\n%Warning-WIDTH: data/full_repos/permissive/113002755/verilog/asteroid_8x8.v:182: Operator ASSIGN expects 11 bits on the Assign RHS, but Assign RHS\'s CONST \'10\'h3ff\' generates 10 bits.\n                                                                               : ... In instance asteroid_8x8\n  pos_X = 10\'b1111111111;\n        ^\n%Warning-WIDTH: data/full_repos/permissive/113002755/verilog/asteroid_8x8.v:183: Operator ASSIGN expects 11 bits on the Assign RHS, but Assign RHS\'s CONST \'10\'h3ff\' generates 10 bits.\n                                                                               : ... In instance asteroid_8x8\n  pos_Y = 10\'b1111111111;\n        ^\n%Warning-WIDTH: data/full_repos/permissive/113002755/verilog/asteroid_8x8.v:222: Operator ADD expects 11 bits on the RHS, but RHS\'s CONST \'3\'h5\' generates 3 bits.\n                                                                               : ... In instance asteroid_8x8\n     pos_X = pos_X + 3\'b101;\n                   ^\n%Warning-WIDTH: data/full_repos/permissive/113002755/verilog/asteroid_8x8.v:238: Operator ADD expects 11 bits on the RHS, but RHS\'s CONST \'3\'h5\' generates 3 bits.\n                                                                               : ... In instance asteroid_8x8\n     pos_Y = pos_Y + 3\'b101;\n                   ^\n%Warning-WIDTH: data/full_repos/permissive/113002755/verilog/asteroid_8x8.v:187: Operator EQ expects 11 bits on the RHS, but RHS\'s CONST \'10\'h3ff\' generates 10 bits.\n                                                                               : ... In instance asteroid_8x8\n  if(pos_X == 10\'b1111111111)\n           ^~\n%Warning-WIDTH: data/full_repos/permissive/113002755/verilog/asteroid_8x8.v:259: Operator ASSIGN expects 11 bits on the Assign RHS, but Assign RHS\'s CONST \'10\'h3ff\' generates 10 bits.\n                                                                               : ... In instance asteroid_8x8\n  pos_X = 10\'b1111111111;\n        ^\n%Warning-WIDTH: data/full_repos/permissive/113002755/verilog/asteroid_8x8.v:260: Operator ASSIGN expects 11 bits on the Assign RHS, but Assign RHS\'s CONST \'10\'h3ff\' generates 10 bits.\n                                                                               : ... In instance asteroid_8x8\n  pos_Y = 10\'b1111111111;\n        ^\n%Error: Exiting due to 1 error(s), 13 warning(s)\n'
module asteroid_8x8 (
	iRst,
	iMemClk,
	iPClk,

	iDir,
	iPosX,
	iPosY,
	iFireAsteroid,
	iCollision,
	iTorpColl,

	iSize,
	iVGA_X,
	iVGA_Y,
	oDrawPixel,
	oFiring,
	oCntPoints
);





asteroidSprites as
(  
	tAddr,
	iMemClk,
	current
);

input [2:0]		iDir;
input [10:0]	iPosX;
input [10:0]	iPosY;
input 			iMemClk;
input				iPClk;
input 			iRst;
input [10:0]	iVGA_X;
input [10:0]	iVGA_Y;
input				iFireAsteroid;
input 			iCollision;
input				iTorpColl;
input	[1:0]		iSize;

output			oDrawPixel;
output			oFiring;
output			oCntPoints;
reg oCntPoints;

reg fired;
wire firing;
reg done;
reg [2:0]	direction;
reg [10:0]	init_pos_X;
reg [10:0]	init_pos_Y;
reg [10:0]	pos_X;
reg [10:0]	pos_Y;
reg [1:0]	size;


reg collided;
reg rstCollided;

wire didCollide;
reg collision;

assign didCollide = collided ^ rstCollided;

always@( negedge iPClk)
begin
	if(iCollision == 1 && oDrawPixel == 1)
	begin
		collision = 1;
		if(iTorpColl == 1)
		begin
			oCntPoints = 1'b1;
		end
		else
		begin
		end
	end
	else
	begin
		collision = 0;
		oCntPoints = 1'b0;
	end
end


always@(posedge collision)
begin
	collided = ~collided;
end


assign firing = fired ^ done;
assign oFiring = firing;

always@(posedge iFireAsteroid)
begin
	if(!firing)
	begin
		direction = iDir;
		init_pos_X = iPosX;
		init_pos_Y = iPosY;
		fired = ~fired;
		size = iSize%3;
	end
	else
	begin
	end
end

wire				oDrawPixel;

wire [4:0] col;
assign col = iVGA_X - pos_X;

wire [4:0] row;
assign row = iVGA_Y - pos_Y;

wire inPosition;
assign inPosition = ((iVGA_X - pos_X)) < 20 && ((iVGA_Y - pos_Y) < 20);

wire drawAsteroid;
assign drawAsteroid = inPosition && firing;

assign oDrawPixel = (drawAsteroid) ? current[col] : 0 ;

initial
begin
	fired = 0;
	done = 0;
	pos_X = 10'b1111111111;
	pos_Y = 10'b1111111111;
end

wire	[5:0]  tAddr;
wire  [19:0] current;
reg [18:0] cnt;

assign tAddr =  (size * 20) + row;

always@(posedge iMemClk or negedge iRst)
begin
	if(!iRst)
	begin
		if(didCollide)
		begin
			rstCollided = ~rstCollided;
		end
		else
		begin
		end
		if(firing)
		begin
			done = ~done;
		end
		else
		begin
		end
		pos_X = 10'b1111111111;
		pos_Y = 10'b1111111111;
	end
	else if(didCollide)
	begin
		rstCollided = ~rstCollided;
		done = ~done;
		pos_X = 10'b1111111111;
		pos_Y = 10'b1111111111;
	end
	else if(firing)
	begin
		if(pos_X == 10'b1111111111)
		begin
			pos_X = init_pos_X;
			pos_Y = init_pos_Y;
			cnt = 0;
		end
		else
		begin
			cnt = cnt + 1'b1;
			if (cnt == 0)
			begin
				case (direction)
					3'b000 :  pos_Y = pos_Y - 1'b1;
					3'b001 :  pos_Y = pos_Y - 1'b1;
					3'b010 :  pos_Y = pos_Y;
					3'b011 :  pos_Y = pos_Y + 1'b1;
					3'b100 :  pos_Y = pos_Y + 1'b1;
					3'b101 :  pos_Y = pos_Y + 1'b1;
					3'b110 :  pos_Y = pos_Y;
					3'b111 :  pos_Y = pos_Y - 1'b1;				
				endcase
				
				case (direction)
					3'b000 :  pos_X = pos_X;
					3'b001 :  pos_X = pos_X - 1'b1;
					3'b010 :  pos_X = pos_X - 1'b1;
					3'b011 :  pos_X = pos_X - 1'b1;
					3'b100 :  pos_X = pos_X;
					3'b101 :  pos_X = pos_X + 1'b1;
					3'b110 :  pos_X = pos_X + 1'b1;
					3'b111 :  pos_X = pos_X + 1'b1;				
				endcase

				if(pos_Y > 480)
				begin
					pos_X = pos_X + 3'b101;
					if(direction == 1 || direction == 7)
					begin
						pos_Y = 479;
					end
					else
					begin
						pos_Y = 1;
					end
				end
				else
				begin
				end
				
				if(pos_X > 640)
				begin
					pos_Y = pos_Y + 3'b101;
					if(direction == 1 || direction == 3)
					begin
						pos_X = 639;
					end
					else
					begin
						pos_X = 1;
					end
				end
				else
				begin
				end
			end
			else
			begin
			end
		end
	end
	else
	begin
		pos_X = 10'b1111111111;
		pos_Y = 10'b1111111111;
	end
end

endmodule
module asteroid_8x8 (
	iRst,
	iMemClk,
	iPClk,

	iDir,
	iPosX,
	iPosY,
	iFireAsteroid,
	iCollision,
	iTorpColl,

	iSize,
	iVGA_X,
	iVGA_Y,
	oDrawPixel,
	oFiring,
	oCntPoints
);






asteroidSprites as
(  
	tAddr,
	iMemClk,
	current
);

input [2:0]		iDir;
input [10:0]	iPosX;
input [10:0]	iPosY;
input 			iMemClk;
input				iPClk;
input 			iRst;
input [10:0]	iVGA_X;
input [10:0]	iVGA_Y;
input				iFireAsteroid;
input 			iCollision;
input				iTorpColl;
input	[1:0]		iSize;

output			oDrawPixel;
output			oFiring;
output			oCntPoints;
reg oCntPoints;

reg fired;
wire firing;
reg done;
reg [2:0]	direction;
reg [10:0]	init_pos_X;
reg [10:0]	init_pos_Y;
reg [10:0]	pos_X;
reg [10:0]	pos_Y;
reg [1:0]	size;


reg collided;
reg rstCollided;

wire didCollide;
reg collision;

assign didCollide = collided ^ rstCollided;

always@( negedge iPClk)
begin
	if(iCollision == 1 && oDrawPixel == 1)
	begin
		collision = 1;
		if(iTorpColl == 1)
		begin
			oCntPoints = 1'b1;
		end
		else
		begin
		end
	end
	else
	begin
		collision = 0;
		oCntPoints = 1'b0;
	end
end


always@(posedge collision)
begin
	collided = ~collided;
end


assign firing = fired ^ done;
assign oFiring = firing;

always@(posedge iFireAsteroid)
begin
	if(!firing)
	begin
		direction = iDir;
		init_pos_X = iPosX;
		init_pos_Y = iPosY;
		fired = ~fired;
		size = iSize%3;
	end
	else
	begin
	end
end

wire				oDrawPixel;

wire [4:0] col;
assign col = iVGA_X - pos_X;

wire [4:0] row;
assign row = iVGA_Y - pos_Y;

wire inPosition;
assign inPosition = ((iVGA_X - pos_X)) < 20 && ((iVGA_Y - pos_Y) < 20);

wire drawAsteroid;
assign drawAsteroid = inPosition && firing;

assign oDrawPixel = (drawAsteroid) ? current[col] : 0 ;

initial
begin
	fired = 0;
	done = 0;
	pos_X = 10'b1111111111;
	pos_Y = 10'b1111111111;
end

wire	[5:0]  tAddr;
wire  [19:0] current;
reg [18:0] cnt;

assign tAddr =  (size * 20) + row;

always@(posedge iMemClk or negedge iRst)
begin
	if(!iRst)
	begin
		if(didCollide)
		begin
			rstCollided = ~rstCollided;
		end
		else
		begin
		end
		if(firing)
		begin
			done = ~done;
		end
		else
		begin
		end
		pos_X = 10'b1111111111;
		pos_Y = 10'b1111111111;
	end
	else if(didCollide)
	begin
		rstCollided = ~rstCollided;
		done = ~done;
		pos_X = 10'b1111111111;
		pos_Y = 10'b1111111111;
	end
	else if(firing)
	begin
		if(pos_X == 10'b1111111111)
		begin
			pos_X = init_pos_X;
			pos_Y = init_pos_Y;
			cnt = 0;
		end
		else
		begin
			cnt = cnt + 1'b1;
			if (cnt == 0)
			begin
				case (direction)
					3'b000 :  pos_Y = pos_Y - 1'b1;
					3'b001 :  pos_Y = pos_Y - 1'b1;
					3'b010 :  pos_Y = pos_Y;
					3'b011 :  pos_Y = pos_Y + 1'b1;
					3'b100 :  pos_Y = pos_Y + 1'b1;
					3'b101 :  pos_Y = pos_Y + 1'b1;
					3'b110 :  pos_Y = pos_Y;
					3'b111 :  pos_Y = pos_Y - 1'b1;				
				endcase
				
				case (direction)
					3'b000 :  pos_X = pos_X;
					3'b001 :  pos_X = pos_X - 1'b1;
					3'b010 :  pos_X = pos_X - 1'b1;
					3'b011 :  pos_X = pos_X - 1'b1;
					3'b100 :  pos_X = pos_X;
					3'b101 :  pos_X = pos_X + 1'b1;
					3'b110 :  pos_X = pos_X + 1'b1;
					3'b111 :  pos_X = pos_X + 1'b1;				
				endcase

				if(pos_Y > 480)
				begin
					pos_X = pos_X + 3'b101;
					if(direction == 1 || direction == 7)
					begin
						pos_Y = 479;
					end
					else
					begin
						pos_Y = 1;
					end
				end
				else
				begin
				end
				
				if(pos_X > 640)
				begin
					pos_Y = pos_Y + 3'b101;
					if(direction == 1 || direction == 3)
					begin
						pos_X = 639;
					end
					else
					begin
						pos_X = 1;
					end
				end
				else
				begin
				end
			end
			else
			begin
			end
		end
	end
	else
	begin
		pos_X = 10'b1111111111;
		pos_Y = 10'b1111111111;
	end
end

endmodule