如何使用VHDL为具有n个选择行的1到2^n输出解复用设置实体?

如何使用VHDL为具有n个选择行的1到2^n输出解复用设置实体?,vhdl,Vhdl,我正在处理一项任务,使用2^n个输出和n个选择行进行解复用。我有一个我的输入(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 p

我正在处理一项任务,使用2^n个输出和n个选择行进行解复用。我有一个我的输入(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;

基本上我有一个解复用器,它接受一个宽度为x位的输入(“01001011”32位序列)。我想把它放到解复用器的另一边,在那里有2^n条路径。选择行确定要采用的路径。我想知道如何为输出和选择引脚设置实体声明。

如果我理解正确,您有一个输入(x位)和2^n个输出(每个x位) 最简单的方法是在单独的包中定义无约束数组数据类型。(注意:这是VHDL-2008!)

ieee库;
使用ieee.std_logic_1164.all;
包数组类型为
类型std_逻辑_向量_数组是std_逻辑_向量的数组(自然范围);
端包装;
图书馆ieee;
使用ieee.std_logic_1164.all;
使用work.array_type.all;
--实体声明
实体DEMUX是
--获取整数的大小
一般的(
x:阳性;
n:是的
);
--映射输入、输出、选择和启用信号端口
港口(
Inp:in标准逻辑向量(x-1向下至0);
Ena:标准逻辑;
Sel:标准逻辑向量(0到n-1);
输出:输出标准逻辑向量阵列(0至(2**n)-1)(x-1向下至0)
);
终端解复用;

编辑:我刚刚发现了相同的解释。

您的问题不清楚:您希望选择的管脚做什么?您希望输出显示什么?@J.H.Bonarius我已更新了上述问题。
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;