SOGO論壇

標題: VHDL process 執行時機? [列印本頁]

作者: 臭鴨蛋    時間: 2016-2-17 23:15:07     標題: VHDL process 執行時機?

小弟我看書上寫 VHDL process(sensitivity list),
process運作是偵測到 sensitivity list 訊號有變化就會執行底下所有敘述,
但小弟實際上我實際上測試,如果沒有掛一個if來偵測CLK的訊號變化根本不會動。

小弟以前學VHDL的時候都是掛一個CLK來運作,當初也沒想太多為什麼,
最近自己在玩卻一直搞不懂為什麼不能這樣操作,請各位大大指點迷津,謝謝。

不會動的程式碼:
library ieee;
Use ieee.std_logic_1164.all;
Use ieee.std_logic_arith.all;
Use ieee.std_logic_unsigned.all;

entity test is
        port (
                CLK : in  std_logic;
                SO : out std_logic_vector(2 downto 0)
        );
end test;


architecture output of test is
        signal buf : std_logic_vector(2 downto 0) := "000";
begin
        process(CLK)
        begin
                buf <= buf + 1;
                SO <= buf;
        end process;
end output;

會動的程式碼:
library ieee;
Use ieee.std_logic_1164.all;
Use ieee.std_logic_arith.all;
Use ieee.std_logic_unsigned.all;

entity test is
        port (
                CLK : in  std_logic;
                SO : out std_logic_vector(2 downto 0)
        );
end test;


architecture output of test is
        signal buf : std_logic_vector(2 downto 0) := "000";
begin
        process(CLK)
        begin
                if ((CLK'event) and (CLK='1')) then
                        buf <= buf + 1;
                        SO <= buf;
                end if;
        end process;
end output;
作者: ryoownt    時間: 2016-6-1 23:45:20

恩...該怎麼說勒.....
因為你要它處理時脈信號,但是begin之後沒有clk的描述句
在組譯器來看,就像是和它說請依照clk做事,但實際硬體上沒給clk的輸入點一樣
作者: 紅塵孤鳥    時間: 2016-6-2 08:04:02

你的process依據CLK動作,但你沒有描述要動作的條件,後面那個程式中,你加上一段if,那就是描述要動作的條件。




歡迎光臨 SOGO論壇 (https://oursogo.com/) Powered by OURSOGO.COM