2013-04-02 41 views
0

我有一個VHDL設計問題。 我有N個相似的實體需要一些輸入,他們每個產生一個STD_LOGIC輸出 。VHDL位聚合

實施例:

entity example1 is 
begin 
    ... 
    result_1 : out std_logic; 
end example1; 

entity example2 is 
begin 
    ... 
    result_2 : out std_logic; 
end example2; 

... 

我正在尋找一種方法來聚集所有在一個UNSIGNED那些單個位結果 - 使得V(I)= result_i保持結果信號V(N 1 DOWNTO 0)。

目前,我的做法是這樣的:

entity ResultAggregation is 
    port (
     result_1 : in std_logic; 
     result_2 : in std_logic; 
     aggregate_results : out unsigned(1 downto 0) 
    ); 
end ResultAggregation; 

architecture Behavioral of ResultAggregation is 
begin 
    aggregate_results <= result_2 & result_1; 
end Behavioral; 

我發現這種方法相當笨拙。我正在尋找的是一個更自動的解決方案,例如,我可以提供數字N,以便生成適當的引腳。

我知道這是一個相當普遍的問題,但如果有人知道一個聰明的解決方案,請 告訴我。

由於提前,
斯文

回答

0

我的建議將是省略ResultAggregation實體,只定義在同一水平上一個aggregate_results信號作爲example1example2等實體。然後,您可以舉例說明這些實體

i_example1 : entity work.example1 
port map (
    ... 
    result_1 => aggregate_results(0)); 

i_example2 : entity work.example2 
port map (
    ... 
    result_2 => aggregate_results(1)); 

你可以做的aggregate_results向量的寬度上水平的通用,你實例化example1等實體。

你可以得到引腳的通用號碼的唯一方法是定義你的ResultsAggregation實體

entity ResultAggregation is 
    generic (
     N_RESULTS : integer 
    ); 
    port (
     results : in std_logic_vector(N_RESULTS-1 downto 0); 
     aggregate_results : out std_logic_vector(N_RESULTS-1 downto 0) 
    ); 
end ResultAggregation; 

但隨後這個實體將只包含這使得這個實體毫無意義的聲明aggregate_results <= results

0

使用了/生成的語句,如果塊是相同的:

n_examples: for i in 0 to (N-1) generate 
    inst_example: example_entity 
     port map(
      ... 
      result => V(i); 
    ); 
end generate n_examples; 

如果塊有類似的實體,但不同funcitonality,你仍然可以使用這種方法:

... 
inst_ex1: example1 
port map(
    ..., 
    result_1 => V(1) 
); 

inst_ex2: example2 
port map(
    ..., 
    result_2 => V(2) 
); 
....