VHDL:(vcom-1136:std_logic_vector undefined)

时间:2015-05-16 17:04:13

标签: syntax vhdl

获得一个看似无法解释的语法错误,说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是未知的引用。

1 个答案:

答案 0 :(得分:2)

IEEE.std_logic_1164.all之前还需要使用entity,例如:

library IEEE;
use IEEE.std_logic_1164.all;

entity lab2 is

第一个IEEE.std_logic_1164.all仅适用于同一个包的packagepackage body,但不适用于entity或{{1}等任何其他设计对象即使这些恰好在同一个文件中。

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