function(help!)

L

leon86

Guest
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;
 

Welcome to EDABoard.com

Sponsor

Back
Top