data/full_repos/permissive/48004801/ServoCommander.srcs/sources_1/new/Components.v
1: b'%Warning-MULTITOP: data/full_repos/permissive/48004801/ServoCommander.srcs/sources_1/new/Components.v:75: Multiple top level modules\n                                                                                                        : ... Suggest see manual; fix the duplicates, or use --top-module to select top.\n                   ... Use "/* verilator lint_off MULTITOP */" and lint_on around source to disable this message.\n                                                                                                        : ... Top module \'PositionMux\'\nmodule PositionMux(\n       ^~~~~~~~~~~\n                                                                                                        : ... Top module \'SweepPosition\'\nmodule SweepPosition(\n       ^~~~~~~~~~~~~\n                                                                                                        : ... Top module \'AngleToPWM\'\nmodule AngleToPWM(\n       ^~~~~~~~~~\n%Error: data/full_repos/permissive/48004801/ServoCommander.srcs/sources_1/new/Components.v:57: Cannot find file containing module: \'Segment\'\nSegment U0 (\n^~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/48004801/ServoCommander.srcs/sources_1/new,data/full_repos/permissive/48004801/Segment\n             data/full_repos/permissive/48004801/ServoCommander.srcs/sources_1/new,data/full_repos/permissive/48004801/Segment.v\n             data/full_repos/permissive/48004801/ServoCommander.srcs/sources_1/new,data/full_repos/permissive/48004801/Segment.sv\n             Segment\n             Segment.v\n             Segment.sv\n             obj_dir/Segment\n             obj_dir/Segment.v\n             obj_dir/Segment.sv\n%Warning-WIDTH: data/full_repos/permissive/48004801/ServoCommander.srcs/sources_1/new/Components.v:66: Operator SHIFTL expects 11 bits on the LHS, but LHS\'s VARREF \'pin_pos\' generates 10 bits.\n                                                                                                     : ... In instance PositionMux\n  1: out_pos = (pin_pos << 1) | 1\'b1;\n                        ^~\n%Warning-WIDTH: data/full_repos/permissive/48004801/ServoCommander.srcs/sources_1/new/Components.v:66: Operator OR expects 11 bits on the RHS, but RHS\'s CONST \'1\'h1\' generates 1 bits.\n                                                                                                     : ... In instance PositionMux\n  1: out_pos = (pin_pos << 1) | 1\'b1;\n                              ^\n%Warning-WIDTH: data/full_repos/permissive/48004801/ServoCommander.srcs/sources_1/new/Components.v:146: Operator ASSIGN expects 2 bits on the Assign RHS, but Assign RHS\'s CONST \'3\'h0\' generates 3 bits.\n                                                                                                      : ... In instance AngleToPWM\n  state = 3\'b0;\n        ^\n%Warning-WIDTH: data/full_repos/permissive/48004801/ServoCommander.srcs/sources_1/new/Components.v:161: Operator ASSIGN expects 2 bits on the Assign RHS, but Assign RHS\'s CONST \'3\'h1\' generates 3 bits.\n                                                                                                      : ... In instance AngleToPWM\n    state = 3\'h1;\n          ^\n%Warning-WIDTH: data/full_repos/permissive/48004801/ServoCommander.srcs/sources_1/new/Components.v:168: Operator ASSIGN expects 2 bits on the Assign RHS, but Assign RHS\'s CONST \'3\'h2\' generates 3 bits.\n                                                                                                      : ... In instance AngleToPWM\n     state = 3\'h2;\n           ^\n%Warning-WIDTH: data/full_repos/permissive/48004801/ServoCommander.srcs/sources_1/new/Components.v:176: Operator ASSIGN expects 2 bits on the Assign RHS, but Assign RHS\'s CONST \'3\'h0\' generates 3 bits.\n                                                                                                      : ... In instance AngleToPWM\n     state = 3\'h0;\n           ^\n%Warning-WIDTH: data/full_repos/permissive/48004801/ServoCommander.srcs/sources_1/new/Components.v:150: Operator GT expects 32 or 12 bits on the LHS, but LHS\'s VARREF \'pos\' generates 11 bits.\n                                                                                                      : ... In instance AngleToPWM\n else if(pos > 2500 || pos < 0) begin\n             ^\n%Warning-WIDTH: data/full_repos/permissive/48004801/ServoCommander.srcs/sources_1/new/Components.v:100: Operator ASSIGN expects 11 bits on the Assign RHS, but Assign RHS\'s CONST \'10\'h0\' generates 10 bits.\n                                                                                                      : ... In instance SweepPosition\n  pos = 10\'d0;\n      ^\n%Warning-WIDTH: data/full_repos/permissive/48004801/ServoCommander.srcs/sources_1/new/Components.v:104: Operator SHIFTL expects 11 bits on the LHS, but LHS\'s VARREF \'speed\' generates 3 bits.\n                                                                                                      : ... In instance SweepPosition\n  pos = pos + (speed << 1);\n                     ^~\n%Warning-WIDTH: data/full_repos/permissive/48004801/ServoCommander.srcs/sources_1/new/Components.v:111: Operator SHIFTL expects 11 bits on the LHS, but LHS\'s VARREF \'speed\' generates 3 bits.\n                                                                                                      : ... In instance SweepPosition\n  pos = pos - (speed << 1);\n                     ^~\n%Error: Exiting due to 1 error(s), 11 warning(s)\n'
module AngleToPWM(
	input wire [RC_SIGNAL_WIDTH-1:0] pos,
	input wire clk1MHz,
	input wire rst,
	output reg pwm
);

parameter RC_SIGNAL_WIDTH = 11;
parameter PIN_POS_WIDTH = 10;
parameter BCD_WIDTH = 4;

parameter POSITION_FILE_WIDTH = 32;
parameter POSITION_WIDTH = 11;
parameter PWMS = 4;

parameter time_width   = 20000;
parameter pos_time_min = 500;
parameter pos_time_max = 2500;
integer current_time;
reg [10:0] stored_pos;
reg [1:0] state;

always @(posedge clk1MHz or posedge rst) begin
	if (rst) begin
		pwm = 1'b1;
		state = 3'b0;
		current_time = 0;
		stored_pos = 0;
	end
	else if(pos > 2500 || pos < 0) begin
		pwm = 1'b1;
	end
	else begin
		case(state)


			0: begin 
				pwm = 1;

				stored_pos = pos;
				state = 3'h1;

			end

			1: begin
				pwm = 1;
				if (current_time >= stored_pos) begin
					state = 3'h2;
				end
			end


			2: begin
				pwm = 0;
				if (current_time >= time_width) begin
					state = 3'h0;
					current_time = 0;
				end
			end
		endcase
		current_time = current_time + 1;
	end
end

endmodule
module AngleToPWM(
	input wire [RC_SIGNAL_WIDTH-1:0] pos,
	input wire clk1MHz,
	input wire rst,
	output reg pwm
);


parameter RC_SIGNAL_WIDTH = 11;
parameter PIN_POS_WIDTH = 10;
parameter BCD_WIDTH = 4;

parameter POSITION_FILE_WIDTH = 32;
parameter POSITION_WIDTH = 11;
parameter PWMS = 4;

parameter time_width   = 20000;
parameter pos_time_min = 500;
parameter pos_time_max = 2500;
integer current_time;
reg [10:0] stored_pos;
reg [1:0] state;

always @(posedge clk1MHz or posedge rst) begin
	if (rst) begin
		pwm = 1'b1;
		state = 3'b0;
		current_time = 0;
		stored_pos = 0;
	end
	else if(pos > 2500 || pos < 0) begin
		pwm = 1'b1;
	end
	else begin
		case(state)


			0: begin 
				pwm = 1;

				stored_pos = pos;
				state = 3'h1;

			end

			1: begin
				pwm = 1;
				if (current_time >= stored_pos) begin
					state = 3'h2;
				end
			end


			2: begin
				pwm = 0;
				if (current_time >= time_width) begin
					state = 3'h0;
					current_time = 0;
				end
			end
		endcase
		current_time = current_time + 1;
	end
end

endmodule