-- Signals and constants
-- Positional
signal azimuth, elevation: integer := 0;
signal target_new: unsigned(3 downto 0) := x"1";
signal target_set: unsigned(3 downto 0) := x"0";
signal cmd: unsigned(7 downto 0) := x"00";
-- Status flags
signal Az_idle, El_idle: std_logic;
signal status: unsigned(3 downto 0); -- ? zeroed, search, lock
-- Netduino interface
netduino: entity work.netduino_bridge port map(mclk, net_SCLK, net_MOSI, net_CS, net_MISO, target_new, target_set, status, cmd);
------ PROCESSES ------
-- Deal with netduino commands
process(target_fix) is
begin
-- if both axes are idling, accept new position.
if(Az_idle = '1' and El_idle = '1') then
case target_new is
-- zero position
when "0000" =>
azimuth <= 0;
elevation <= 0;
-- Sat 1
when "0001" =>
azimuth <= 50;
elevation <= 50;
-- Sat 2
when "0010" =>
azimuth <= 100;
elevation <= 300;
-- Sat 3
when "0011" =>
azimuth <= 200;
elevation <= 180;
-- Sat 4
when "0100" =>
azimuth <= 300;
elevation <= 100;
-- Unrecognised; do nothing
when others =>
null;
end case;
end if;
-- wait until pointing is finished and report lack of lock
if (Az_idle = '0' AND El_idle = '0') then
status(0) <= '0';
else
-- once pointing finished, update status
target_set <= target_new;
status(0) <= '1';
end if;
end process;