2012-04-20 45 views
2

我正在閱讀VHDL書籍,無法理解他們給出的示例。瞭解這個T觸發器的例子?

給出的代碼:

------------------------------------------------------------------- 
-- RET T Flip-flop model with active-low asynchronous set input. -- 
------------------------------------------------------------------- 
-- library declaration 
library IEEE; 
use IEEE.std_logic_1164.all; 
-- entity 
entity t_ff_s is 
    port (T,S,CLK : in std_logic; 
    Q : out std_logic); 
end t_ff_s; 
-- entity 
architecture my_t_ff_s of t_ff_s is 
    signal t_tmp : std_logic; -- intermediate signal declaration 
begin 
    tff: process (S,CLK) 
    begin 
    if (S = '0') then 
     Q <= '1'; 
    elsif (rising_edge(CLK)) then 
     t_tmp <= T XOR t_tmp; -- temp output assignment 
    end if; 
    end process tff; 
    Q <= t_tmp; -- final output assignment 
end my_t_ff_s; 

我不明白的是,他們如何分配多個信號Q.過程敘述之外,它的Q <= t_tmp但是這個過程裏面,如果S='0'然後Q <= '1'。這是如何工作的?我對VHDL的理解有限,這對我來說似乎是錯誤的。基本上,這看起來對我來說就像寫作一樣:

Q <= '0'; 
Q <= '1'; 

任何人都可以幫助我更好地理解這個例子嗎?

回答

4

你是正確的問題的例子。它壞了。

Q <= '1'; 

應該

t_tmp <= '1'; 

有人意識到他們不可能讀輸出,引進t_tmp只有改變一半的代碼。

+0

這也是我的想法,但我並不完全確定 – Earlz 2012-04-20 16:52:30

+0

注意到作者,他說這也是正確的,當他上傳他的書的新版本時它也會被修復 – Earlz 2012-04-27 03:13:04