2015-12-02 52 views
0

我正在使用modelsim。我寫了簡單的代碼,但我得到錯誤。錯誤:VHDL編譯器退出

library ieee; 
use ieee.std_logic_1164.all; 
use ieee.numeric_std.all; 



entity clk_counter is 
port(output : out bit; 
    clk : in bit 
    ); 
end clk_counter; 

architecture rtl of clk_counter_arch is 

    signal clock_counter_output_flag: bit; 
    constant clock_max_count : integer := 20000; 


begin 

    process (clock_counter_output_flag, clk,CLK'event) 

     variable clock_count : integer := 0; 
     --constant clock_max_count : integer := 20000; 
     variable clock_out : bit := 0; 
     -- wait until CLK'event and CLK='1'; 
      begin 
       if (CLK'event and CLK='1') then 
        clock_count := clock_count+1; 
        if (clock_count = clock_max_count) then 
         clock_out := 1; 
        else 
         clock_out := 0; 
        end if 
       end if 
       clock_counter_output_flag <= clock_out;   
      end process; 


END Architecture; 

錯誤messege:

# ** Error: (vcom-11) Could not find work.clk_counter_arch.      
#                   
# ** Error: C:/Modeltech_pe_edu_10.4a/examples/work/src/clk_counter(13):    VHDL Compiler exiting 

回答

0

你的實體名稱爲CLK_COUNTER並且您已經定義clk_counter_arch的架構RTL。因此,你會得到錯誤。將clk_counter_arch更改爲clk_counter。

其次,您應該將體系結束作爲結束rtl。

此外,爲什麼你使用兩個額外的變量clock_out和clock_counter_output_flag?如果你想要這個值作爲你的代碼的輸出,你應該簡單地寫

if (CLK'event and CLK='1') then 
        clock_count := clock_count+1; 
        if (clock_count = clock_max_count) then 
         output<='1'; 
        else 
         output <='0'; 
        end if; 
       end if; 
+0

是的,我剛剛做到了。在發佈這個問題之前,我應該正確地檢查代碼。無論如何感謝您的寶貴回答 –

+0

您的第一點是有效的。 '其次,你應該結束體系結構rtl。'這是您通常不會成功執行第三方的風格。至於剩下的編碼風格挑剔,你也可以指出我們在結尾if後仍然缺少分號(也存在於你的答案中)。靈敏度列表錯誤和冗餘。將數字文字分配給類型位(3位)。從原來的'clock_counter_output_flag'到'output'的缺失分配(顯然)。 – user1155120

+0

它絕對是很好的做法,指出所有的錯誤。但是,當他解決了他的問題時,我沒有編輯我的答案。 – Anonymous