小弟我的vhdl程序为什么错了

请高手看看我的vhdl程序为什么错了
library ieee;
use ieee.std_logic_1164.all;
entity p92_15 is
port(
reset,clk:in std_logic;
input:in std_logic_vector(1 downto 0);
output:out std_logic_vector(3 downto 0));
end p92_15;
architecture behv of p92_15 is
type st is(s0,s1,s2,s3);
signal c_st,n_st:st; 
begin
process(clk,reset)
begin
if reset='1' then 
c_st<=s0; 
end if;    
if clk='1'and clk'event then   --this is the wrong sentence
case c_st is
when s0=> output<="0101";
if input="00"  then 
c_st<=s0;
elsif input="01" or input="10" or input="11" then 
c_st<=s1;
end if;
when s1=> output<="1000";
if input="00" then
c_st<=s1;
elsif input="01" or input="10" or input="11" then
c_st<=s2;
end if;
when s2=> output<="1100";
if input="11" then
c_st<=s0;
elsif input="01" or input="00" or input="10" then
c_st<=s3;
end if;
when s3=> output<="1101";
if input="11" then
c_st<=s3;
elsif input="00" or input="01" or input="10" then
c_st<=s0;
end if;
end case;
end if;
end process;
end behv;

我用的是quartus ii。报错:
Error (10818): Can't infer register for "c_st.s0" at p92_15.vhd(18) because it does not hold its value outside the clock edge
Error (10822): HDL error at p92_15.vhd(18): couldn't implement registers for assignments on this clock edge
费解啊

------最佳解决方案--------------------
if reset='1' then 
c_st<=s0; 
end if;    
if clk='1'and clk'event then   --this is the wrong sentence
....
这里貌似写错了,
应该是
if reset='1' then 
c_st<=s0; 
elsif clk='1'and clk'event then   --this is the wrong sentence
... 
------其他解决方案--------------------
引用:
引用:

if reset='1' then
c_st<=s0;
end if;
if clk='1'and clk'event then --this is the wrong sentence
....
这里貌似写错了,
应该是
if reset='1' then
c_st<=s0;
elsif clk='1'and clk'event t……


你这个写法是错误的。VHDL程序在进程里面是顺序执行的,你的原始程序可以分成
if reset='1' then 
c_st<=s0; 
end if;    

if clk='1'and clk'event then
这两个部分,if reset='1' then 这一部分其实没有起作用。
c_st又需要在电平触发,有需要沿触发,这个是没办法综合,这个就是你错误的原因。
你的本意是状态机在复位的时候初态是S0,然后不复位的时状态转换,所以稍微改一下就行了。

------其他解决方案--------------------
帮顶
------其他解决方案--------------------
引用:
if reset='1' then 
c_st<=s0; 
end if;    
if clk='1'and clk'event then   --this is the wrong sentence