2012-02-14 40 views
2

我想實現一個D觸發器在VHDL中,使用我寫的D鎖存器。 但時鐘似乎有錯誤,我無法弄清楚是什麼。D觸發器在VHDL

這是我的D鎖存器的代碼。

Library ieee; 
Use ieee.std_logic_1164.all; 

entity d_latch is 
    port (c,d : in std_logic; 
     q,nq : out std_logic); 
end d_latch; 

architecture arch of d_latch is 

Signal qt, nqt: std_logic; 

begin 

    qt <= (d nand c) nand nqt; 
    nqt <= ((not d) nand c) nand qt; 

    q <= qt; 
    nq <= nqt; 

end arch; 

我測試了它和它的作品,這裏是我的d觸發器代碼:

Library ieee; 
Use ieee.std_logic_1164.all; 

entity d_flipflop is 
    port (d,clock : in std_logic; 
     q,nq : out std_logic); 
end d_flipflop; 

architecture arch of d_flipflop is 

Component d_latch 
Port 
(
    d, clk: in std_logic; 
    q, nq : out std_logic 
); 
End Component ; 

Signal qt, nqt: std_logic; 

begin 

dl1: d_latch port map (
    d => d, 
    clk => not clock, 
    q => qt 
); 

dl2: d_latch port map (
    d => qt, 
    clk => clock, 
    q => q, 
    nq => nq 
); 

end arch; 

,這裏是錯誤:

** Error: /home/devplayer/CSC343/Lab_2_Content/d_flipflop.vhd(25): (vcom-1436) Use of non globally static actual (prefix expression) of formal "clk" requires VHDL 2008. 

謝謝

回答

2

您不能在端口分配中使用完整表達式。當將時鐘分配給dl1實例的端口時,不需要反轉時鐘,而是創建一個反向時鐘並使用該時鐘:

clockn <= not clock; 

dl1: d_latch port map (
    d => d, 
    clk => clockn, 
    q => qt 
); 
+0

明白了,謝謝! – ratsimihah 2012-02-15 03:30:34