2013-10-05 69 views
0

以下为JK触发器的代码: -JK触发器代码调试

entity jkasync is 
Port (j : in std_logic; 
     k : in std_logic; 
     r : in std_logic; 
     clk : in std_logic; 
     q : inout std_logic); 
end jkasync; 

architecture Behavioral of jkasync is 
signal s: std_logic_vector(1 downto 0); 
s <= j&k; 
begin 

    process (j,k,r,clk) 
    begin 

     if (r='1') then 
     q<='0'; 
     elsif (falling_edge(clk)) then 
     case s is 
     when "00" =>q<=q; 
     when "01" =>q<='0'; 
     when "10" =>q<='1'; 
     when "11" =>q<= not q; 
     when others =>q<='0'; 
     end case; 
     end if; 
    end process; 


    end Behavioral; 

而且我收到以下错误: -

线21.解析错误,意想不到的标识符

21行是s<=j&k; 所以,请帮助我更正此代码的语法,并请告诉我这里有什么问题。 谢谢。

+0

你不能让任何信号分配之前开始建筑。 – 2013-10-05 17:26:11

回答

0

明白了。

一个新的信号在体系结构体中被初始化,但是这个值是在过程体内定义的。

SO移动过程中的21行。

正确的代码: -

architecture Behavioral of jkasync is 
    signal s: std_logic_vector(1 downto 0); 

    begin 
    s <= j&k; 
    process (j,k,r,clk) 
    begin 

     if (r='1') then 
     q<='0'; 
     elsif (falling_edge(clk)) then 
     case s is 
     when "00" =>q<=q; 
     when "01" =>q<='0'; 
     when "10" =>q<='1'; 
     when "11" =>q<= not q; 
     when others =>q<='0'; 
     end case; 
     end if; 
    end process; 


     end Behavioral;