2015-12-02 485 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