如何使用 VHDL 为带有 n select 行的 1 到 2^n 输出多路分配器设置实体?

How do I setup entity for a 1 to 2^n output demux with n select lines using VHDL?

我正在做一个任务,做一个带有 2^n 个输出和 n select 行的多路分解器。我有一个输入(x 位宽,在这种情况下 x 是 32 位)并且我的启用引脚得到了处理。但我不知道如何设置实体,以便我的输出是 2^n 和 n select 行。到目前为止,我的实体声明如下所示:

-- 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 条路径。 select 行决定采用哪条路径。我想知道如何为输出和 select 引脚设置实体声明。

如果我理解正确的话,你有一个输入(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 解释相同。