VHDL 阵列初始化错误

VHDL Array Initialization Error

我写了简单的代码,只定义了一个数组。但它显示以下三个错误。

ERROR:HDLCompiler:806 - Syntax error near "type". Parsing entity .

ERROR:HDLCompiler:854 - Unit ignored due to previous errors. Parsing architecture of entity .

ERROR:HDLCompiler:374 - Entity is not yet compiled.

   library IEEE;
   use IEEE.std_logic_1164.all;

    type NIBBLE is ARRAY (3 downto 0) of std_ulogic;

    entity kelvin is
    end kelvin;

    architecture ospl of kelvin is
    begin
    end ospl;

在 VHDL 中,在 设计单元 之外(即在 实体 架构包主体)。此外,您必须在 声明区域 内(即 architecturebegin 之间或 processbegin 等)。

所以,你的代码应该是

library IEEE;
use IEEE.std_logic_1164.all;

entity kelvin is
end kelvin;

architecture ospl of kelvin is
  type NIBBLE is ARRAY (3 downto 0) of std_ulogic;
begin