How to declare output array in VHDL?

落爺英雄遲暮 提交于 2020-03-23 06:19:07

问题


In VHDL how we can declare output array. I know to how to declare a signal as array, by first declaring the type and then defining a signal as this type. Is it possible to do same on output?


回答1:


If you want to declare a new type of an array for use on module output, thus not use some existing array type like std_logic_vector, then the type must be declared in a package, in order to make the type available where the module is instantiated. Example below:

library ieee;
use ieee.std_logic_1164.all;

package pkg is
  type slv8_array_t is array (natural range <>) of std_logic_vector(7 downto 0);
end package;

package body pkg is
end package body;


library ieee;
use ieee.std_logic_1164.all;
library work;
use work.pkg.all;

entity mdl is
  port(
    array_o : out slv8_array_t(0 to 3));
end entity;

architecture syn of mdl is
begin
  array_o <= (others => (others => '0'));
end architecture;

A similar approach applies to other declared types, like for example records, or for other kind of interface type sharing like input.



来源:https://stackoverflow.com/questions/28187621/how-to-declare-output-array-in-vhdl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!