data/full_repos/permissive/461620575/Galaga on FPGA/ALU/alutest_colton.v
1: b'%Error: Cannot find file containing module: on\n        ... Looked in:\n             data/full_repos/permissive/461620575/Galaga/on\n             data/full_repos/permissive/461620575/Galaga/on.v\n             data/full_repos/permissive/461620575/Galaga/on.sv\n             on\n             on.v\n             on.sv\n             obj_dir/on\n             obj_dir/on.v\n             obj_dir/on.sv\n%Error: Cannot find file containing module: FPGA/ALU,data/full_repos/permissive/461620575\n%Error: Cannot find file containing module: data/full_repos/permissive/461620575/Galaga\n%Error: Cannot find file containing module: FPGA/ALU/alutest_colton.v\n%Error: Exiting due to 4 error(s)\n'
module alutest_colton;


	reg [15:0] A;
	reg [15:0] B;
	reg [7:0] Opcode;
	

	wire [15:0] C;
	wire [4:0] Flags;

	integer i;
		

	alu uut (
		.A(A), 
		.B(B), 
		.C(C), 
		.Opcode(Opcode), 
		.Flags(Flags)
	);

	initial 
		begin
		
		$monitor("A: 0x%0h (%0d), B: 0x%0h (%0d), C: 0x%0h (%0d), Flags[4:0]: %b, time:%0d", A, $signed(A), B, $signed(B), C, $signed(C), Flags[4:0], $time );

		

		A = 0;
		B = 0;
		Opcode = 8'b00000101;
		
		
		$display("\nTesting ADD instruction\n");
		
		#10;
	

		for( i = 0; i< 10; i = i + 1)
		begin
			#10;
			A = $random % 65536;
			B = $random % 65536;
		end
		
		#100;
		$display("\nTesting ADDI instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b0101xxxx;
		
		#10;
		

		for( i = 0; i< 10; i = i + 1)
		begin
			#10;
			A = $random % 65536;
			B = {$random} % 256;
		end
		
		
		



		
		#100;
		$display("\nTesting ADDU instruction\n");
	
		A = 0;
		B = 0;
		Opcode = 8'b00000110;
		#10;
		
		

		for( i = 0; i< 10; i = i + 1)
		begin
			#10;
			A = $random % 65536;
			B = $random % 65536;
		end
		
		#100;
		$display("\nTesting ADDUI instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b0110xxxx;
		#10;
		

		for( i = 0; i< 10; i = i + 1)
		begin
			#10;
			A = $random % 65536;
			B = {$random} % 256;
		end
		
		#100;
		$display("\nTesting ADDC instrtruction\n");
		
	
		A = 0;
		B = 0;
		Opcode = 8'b00000111;
		#10;
		
		A = 16'hFFFF;
		B = 16'hFFFF;
		#10;
		
		A = 16'b0;
		B = 16'b0;
		
		#10;
		
		

		for( i = 0; i< 10; i = i + 1)
		begin
			#10;
			A = $random % 65536;
			B = $random % 65536;
		end
		

		#100;
		$display("\nTesting ADDCI instruction\n");
		
			
		A = 0;
		B = 0;
		Opcode = 8'b0111xxxx;
		#10;
		
		
		A = 16'hFFFF;
		B = 16'd10;
		
		#10;
		
		A = 16'b0;
		B = 16'b0;
		
		#10;
		

		for( i = 0; i< 10; i = i + 1)
		begin
			#10;
			A = $random % 65536;
			B = {$random} % 256;
		end
		
		
		#100;
		$display("\nTesting SUB instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b00001001;
		
		#10;
		

		A = 0;
		B = 1;
		
		#10;		
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = $random % 65536;
			#10;
		end
		
		#100;
		$display("\nTesting SUBI instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b1001xxxx;
		
		#10;
		

		A = 0;
		B = 1;
		
		#10;	
	

		A = 16'h7FFF;
		B = -1;
		
		#10
		
	
		A = 16'h8000;
		B = 1;
		
		#10
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = {$random} % 256;
			#10;
		end
		
		
		
		#100;
		$display("\nTesting SUBC instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b00001010;
		
		#10;
		A = 16'h0001;
		B = 16'hFFFF;
		
		#10;
		
		A = 16'b0;
		B = 16'b0;
		
		#10;
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = $random % 65536;
			#10;
		end
		
		#100;
		$display("\nTesting SUBCI instruction\n");
		
		A = 0;
		B = 0;
		Opcode = 8'b1010xxxx;
		
		#10;
		A = 16'h0001;
		B = 16'hFFFF;
		
		#10;
		
		A = 16'b0;
		B = 16'b0;
		
		#10;		
		
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = {$random} % 256;
			#10;
		end
		
		
		#100;
		$display("\nTesting CMP instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b00001011;
		
		#10
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = $random % 65536;
			#10;
		end
		
		#100;
		$display("\nTesting CMPI instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b1011xxxx;
		
		#10
		

		A = 10;
		B = 20;
		
		#10
		
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = {$random} % 256;
			#10;
		end
		
		#100;
		$display("\nTesting AND instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b00000001;
		
		#10
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = $random % 65536;
			#10;
		end
		
		#100;
		$display("\nTesting ANDI instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b0001xxxx;
		
		#10
		
		
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = {$random} % 256;
			#10;
		end
		
		
		
		#100;
		$display("\nTesting OR instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b00000010;
		
		#10
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = $random % 65536;
			#10;
		end
		
		#100;
		$display("\nTesting ORI instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b0010xxxx;
		
		#10
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = {$random} % 256;
			#10;
		end
		
		
		#100;
		$display("\nTesting XOR instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b00000011;
		
		#10
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = $random % 65536;
			#10;
		end
		
		#100;
		$display("\nTesting XORI instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b0011xxxx;
		
		#10
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = {$random} % 256;
			#10;
		end
		
		#100;
		$display("\nTesting MOV instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b00001101;
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = $random % 65536;
			#10;
		end
		
		#100;
		$display("\nTesting MOVI instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b1101xxxx;
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = {$random} % 256;
			#10;
		end
		
		
		#100;
		$display("\nTesting LUI instruction\n");
				
		A = 0;
		B = 0;
		Opcode = 8'b1111xxxx;
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = {$random} % 256;
			#10;
		end
		
		
		#100;
		$display("\nTesting LSH instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b10000100;
		#10;
		
		


		A = 16'h2b2b;
		B = 1;
		#10;
		


		A = 16'h2b2b;
		B = -1;
		#10;
		


		A = 16'hAAAA;
		B = 1;
		#10;
		


		A = 16'hAAAA;
		B = -1;
		#10;
		
		


		A = 16'hFFFF;
		B = 0;
		#10;
		

		A = 4;
		B = 5;
		#10;
		

		A = 100;
		B = -2;
		#10;
		
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B[15:4] = -({$random} % 2);
			B[3:0] = {$random} % 16;
			#10;
		end
		
		
		#100;
		$display("\nTesting LSHI instruction\n");
		
		
		A = 0;
		B = 0;



		Opcode = 8'b10000000; 		
		#10;
		

		Opcode = 8'b10000000;
		A = 8;
		B = 2;

		#10;
		

		Opcode = 8'b10000001;
		A = 16'hFFFF;
		B = 16'h000F;
		#10;
		
		

		for( i = 0; i< 10; i = i + 1)
		begin
			Opcode[0] = {$random} % 2;
			$display("Shift: %0b", Opcode[0]);
			A = $random % 65536;
			B = ({$random} % 3) + 1'b1;
			#10;
			
		end
		
		for( i = 0; i< 10; i = i + 1)
		begin
			Opcode[0] = $random % 2;
			$display("Shift: %0b", Opcode[0]);
			A = $random % 65536;
			B = {$random} % 16;
			#10;
			
		end
		
		#100;
		$display("\nTesting ASHU instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b10000110;
		#10;
		
		A = 16'h8000;
		B = 16'h3;
		#10;
		
		A = 16'h8000;
		B = -(16'd3);
		#10;
		

		A = 16'hFFFF;
		B = 16'hFFFF;
		#10; 
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = $random % 16;
			#10;
		end
		
		#100;
		$display("\nTesting ASHUI instruction\n");
			

		A = 0;
		B = 0;
		Opcode = 8'b10000010;
		#10;
		
		A = 16'h8000;
		B = 16'h3;
		#10;
		
		Opcode = 8'b10000011;
		A = 16'h8000;
		B = (16'd3);
		#10;
		
		A = 16'hEE0E;
		B = 16'h0001;
		
		#10;
		Opcode = 8'b10000010;				
				

		for( i = 0; i< 10; i = i + 1)
		begin
			Opcode[0] = $random % 2;
			$display("Shift: %0b", Opcode[0]);
			A = $random % 65536;
			B = ({$random} % 3) + 1'b1;
			#10;
			
		end
		
		for( i = 0; i< 10; i = i + 1)
		begin
			Opcode[0] = $random % 2;
			$display("Shift: %0b", Opcode[0]);
			A = $random % 65536;
			B = {$random} % 16;
			#10;
			
		end
		
		$finish(2);
		

	end
      
endmodule
module alutest_colton;



	reg [15:0] A;
	reg [15:0] B;
	reg [7:0] Opcode;
	

	wire [15:0] C;
	wire [4:0] Flags;

	integer i;
		

	alu uut (
		.A(A), 
		.B(B), 
		.C(C), 
		.Opcode(Opcode), 
		.Flags(Flags)
	);

	initial 
		begin
		
		$monitor("A: 0x%0h (%0d), B: 0x%0h (%0d), C: 0x%0h (%0d), Flags[4:0]: %b, time:%0d", A, $signed(A), B, $signed(B), C, $signed(C), Flags[4:0], $time );

		

		A = 0;
		B = 0;
		Opcode = 8'b00000101;
		
		
		$display("\nTesting ADD instruction\n");
		
		#10;
	

		for( i = 0; i< 10; i = i + 1)
		begin
			#10;
			A = $random % 65536;
			B = $random % 65536;
		end
		
		#100;
		$display("\nTesting ADDI instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b0101xxxx;
		
		#10;
		

		for( i = 0; i< 10; i = i + 1)
		begin
			#10;
			A = $random % 65536;
			B = {$random} % 256;
		end
		
		
		



		
		#100;
		$display("\nTesting ADDU instruction\n");
	
		A = 0;
		B = 0;
		Opcode = 8'b00000110;
		#10;
		
		

		for( i = 0; i< 10; i = i + 1)
		begin
			#10;
			A = $random % 65536;
			B = $random % 65536;
		end
		
		#100;
		$display("\nTesting ADDUI instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b0110xxxx;
		#10;
		

		for( i = 0; i< 10; i = i + 1)
		begin
			#10;
			A = $random % 65536;
			B = {$random} % 256;
		end
		
		#100;
		$display("\nTesting ADDC instrtruction\n");
		
	
		A = 0;
		B = 0;
		Opcode = 8'b00000111;
		#10;
		
		A = 16'hFFFF;
		B = 16'hFFFF;
		#10;
		
		A = 16'b0;
		B = 16'b0;
		
		#10;
		
		

		for( i = 0; i< 10; i = i + 1)
		begin
			#10;
			A = $random % 65536;
			B = $random % 65536;
		end
		

		#100;
		$display("\nTesting ADDCI instruction\n");
		
			
		A = 0;
		B = 0;
		Opcode = 8'b0111xxxx;
		#10;
		
		
		A = 16'hFFFF;
		B = 16'd10;
		
		#10;
		
		A = 16'b0;
		B = 16'b0;
		
		#10;
		

		for( i = 0; i< 10; i = i + 1)
		begin
			#10;
			A = $random % 65536;
			B = {$random} % 256;
		end
		
		
		#100;
		$display("\nTesting SUB instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b00001001;
		
		#10;
		

		A = 0;
		B = 1;
		
		#10;		
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = $random % 65536;
			#10;
		end
		
		#100;
		$display("\nTesting SUBI instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b1001xxxx;
		
		#10;
		

		A = 0;
		B = 1;
		
		#10;	
	

		A = 16'h7FFF;
		B = -1;
		
		#10
		
	
		A = 16'h8000;
		B = 1;
		
		#10
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = {$random} % 256;
			#10;
		end
		
		
		
		#100;
		$display("\nTesting SUBC instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b00001010;
		
		#10;
		A = 16'h0001;
		B = 16'hFFFF;
		
		#10;
		
		A = 16'b0;
		B = 16'b0;
		
		#10;
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = $random % 65536;
			#10;
		end
		
		#100;
		$display("\nTesting SUBCI instruction\n");
		
		A = 0;
		B = 0;
		Opcode = 8'b1010xxxx;
		
		#10;
		A = 16'h0001;
		B = 16'hFFFF;
		
		#10;
		
		A = 16'b0;
		B = 16'b0;
		
		#10;		
		
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = {$random} % 256;
			#10;
		end
		
		
		#100;
		$display("\nTesting CMP instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b00001011;
		
		#10
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = $random % 65536;
			#10;
		end
		
		#100;
		$display("\nTesting CMPI instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b1011xxxx;
		
		#10
		

		A = 10;
		B = 20;
		
		#10
		
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = {$random} % 256;
			#10;
		end
		
		#100;
		$display("\nTesting AND instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b00000001;
		
		#10
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = $random % 65536;
			#10;
		end
		
		#100;
		$display("\nTesting ANDI instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b0001xxxx;
		
		#10
		
		
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = {$random} % 256;
			#10;
		end
		
		
		
		#100;
		$display("\nTesting OR instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b00000010;
		
		#10
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = $random % 65536;
			#10;
		end
		
		#100;
		$display("\nTesting ORI instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b0010xxxx;
		
		#10
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = {$random} % 256;
			#10;
		end
		
		
		#100;
		$display("\nTesting XOR instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b00000011;
		
		#10
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = $random % 65536;
			#10;
		end
		
		#100;
		$display("\nTesting XORI instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b0011xxxx;
		
		#10
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = {$random} % 256;
			#10;
		end
		
		#100;
		$display("\nTesting MOV instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b00001101;
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = $random % 65536;
			#10;
		end
		
		#100;
		$display("\nTesting MOVI instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b1101xxxx;
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = {$random} % 256;
			#10;
		end
		
		
		#100;
		$display("\nTesting LUI instruction\n");
				
		A = 0;
		B = 0;
		Opcode = 8'b1111xxxx;
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = {$random} % 256;
			#10;
		end
		
		
		#100;
		$display("\nTesting LSH instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b10000100;
		#10;
		
		


		A = 16'h2b2b;
		B = 1;
		#10;
		


		A = 16'h2b2b;
		B = -1;
		#10;
		


		A = 16'hAAAA;
		B = 1;
		#10;
		


		A = 16'hAAAA;
		B = -1;
		#10;
		
		


		A = 16'hFFFF;
		B = 0;
		#10;
		

		A = 4;
		B = 5;
		#10;
		

		A = 100;
		B = -2;
		#10;
		
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B[15:4] = -({$random} % 2);
			B[3:0] = {$random} % 16;
			#10;
		end
		
		
		#100;
		$display("\nTesting LSHI instruction\n");
		
		
		A = 0;
		B = 0;



		Opcode = 8'b10000000; 		
		#10;
		

		Opcode = 8'b10000000;
		A = 8;
		B = 2;

		#10;
		

		Opcode = 8'b10000001;
		A = 16'hFFFF;
		B = 16'h000F;
		#10;
		
		

		for( i = 0; i< 10; i = i + 1)
		begin
			Opcode[0] = {$random} % 2;
			$display("Shift: %0b", Opcode[0]);
			A = $random % 65536;
			B = ({$random} % 3) + 1'b1;
			#10;
			
		end
		
		for( i = 0; i< 10; i = i + 1)
		begin
			Opcode[0] = $random % 2;
			$display("Shift: %0b", Opcode[0]);
			A = $random % 65536;
			B = {$random} % 16;
			#10;
			
		end
		
		#100;
		$display("\nTesting ASHU instruction\n");
		
		
		A = 0;
		B = 0;
		Opcode = 8'b10000110;
		#10;
		
		A = 16'h8000;
		B = 16'h3;
		#10;
		
		A = 16'h8000;
		B = -(16'd3);
		#10;
		

		A = 16'hFFFF;
		B = 16'hFFFF;
		#10; 
		

		for( i = 0; i< 10; i = i + 1)
		begin
			A = $random % 65536;
			B = $random % 16;
			#10;
		end
		
		#100;
		$display("\nTesting ASHUI instruction\n");
			

		A = 0;
		B = 0;
		Opcode = 8'b10000010;
		#10;
		
		A = 16'h8000;
		B = 16'h3;
		#10;
		
		Opcode = 8'b10000011;
		A = 16'h8000;
		B = (16'd3);
		#10;
		
		A = 16'hEE0E;
		B = 16'h0001;
		
		#10;
		Opcode = 8'b10000010;				
				

		for( i = 0; i< 10; i = i + 1)
		begin
			Opcode[0] = $random % 2;
			$display("Shift: %0b", Opcode[0]);
			A = $random % 65536;
			B = ({$random} % 3) + 1'b1;
			#10;
			
		end
		
		for( i = 0; i< 10; i = i + 1)
		begin
			Opcode[0] = $random % 2;
			$display("Shift: %0b", Opcode[0]);
			A = $random % 65536;
			B = {$random} % 16;
			#10;
			
		end
		
		$finish(2);
		

	end
      
endmodule