data/full_repos/permissive/49869849/hardware/src/MPU9250_contoroller.v
1: b'%Error: data/full_repos/permissive/49869849/hardware/src/MPU9250_contoroller.v:22: Cannot find include file: MPU9250_defines.v\n`include "MPU9250_defines.v"  //macros for MPUaddress \n         ^~~~~~~~~~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/49869849/hardware/src,data/full_repos/permissive/49869849/MPU9250_defines.v\n             data/full_repos/permissive/49869849/hardware/src,data/full_repos/permissive/49869849/MPU9250_defines.v.v\n             data/full_repos/permissive/49869849/hardware/src,data/full_repos/permissive/49869849/MPU9250_defines.v.sv\n             MPU9250_defines.v\n             MPU9250_defines.v.v\n             MPU9250_defines.v.sv\n             obj_dir/MPU9250_defines.v\n             obj_dir/MPU9250_defines.v.v\n             obj_dir/MPU9250_defines.v.sv\n%Error: data/full_repos/permissive/49869849/hardware/src/MPU9250_contoroller.v:336: Define or directive not defined: \'`MPU9250_RA_GYRO_XOUT_H\'\n        mpu_address_reg <= `MPU9250_RA_GYRO_XOUT_H;    \n                           ^~~~~~~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/49869849/hardware/src/MPU9250_contoroller.v:336: syntax error, unexpected \';\', expecting TYPE-IDENTIFIER\n        mpu_address_reg <= `MPU9250_RA_GYRO_XOUT_H;    \n                                                  ^\n%Error: data/full_repos/permissive/49869849/hardware/src/MPU9250_contoroller.v:355: Define or directive not defined: \'`MPU9250_RA_GYRO_XOUT_L\'\n        mpu_address_reg <= `MPU9250_RA_GYRO_XOUT_L;    \n                           ^~~~~~~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/49869849/hardware/src/MPU9250_contoroller.v:355: syntax error, unexpected \';\', expecting TYPE-IDENTIFIER\n        mpu_address_reg <= `MPU9250_RA_GYRO_XOUT_L;    \n                                                  ^\n%Error: data/full_repos/permissive/49869849/hardware/src/MPU9250_contoroller.v:377: Define or directive not defined: \'`MPU9250_RA_GYRO_YOUT_H\'\n        mpu_address_reg <= `MPU9250_RA_GYRO_YOUT_H;    \n                           ^~~~~~~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/49869849/hardware/src/MPU9250_contoroller.v:377: syntax error, unexpected \';\', expecting TYPE-IDENTIFIER\n        mpu_address_reg <= `MPU9250_RA_GYRO_YOUT_H;    \n                                                  ^\n%Error: data/full_repos/permissive/49869849/hardware/src/MPU9250_contoroller.v:396: Define or directive not defined: \'`MPU9250_RA_GYRO_YOUT_L\'\n        mpu_address_reg <= `MPU9250_RA_GYRO_YOUT_L;    \n                           ^~~~~~~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/49869849/hardware/src/MPU9250_contoroller.v:396: syntax error, unexpected \';\', expecting TYPE-IDENTIFIER\n        mpu_address_reg <= `MPU9250_RA_GYRO_YOUT_L;    \n                                                  ^\n%Error: data/full_repos/permissive/49869849/hardware/src/MPU9250_contoroller.v:418: Define or directive not defined: \'`MPU9250_RA_GYRO_ZOUT_H\'\n        mpu_address_reg <= `MPU9250_RA_GYRO_ZOUT_H;    \n                           ^~~~~~~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/49869849/hardware/src/MPU9250_contoroller.v:418: syntax error, unexpected \';\', expecting TYPE-IDENTIFIER\n        mpu_address_reg <= `MPU9250_RA_GYRO_ZOUT_H;    \n                                                  ^\n%Error: data/full_repos/permissive/49869849/hardware/src/MPU9250_contoroller.v:437: Define or directive not defined: \'`MPU9250_RA_GYRO_ZOUT_L\'\n        mpu_address_reg <= `MPU9250_RA_GYRO_ZOUT_L;    \n                           ^~~~~~~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/49869849/hardware/src/MPU9250_contoroller.v:437: syntax error, unexpected \';\', expecting TYPE-IDENTIFIER\n        mpu_address_reg <= `MPU9250_RA_GYRO_ZOUT_L;    \n                                                  ^\n%Error: Exiting due to 13 error(s)\n'
module MPU_gyro_controller(
    input clk,
    input reset,
	output reg [15:0] gyro_x,
	output reg [15:0] gyro_y,
	output reg [15:0] gyro_z,
	output SPI_SS_g,
	output SPI_CK_g,
	output SPI_DO_g,
	input SPI_DI_g,
	output reg arm_read_enable_g
	);

	parameter 	SETUP_GYRO_X_H = 18,
					WAIT_GYRO_X_H = 19,
					READ_GYRO_X_H = 20,
					SETUP_GYRO_X_L = 21,
					WAIT_GYRO_X_L = 22,
					READ_GYRO_X_L = 23,
					SETUP_GYRO_Y_H = 24,
					WAIT_GYRO_Y_H = 25,
					READ_GYRO_Y_H = 26,
					SETUP_GYRO_Y_L = 27,
					WAIT_GYRO_Y_L = 28,
					READ_GYRO_Y_L = 29,
					SETUP_GYRO_Z_H = 30,
					WAIT_GYRO_Z_H = 31,
					READ_GYRO_Z_H = 32,
					SETUP_GYRO_Z_L = 33,
					WAIT_GYRO_Z_L = 34,
					READ_GYRO_Z_L = 35;
				
	
	wire mpu_busy;
	wire [7:0] mpu_read_data;

	reg [31:0] IDLEcounter = 0;
	parameter MAX_IDLEcounter = 32'd1000000;
	reg [4:0] state;
	reg [5:0] read_counter;
	
	reg [6:0] mpu_address_reg;
	reg [7:0] mpu_write_data;
	reg mpu_rd_wr_select;
	reg mpu_start = 0;
	reg [7:0] gyro_x_H;
	reg [7:0] gyro_y_H;
	reg [7:0] gyro_z_H;
	
	reg [7:0] whoami;
	




























































































































			

		   7:begin
					case(read_counter)

						SETUP_GYRO_X_H:begin						
							if(mpu_busy == 0)
							begin
								mpu_start <= 1;
								mpu_rd_wr_select <= 1;
								mpu_address_reg <= `MPU9250_RA_GYRO_XOUT_H;
								read_counter <= read_counter + 1;
							end
						end
						WAIT_GYRO_X_H:begin						
							mpu_start <= 0;
							if(mpu_busy == 0) read_counter <= read_counter + 1;
						end
						READ_GYRO_X_H:begin
							gyro_x_H <= mpu_read_data;
							read_counter <= read_counter + 1;
						end
						

						SETUP_GYRO_X_L:begin						
							if(mpu_busy == 0)
							begin
								mpu_start <= 1;
								mpu_rd_wr_select <= 1;
								mpu_address_reg <= `MPU9250_RA_GYRO_XOUT_L;
								read_counter <= read_counter + 1;
							end
						end
						WAIT_GYRO_X_L:begin						
							mpu_start <= 0;
							if(mpu_busy == 0) read_counter <= read_counter + 1;
						end
						READ_GYRO_X_L:begin
							gyro_x <= { mpu_read_data,gyro_x_H};
							read_counter <= read_counter + 1;
						end
					endcase
			end
			8:begin
					case(read_counter)

						SETUP_GYRO_Y_H:begin						
							if(mpu_busy == 0)
							begin
								mpu_start <= 1;
								mpu_rd_wr_select <= 1;
								mpu_address_reg <= `MPU9250_RA_GYRO_YOUT_H;
								read_counter <= read_counter + 1;
							end
						end
						WAIT_GYRO_Y_H:begin						
							mpu_start <= 0;
							if(mpu_busy == 0) read_counter <= read_counter + 1;
						end
						READ_GYRO_Y_H:begin
							gyro_y_H <= mpu_read_data;
							read_counter <= read_counter + 1;
						end
						

						SETUP_GYRO_Y_L:begin						
							if(mpu_busy == 0)
							begin
								mpu_start <= 1;
								mpu_rd_wr_select <= 1;
								mpu_address_reg <= `MPU9250_RA_GYRO_YOUT_L;
								read_counter <= read_counter + 1;
							end
						end
						WAIT_GYRO_Y_L:begin						
							mpu_start <= 0;
							if(mpu_busy == 0) read_counter <= read_counter + 1;
						end
						READ_GYRO_Y_L:begin
							gyro_y <= {mpu_read_data,gyro_y_H};
							read_counter <= read_counter + 1;
						end
					endcase
			end
			9:begin
					case(read_counter)

						SETUP_GYRO_Z_H:begin						
							if(mpu_busy == 0)
							begin
								mpu_start <= 1;
								mpu_rd_wr_select <= 1;
								mpu_address_reg <= `MPU9250_RA_GYRO_ZOUT_H;
								read_counter <= read_counter + 1;
							end
						end
						WAIT_GYRO_Z_H:begin						
							mpu_start <= 0;
							if(mpu_busy == 0) read_counter <= read_counter + 1;
						end
						READ_GYRO_Z_H:begin
							gyro_z_H <= mpu_read_data;
							read_counter <= read_counter + 1;
						end
						

						SETUP_GYRO_Z_L:begin						
							if(mpu_busy == 0)
							begin
								mpu_start <= 1;
								mpu_rd_wr_select <= 1;
								mpu_address_reg <= `MPU9250_RA_GYRO_ZOUT_L;
								read_counter <= read_counter + 1;
							end
						end
						WAIT_GYRO_Z_L:begin						
							mpu_start <= 0;
							if(mpu_busy == 0) read_counter <= read_counter + 1;
						end
						READ_GYRO_Z_L:begin
							gyro_z <= {mpu_read_data,gyro_z_H};
							read_counter <= read_counter + 1;
						end
					endcase
			end


			
						
			10:begin

				if(IDLEcounter == 32'd80000)
				begin
						arm_read_enable_g <= 1;
						IDLEcounter <= IDLEcounter + 1;		
				end
				else begin
						IDLEcounter <= IDLEcounter + 1;		
				end
			 end
			endcase
	end
end



endmodule
module MPU_gyro_controller(
    input clk,
    input reset,
	output reg [15:0] gyro_x,
	output reg [15:0] gyro_y,
	output reg [15:0] gyro_z,
	output SPI_SS_g,
	output SPI_CK_g,
	output SPI_DO_g,
	input SPI_DI_g,
	output reg arm_read_enable_g
	);


	parameter 	SETUP_GYRO_X_H = 18,
					WAIT_GYRO_X_H = 19,
					READ_GYRO_X_H = 20,
					SETUP_GYRO_X_L = 21,
					WAIT_GYRO_X_L = 22,
					READ_GYRO_X_L = 23,
					SETUP_GYRO_Y_H = 24,
					WAIT_GYRO_Y_H = 25,
					READ_GYRO_Y_H = 26,
					SETUP_GYRO_Y_L = 27,
					WAIT_GYRO_Y_L = 28,
					READ_GYRO_Y_L = 29,
					SETUP_GYRO_Z_H = 30,
					WAIT_GYRO_Z_H = 31,
					READ_GYRO_Z_H = 32,
					SETUP_GYRO_Z_L = 33,
					WAIT_GYRO_Z_L = 34,
					READ_GYRO_Z_L = 35;
				
	
	wire mpu_busy;
	wire [7:0] mpu_read_data;

	reg [31:0] IDLEcounter = 0;
	parameter MAX_IDLEcounter = 32'd1000000;
	reg [4:0] state;
	reg [5:0] read_counter;
	
	reg [6:0] mpu_address_reg;
	reg [7:0] mpu_write_data;
	reg mpu_rd_wr_select;
	reg mpu_start = 0;
	reg [7:0] gyro_x_H;
	reg [7:0] gyro_y_H;
	reg [7:0] gyro_z_H;
	
	reg [7:0] whoami;
	




























































































































			

		   7:begin
					case(read_counter)

						SETUP_GYRO_X_H:begin						
							if(mpu_busy == 0)
							begin
								mpu_start <= 1;
								mpu_rd_wr_select <= 1;
								mpu_address_reg <= `MPU9250_RA_GYRO_XOUT_H;
								read_counter <= read_counter + 1;
							end
						end
						WAIT_GYRO_X_H:begin						
							mpu_start <= 0;
							if(mpu_busy == 0) read_counter <= read_counter + 1;
						end
						READ_GYRO_X_H:begin
							gyro_x_H <= mpu_read_data;
							read_counter <= read_counter + 1;
						end
						

						SETUP_GYRO_X_L:begin						
							if(mpu_busy == 0)
							begin
								mpu_start <= 1;
								mpu_rd_wr_select <= 1;
								mpu_address_reg <= `MPU9250_RA_GYRO_XOUT_L;
								read_counter <= read_counter + 1;
							end
						end
						WAIT_GYRO_X_L:begin						
							mpu_start <= 0;
							if(mpu_busy == 0) read_counter <= read_counter + 1;
						end
						READ_GYRO_X_L:begin
							gyro_x <= { mpu_read_data,gyro_x_H};
							read_counter <= read_counter + 1;
						end
					endcase
			end
			8:begin
					case(read_counter)

						SETUP_GYRO_Y_H:begin						
							if(mpu_busy == 0)
							begin
								mpu_start <= 1;
								mpu_rd_wr_select <= 1;
								mpu_address_reg <= `MPU9250_RA_GYRO_YOUT_H;
								read_counter <= read_counter + 1;
							end
						end
						WAIT_GYRO_Y_H:begin						
							mpu_start <= 0;
							if(mpu_busy == 0) read_counter <= read_counter + 1;
						end
						READ_GYRO_Y_H:begin
							gyro_y_H <= mpu_read_data;
							read_counter <= read_counter + 1;
						end
						

						SETUP_GYRO_Y_L:begin						
							if(mpu_busy == 0)
							begin
								mpu_start <= 1;
								mpu_rd_wr_select <= 1;
								mpu_address_reg <= `MPU9250_RA_GYRO_YOUT_L;
								read_counter <= read_counter + 1;
							end
						end
						WAIT_GYRO_Y_L:begin						
							mpu_start <= 0;
							if(mpu_busy == 0) read_counter <= read_counter + 1;
						end
						READ_GYRO_Y_L:begin
							gyro_y <= {mpu_read_data,gyro_y_H};
							read_counter <= read_counter + 1;
						end
					endcase
			end
			9:begin
					case(read_counter)

						SETUP_GYRO_Z_H:begin						
							if(mpu_busy == 0)
							begin
								mpu_start <= 1;
								mpu_rd_wr_select <= 1;
								mpu_address_reg <= `MPU9250_RA_GYRO_ZOUT_H;
								read_counter <= read_counter + 1;
							end
						end
						WAIT_GYRO_Z_H:begin						
							mpu_start <= 0;
							if(mpu_busy == 0) read_counter <= read_counter + 1;
						end
						READ_GYRO_Z_H:begin
							gyro_z_H <= mpu_read_data;
							read_counter <= read_counter + 1;
						end
						

						SETUP_GYRO_Z_L:begin						
							if(mpu_busy == 0)
							begin
								mpu_start <= 1;
								mpu_rd_wr_select <= 1;
								mpu_address_reg <= `MPU9250_RA_GYRO_ZOUT_L;
								read_counter <= read_counter + 1;
							end
						end
						WAIT_GYRO_Z_L:begin						
							mpu_start <= 0;
							if(mpu_busy == 0) read_counter <= read_counter + 1;
						end
						READ_GYRO_Z_L:begin
							gyro_z <= {mpu_read_data,gyro_z_H};
							read_counter <= read_counter + 1;
						end
					endcase
			end


			
						
			10:begin

				if(IDLEcounter == 32'd80000)
				begin
						arm_read_enable_g <= 1;
						IDLEcounter <= IDLEcounter + 1;		
				end
				else begin
						IDLEcounter <= IDLEcounter + 1;		
				end
			 end
			endcase
	end
end



endmodule