2013-04-02 40 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) 
); 
....