使用 vhdl 中的类型创建二维数组

Creating a 2d array using types in vhdl

你能帮我用 VHDL 中的类型做这个矩阵声明吗?

-- A    B     Q    Y
(('0', '0', "000", 0),
 ('0', '1', "ZZ1", 1),
 ('1', '0', "Z1Z", 1),
 ('1', '1', "1ZZ", 2))


类型声明可能如下所示:

type element_t is record
  A : std_logic;
  B : std_logic;
  Q : std_logic_vector(2 downto 0);
  Y : natural;
end record;

type array_t is array (0 to 3) of element_t;

constant VALUE : array_t :=
  -- A    B     Q    Y
  (('0', '0', "000", 0),
   ('0', '1', "ZZ1", 1),
   ('1', '0', "Z1Z", 1),
   ('1', '1', "1ZZ", 2));

我建议您获取 VHDL 编译器和模拟器,例如免费的 ModelSim-Intel FPGA Starter Edition;那么你可以轻松地自己尝试来VHDL。