data/full_repos/permissive/176151176/PS2MouseKeyboard/PS2_Mouse_Controller.v
1: b'%Warning-PINMISSING: data/full_repos/permissive/176151176/PS2MouseKeyboard/PS2_Mouse_Controller.v:322: Cell has missing pin: \'count\'\n  mouse_tracker tester(\n                ^~~~~~\n                     ... Use "/* verilator lint_off PINMISSING */" and lint_on around source to disable this message.\n%Error: data/full_repos/permissive/176151176/PS2MouseKeyboard/PS2_Mouse_Controller.v:158: Cannot find file containing module: \'PS2_Controller\'\n  PS2_Controller #(.INITIALIZE_MOUSE(1)) tracker2(\n  ^~~~~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/176151176/PS2MouseKeyboard,data/full_repos/permissive/176151176/PS2_Controller\n             data/full_repos/permissive/176151176/PS2MouseKeyboard,data/full_repos/permissive/176151176/PS2_Controller.v\n             data/full_repos/permissive/176151176/PS2MouseKeyboard,data/full_repos/permissive/176151176/PS2_Controller.sv\n             PS2_Controller\n             PS2_Controller.v\n             PS2_Controller.sv\n             obj_dir/PS2_Controller\n             obj_dir/PS2_Controller.v\n             obj_dir/PS2_Controller.sv\n%Error: Exiting due to 1 error(s), 1 warning(s)\n'
module mouse_tracker(
    input clock,
	 input reset,
	 input enable_tracking,
	 
	 inout PS2_CLK,
	 inout PS2_DAT,
	 
	 output reg [8:0] x_pos,
	 output reg [8:0] y_pos,
	 output reg right_click,
	 output reg left_click,
	 output reg [3:0] count
    );


	 wire byte_received;

	 wire [7:0] newest_byte;
	 

	 reg [7:0] byte1;
	 reg [7:0] byte2;
	 reg [7:0] byte3;
	 



	 wire [8:0] new_x;
	 wire [8:0] new_y;
	 
	 assign new_x = x_pos + {byte1[4], byte2};




	 assign new_y = y_pos - {byte1[5], byte3};
	 
	 PS2_Controller #(.INITIALIZE_MOUSE(1)) tracker2(
	     .CLOCK_50(clock),
		  .reset(~reset),
		  .PS2_CLK(PS2_CLK),
		  .PS2_DAT(PS2_DAT),
		  .received_data(newest_byte),
		  .received_data_en(byte_received)
		  );
	 
	 reg [2:0] curr_state;
	 reg [2:0] next_state;
	 



	 reg init_byte_received;
	 
	 localparam WAIT_INIT   = 3'b000,
	            GET_BYTE_1  = 3'b001,
					LOAD_BYTE_1 = 3'b011,
					GET_BYTE_2  = 3'b010,
					LOAD_BYTE_2 = 3'b110,
					GET_BYTE_3  = 3'b100,
					LOAD_BYTE_3 = 3'b101,
					PROCESS     = 3'b111;

    parameter  XMIN        = 9'd0,
	            YMIN        = 9'b0,
					XMAX        = 9'd159,
					YMAX        = 9'd119,
					XSTART      = 9'd79,
					YSTART      = 9'd59;
    
	 always @(*) begin: state_transitions
	     case (curr_state)
		      WAIT_INIT:  next_state = init_byte_received && byte_received ? GET_BYTE_1 : WAIT_INIT;
		      GET_BYTE_1: next_state = byte_received ? LOAD_BYTE_1 : GET_BYTE_1;
				LOAD_BYTE_1: next_state = GET_BYTE_2;
				GET_BYTE_2: next_state = byte_received ? LOAD_BYTE_2 : GET_BYTE_2;
				LOAD_BYTE_2: next_state = GET_BYTE_3;
				GET_BYTE_3: next_state = byte_received ? LOAD_BYTE_3 : GET_BYTE_3;
				LOAD_BYTE_3: next_state = PROCESS;
				PROCESS: next_state = GET_BYTE_1;
        endcase
    end
	 
	 
	 always @(posedge clock) begin: receive_data

	     byte1 <= byte1;
		  byte2 <= byte2;
		  byte3 <= byte3;
		  x_pos <= x_pos;
		  y_pos <= y_pos;
		  left_click <= left_click;
		  init_byte_received <= init_byte_received;
		  count <= count;
		  
		  if (~reset) begin
		      byte1 <= 8'b0;
				byte2 <= 8'b0;
				byte3 <= 8'b0;
				x_pos <= XSTART;
				y_pos <= YSTART;
				left_click  <= 1'b0;
				right_click <= 1'b0;
				init_byte_received <= 1'b0;
				count <= 4'd15;
        end
		  if (byte_received)
		      init_byte_received <= 1'b1;
        if (curr_state == LOAD_BYTE_1)

            byte1 <= newest_byte;
        if (curr_state == LOAD_BYTE_2)

            byte2 <= newest_byte;
        if (curr_state == LOAD_BYTE_3)

		      byte3 <= newest_byte;
        if (curr_state == PROCESS) begin



		      x_pos <= ~enable_tracking || byte1[6] ? x_pos

                     : (new_x < XMIN || (byte1[4] && new_x > x_pos) ? XMIN

                     : (new_x > XMAX ? XMAX

                     : new_x));

							  
            y_pos <= ~enable_tracking || byte1[7] ? y_pos

                     : (new_y < YMIN || (~byte1[5] && new_y > y_pos) ? YMIN

                     : (new_y > YMAX ? YMAX

							: new_y));



            right_click <= byte1[1];
				left_click  <= byte1[0];
				count <= count - 4'b1;
        end
    end
	 
	 
	 always @(posedge clock) begin: increment_state
	     if (~reset) begin

		      curr_state <= WAIT_INIT;
		  end
		  else begin
		      curr_state <= next_state;
		  end
    end
endmodule
module mouse_tracker(
    input clock,
	 input reset,
	 input enable_tracking,
	 
	 inout PS2_CLK,
	 inout PS2_DAT,
	 
	 output reg [8:0] x_pos,
	 output reg [8:0] y_pos,
	 output reg right_click,
	 output reg left_click,
	 output reg [3:0] count
    );



	 wire byte_received;

	 wire [7:0] newest_byte;
	 

	 reg [7:0] byte1;
	 reg [7:0] byte2;
	 reg [7:0] byte3;
	 



	 wire [8:0] new_x;
	 wire [8:0] new_y;
	 
	 assign new_x = x_pos + {byte1[4], byte2};




	 assign new_y = y_pos - {byte1[5], byte3};
	 
	 PS2_Controller #(.INITIALIZE_MOUSE(1)) tracker2(
	     .CLOCK_50(clock),
		  .reset(~reset),
		  .PS2_CLK(PS2_CLK),
		  .PS2_DAT(PS2_DAT),
		  .received_data(newest_byte),
		  .received_data_en(byte_received)
		  );
	 
	 reg [2:0] curr_state;
	 reg [2:0] next_state;
	 



	 reg init_byte_received;
	 
	 localparam WAIT_INIT   = 3'b000,
	            GET_BYTE_1  = 3'b001,
					LOAD_BYTE_1 = 3'b011,
					GET_BYTE_2  = 3'b010,
					LOAD_BYTE_2 = 3'b110,
					GET_BYTE_3  = 3'b100,
					LOAD_BYTE_3 = 3'b101,
					PROCESS     = 3'b111;

    parameter  XMIN        = 9'd0,
	            YMIN        = 9'b0,
					XMAX        = 9'd159,
					YMAX        = 9'd119,
					XSTART      = 9'd79,
					YSTART      = 9'd59;
    
	 always @(*) begin: state_transitions
	     case (curr_state)
		      WAIT_INIT:  next_state = init_byte_received && byte_received ? GET_BYTE_1 : WAIT_INIT;
		      GET_BYTE_1: next_state = byte_received ? LOAD_BYTE_1 : GET_BYTE_1;
				LOAD_BYTE_1: next_state = GET_BYTE_2;
				GET_BYTE_2: next_state = byte_received ? LOAD_BYTE_2 : GET_BYTE_2;
				LOAD_BYTE_2: next_state = GET_BYTE_3;
				GET_BYTE_3: next_state = byte_received ? LOAD_BYTE_3 : GET_BYTE_3;
				LOAD_BYTE_3: next_state = PROCESS;
				PROCESS: next_state = GET_BYTE_1;
        endcase
    end
	 
	 
	 always @(posedge clock) begin: receive_data

	     byte1 <= byte1;
		  byte2 <= byte2;
		  byte3 <= byte3;
		  x_pos <= x_pos;
		  y_pos <= y_pos;
		  left_click <= left_click;
		  init_byte_received <= init_byte_received;
		  count <= count;
		  
		  if (~reset) begin
		      byte1 <= 8'b0;
				byte2 <= 8'b0;
				byte3 <= 8'b0;
				x_pos <= XSTART;
				y_pos <= YSTART;
				left_click  <= 1'b0;
				right_click <= 1'b0;
				init_byte_received <= 1'b0;
				count <= 4'd15;
        end
		  if (byte_received)
		      init_byte_received <= 1'b1;
        if (curr_state == LOAD_BYTE_1)

            byte1 <= newest_byte;
        if (curr_state == LOAD_BYTE_2)

            byte2 <= newest_byte;
        if (curr_state == LOAD_BYTE_3)

		      byte3 <= newest_byte;
        if (curr_state == PROCESS) begin



		      x_pos <= ~enable_tracking || byte1[6] ? x_pos

                     : (new_x < XMIN || (byte1[4] && new_x > x_pos) ? XMIN

                     : (new_x > XMAX ? XMAX

                     : new_x));

							  
            y_pos <= ~enable_tracking || byte1[7] ? y_pos

                     : (new_y < YMIN || (~byte1[5] && new_y > y_pos) ? YMIN

                     : (new_y > YMAX ? YMAX

							: new_y));



            right_click <= byte1[1];
				left_click  <= byte1[0];
				count <= count - 4'b1;
        end
    end
	 
	 
	 always @(posedge clock) begin: increment_state
	     if (~reset) begin

		      curr_state <= WAIT_INIT;
		  end
		  else begin
		      curr_state <= next_state;
		  end
    end
endmodule