Delay modelling problem

Joined
Apr 14, 2008
Messages
1
Reaction score
0
For a sumo robot application I wrote following codes as state machine. But my problem is I need somewhere of the codes, 500ms and 1000ms delays (you can find those in the explanation lines). Please help me how can solve this problem.


entity SSMACH2 is
port (sh,solcny,sagcny :in std_logic; solmi,solmg,sagmi,sagmg:eek:ut std_logic; clk, reset : in std_logic); end SSMACH2;

architecture BEHAVIOR of SSMACH2 is
type STATES is (ilkhareket,solgeridon,duzgit,saggeridon); signal PRESENT_STATE : STATES; signal sign_f :bit;
begin
process (clk, reset)
begin

if reset = '1' then
PRESENT_STATE <= ilkhareket;
solmi<='0';
solmg<='1';
sagmi<='1';
sagmg<='0';

elsif clk'event and clk = '1' then
solmi<='0';
solmg<='1';
sagmi<='1';
sagmg<='0';
PRESENT_STATE <= ilkhareket;
case PRESENT_STATE is

when ilkhareket =>
if sh='1' and solcny='1' and sagcny='1' then PRESENT_STATE<= duzgit;
elsif sh='1' and solcny='1' and sagcny='0' then PRESENT_STATE<= saggeridon;
elsif sh='1' and solcny='0' and sagcny='0' then PRESENT_STATE<= saggeridon;
elsif sh='0' and solcny='1' and sagcny='0' then PRESENT_STATE<= saggeridon;
elsif sh='0' and solcny='0' and sagcny='0' then PRESENT_STATE<= saggeridon;
elsif sh='1' and solcny='0' and sagcny='1' then PRESENT_STATE<=solgeridon;
elsif sh='0' and solcny='0' and sagcny='1' then PRESENT_STATE<=solgeridon;
elsif sh='0' and solcny='1' and sagcny='1' then PRESENT_STATE<= ilkhareket;
end if;

when duzgit =>
solmi<='1';
solmg<='0';
sagmi<='1';
sagmg<='0';
if sh='0' and solcny='1' and sagcny='1' then PRESENT_STATE<= ilkhareket;
elsif sh='1' and solcny='1' and sagcny='1' then PRESENT_STATE<= duzgit;
end if;
when solgeridon =>
solmi<= '0';
solmg<= '1';
sagmi<= '0';
sagmg<= '1';

--wait for 1000ms;

solmi <= '0';
solmg <= '1';
sagmi <= '0';
sagmg <= '0';

--wait for 500ms;

if sh='0' and solcny='1' and sagcny='1' then PRESENT_STATE<= ilkhareket;
elsif sh='1' and solcny='0' and sagcny='1' then PRESENT_STATE<=solgeridon;
elsif sh='0' and solcny='0' and sagcny='1' then PRESENT_STATE<=solgeridon;
end if;

when saggeridon=>
solmi<='0';
solmg<='1';
sagmi<='0';
sagmg<='1';

--wait for 1000ms;

solmi<='0';
solmg<='0';
sagmi<='0';
sagmg<='1';

--wait for 500ms;

if sh='0' and solcny='1' and sagcny='1' then PRESENT_STATE<= ilkhareket ;
elsif sh='1' and solcny='1' and sagcny='0' then PRESENT_STATE<= saggeridon;
elsif sh='1' and solcny='0' and sagcny='0' then PRESENT_STATE<= saggeridon;
elsif sh='0' and solcny='1' and sagcny='0' then PRESENT_STATE<= saggeridon;
elsif sh='0' and solcny='0' and sagcny='0' then PRESENT_STATE<= saggeridon;
end if;

end case;
end if;
end process;
end BEHAVIOR;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top