【问题标题】:VHDL: (vcom-1136: std_logic_vector undefined)VHDL:(vcom-1136:std_logic_vector 未定义)
【发布时间】:2015-05-16 17:04:12
【问题描述】:

得到一个看似无法解释的语法错误,说 std_logic 未定义,即使它在代码的早期编译!第一个错误发生在实体的开头或第 37 行。我相信它与创建我自己的包有关,但这是我以前做过的事情,从来没有出现过这个错误!感谢您的帮助。

  library IEEE;
  use IEEE.std_logic_1164.all;
  use IEEE.std_logic_unsigned.all;

  package lab2 is  
  constant SWIDTH: integer := 4;
  subtype state_type is 
    std_logic_vector(SWIDTH-1 downto 0); 

  constant S1: state_type  := "0000"; --these are the "reset states"
  constant S2: state_type  := "0001";
  constant S3: state_type  := "0010";
  constant S4: state_type  := "0011";
  constant S5: state_type  := "0101";
  constant S6: state_type  := "0110";
  constant S7: state_type  := "0111"; -- these are the "show letter" states
  constant S8: state_type  := "1000";
  constant S9: state_type  := "1001";
  constant S10: state_type := "1010";
  constant S11: state_type := "1011";

  constant G : std_logic_vector(7 downto 0) := x"47";
  constant a : std_logic_vector(7 downto 0) := x"61";
  constant r : std_logic_vector(7 downto 0) := x"72";
  constant e : std_logic_vector(7 downto 0) := x"65";
  constant send1 : std_logic_vector(7 downto 0) := x"38";
  constant send2 : std_logic_vector(7 downto 0) := x"0C";
  constant send3 : std_logic_vector(7 downto 0) := x"01";
  constant send4 : std_logic_vector(7 downto 0) := x"06";
  constant send5 : std_logic_vector(7 downto 0) := x"80";

end package;

------------------------------------

entity lab2 is
    port(     key : in std_logic_vector(3 downto 0);  -- pushbutton switches
            sw : in std_logic_vector(8 downto 0);  -- slide switches
            ledg : out std_logic_vector(7 downto 0);
            lcd_rw : out std_logic;
            lcd_en : out std_logic;
            lcd_rs : out std_logic;
            lcd_on : out std_logic;
            lcd_blon : out std_logic;
            lcd_data : out std_logic_vector(7 downto 0);
            hex0 : out std_logic_vector(6 downto 0));  -- one of the 7-segment diplays
end lab2 ;

错误发生在端口中,导致 std_logic 和 std_logic_vector 是未知引用。

【问题讨论】:

    标签: syntax vhdl


    【解决方案1】:

    IEEE.std_logic_1164.all也需要在entity之前使用,如:

    library IEEE;
    use IEEE.std_logic_1164.all;
    
    entity lab2 is
    

    第一个IEEE.std_logic_1164.all 仅适用于同一包的packagepackage body,但不适用于任何其他设计对象,例如entitypackage,即使这些恰好在同一个文件。

    这允许在同一个文件中创建不同的设计对象,同时仍然控制库和包中的可见对象。

    【讨论】:

    • 这修复了 std_logic 错误,但不是我定义的类型 state_type 给了我一个未知的参考。我还必须以某种方式包含包 lab2 吗?
    • 我在lab2 包之外没有看到对state_type 类型的引用,那么您从哪里得到“未知引用”错误?如果您在另一个实体中使用lab2state_type 类型,则添加use work.lab2.alluse work.lab2.all 以引用state_type 作为lab2.state_type
    • 啊抱歉,我没有在帖子中包含的代码更进一步。这似乎解决了我的错误,非常感谢!
    • 除了 Morten 的好答案之外,您至少还需要解决一件事。两个主要单元(包、实体、配置)在同一个库(工作)中不能具有相同的简单名称。有两个明显的解决方案,更改包的名称(例如lab2_pkg)或放入单独的库中。请参阅 IEEE Std 1076-2008 13.1 设计单位第 5 段。
    • @gurtn:如果这是您问题的答案,请单击复选标记接受答案,如here 所述。在Help Center 中查看更多信息。
    猜你喜欢
    • 2015-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多