2017-03-14 31 views
0

我正在做一個任務,用n條選擇線做2^n輸出的解複用。我有我的輸入(x位寬,在這種情況下,x是32位)和我的使能引腳照顧。但我不知道如何去設置實體,以便我的輸出是2^n個選擇線。到目前爲止,我的實體聲明如下:如何使用VHDL爲n個選擇行設置1至2^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位(32位「01001011」序列)解複用。我想把它拿過去,並在解複用器的另一端傳遞2^n個路徑。選擇線決定採取哪條路徑。我想知道如何爲輸出和選擇引腳設置實體聲明。

+0

您的問題並不清楚:您希望選擇引腳做什麼以及您希望輸出顯示什麼? – JHBonarius

+0

@ J.H.Bonarius我已經更新了上面的問題。 – dikshant

回答

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解釋相同。

相關問題