process (stCur, rdaSig, dboutsig,tClk1)
begin
case stCur is
-------------------------------------------------------------------------
--
--Title: stReceive state
--
--Description: This state waits for the UART to receive data. While in
-- this state, the rdSig and wrSig are held low to keep the
-- UART from transmitting any data. Once the rdaSig is set
-- high, data has been received, and is safe to transmit. At
-- this time, the stSend state is loaded, and the dbOutSig
-- is copied to the dbInSig in order to transmit the newly
-- acquired parallel information.
-------------------------------------------------------------------------
when stReceive =>
rdSig <= '0';
wrSig <= '0';
-- if rdaSig = '1' then
if(dbOutSig= x"73")then
-- trig1<='1';
dbInSig <=distance(7 downto 0);
stNext <= stSend;
elsif(dbOutSig= x"74")then
-- trig2<='1';
dbInSig <=distance2(7 downto 0);
stNext <= stSend;
else
stNext<=stReceive;
end if;
-------------------------------------------------------------------------
--
--Title: stSend state
--
--Description: This state tells the UART to send the parallel
-- information found in dbInSig. It does this by strobing
-- both the rdSig and wrSig signals high. Once these
-- signals have been strobed high, the stReceive state is
-- loaded.
--
-------------------------------------------------------------------------
when stSend =>
rdSig <= '0';
wrSig <= '1';
stNext <= stStop;
when stStop =>
wrSig <= '0';
end case;
end process;
end Behavioral;