library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; use work.typy.all; use work.components.all; entity IndividualControl is port ( clock: std_logic; basic: BasicStep; inputState: movementState; inputPos: serwoPosition; action: OrderType; outputStep: out ExtendedStep ); end entity; architecture arch11 of IndividualControl is constant zeroBorder: integer := 0; constant firstBorder: integer := 120; constant secondBorder: integer := 125; constant thirdBorder: integer := 245; constant fourthBorder: integer := 256; signal computedPosition: SerwoPosition; signal change: ExtendedStep; signal tmpChange, syncChange, actChange: BasicStep := 0; signal enable: std_logic; signal akcja: OrderType; signal states: std_logic_vector (2 downto 0); alias computeDifferences: std_logic is states(0); alias computeValues: std_logic is states(1); alias computeResult: std_logic is states(2); begin sm: stateMachine generic map(4) port map (clock, action.enable, states); outputStep <= change; porownajpozycje: process (computeDifferences) begin if (computeDifferences'event and computeDifferences = '1') then if (inputState >= zeroBorder and inputState < firstBorder ) then computedPosition <= (inputState - zeroBorder) * basic ; tmpChange <= basic; elsif (inputState >= firstBorder and inputState < secondBorder) then computedPosition <= firstBorder * basic; tmpChange <= 0; elsif (inputState >= secondBorder and inputState < thirdBorder ) then computedPosition <= (firstBorder - inputState + secondBorder) * basic; tmpChange <= -basic; elsif (inputState >= thirdBorder and inputState < fourthBorder ) then computedPosition <= 0 ; tmpChange <= 0; end if; end if; end process; ustalWartosci: process (computeValues) begin if (computeValues'event and computeValues = '1') then if (computedPosition /= inputPos) then if (computedPosition > inputPos ) then syncChange <= basic; else syncChange <= - basic; end if; else syncChange <= 0; end if; if (action.direction = l) then actChange <= - tmpChange; else actChange <= tmpChange; end if; end if; end process; zsumujWartosci: process (computeResult) begin if (computeResult'event and computeResult = '1') then change <= actChange + syncChange; end if; end process; end architecture;