module calculate_val #(
	parameter INPUT = 1
) (
	input [4:0] value,
	input [4:0] rotor,
	output reg [4:0] out,
	input [4:0] ring_position
);
	reg signed [6:0] val = 7'b0000000;

	always @* 
	begin		
		if (INPUT==1)
			val = value - ring_position + rotor;
		else
			val = value + ring_position - rotor;

		if (val < 0    ) val = val + 7'd26;
		if (val > 7'd25) val = val - 7'd26;
		out = val[4:0];
	end
endmodule