function(help!)

L

leon86

this coding i have done...how do i declare a function and call it? e.g

******
if(check='0') then
if(input="00" or count=0) then
sm<=s0;
output<='0';
check<='1';
else
count<=count-1;
end if;
end if;

*************

--actual coding here...--
architecture abehav of adetect is
type states is (s0,s1,s2,s3);
signal sm: states;
signal count: integer:=3;
signal check: std_logic;

begin
process(clk,reset,input)
begin
if reset='1' then
sm<=s0;output<='0';check<='0';
elsif(clk'event and clk='1') then
case sm is
when s0 => if(input="00") then
sm<=s0;
output<='0';
check<='0';
count<=3;

elsif(input="01" and check='0') then
sm<=s1;
output<='1';

elsif(input="10" and check='0') then
sm<=s2;
output<='1';
count<=count*2;

else
sm<=s0;
output<='0';
count<=3;
end if;

when s1 => if(check='0') then
if(input="00" or count=0) then
sm<=s0;
output<='0';
check<='1';
else
count<=count-1;
end if;
end if;

when s2 => if(check='0') then
if(input="00" or count=0) then
sm<=s0;
output<='0';
check<='1';
else
count<=count-1;
end if;
end if;
when others=>sm<=s0;
end case;
end if;
end process;
end abehav;
 

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

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,268
Latest member
AshliMacin

Latest Threads

Top