我正在进行一项任务,使用n条选择线做2 ^ n输出的demux。我有一个输入(x位宽,在这种情况下x是32位),我的启动引脚得到了处理。但我不知道如何设置实体,以便我的输出为2 ^ n,有n条选择线。到目前为止,我的实体声明如下:
-- Entity declaration
entity DEMUX is
-- Get the size of an integer
generic(Len :integer);
-- Map input, output, selection and enable signal ports
port(
Inp : in std_logic_vector(Len-1 downto 0); -- Input pin
Ena : in std_logic; -- Enable pin
Sel : --How to set select lines?
Oup : --How to set outputs?
);
end DEMUX;
所以基本上我有一个demux,它接受一个x位宽的输入(" 01001011" 32位序列)。我想把它拿到并在demux的另一侧传递,它需要2 ^ n个路径。选择行确定要采用的路径。我想知道如何为输出和选择引脚设置实体声明。
答案 0 :(得分:1)
如果我理解正确,你有一个输入(x位)和2 ^ n输出(每个x位) 最简单的方法是在单独的包中定义无约束的数组数据类型。 (注意:这是VHDL-2008!)
library ieee;
use ieee.std_logic_1164.all;
package array_type is
type std_logic_vector_array is array (natural range <>) of std_logic_vector;
end package;
library ieee;
use ieee.std_logic_1164.all;
use work.array_type.all;
-- Entity declaration
entity DEMUX is
-- Get the size of an integer
generic(
x : positive;
n : positive
);
-- Map input, output, selection and enable signal ports
port(
Inp : in std_logic_vector(x-1 downto 0);
Ena : in std_logic;
Sel : in std_logic_vector(0 to n-1);
Oup : out std_logic_vector_array(0 to (2**n)-1)(x-1 downto 0)
);
end DEMUX;
编辑:我刚刚发现this topic解释相同的内容。