【问题标题】:VHDL bit aggregationVHDL 位聚合
【发布时间】:2013-04-02 09:10:58
【问题描述】:

我有一个 VHDL 设计问题。 我有 N 个相似的实体,它们接受一些输入,每个实体都生成 STD_LOGIC 输出。

例子:

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

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

...

我正在寻找一种方法将所有这些单个位结果聚合为一个 UNSIGNED(N - 1 downto 0) 结果信号 V,使得 V(i) = result_i 成立。

目前,我的方法是这样的:

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 以便生成适当的引脚。

我知道这是一个相当笼统的问题,但如果有人知道一个聪明的解决方案,请 告诉我。

提前致谢,
斯文

【问题讨论】:

    标签: vector vhdl bit


    【解决方案1】:

    我的建议是省略ResultAggregation 实体,仅在与example1example2 等实体相同的级别上定义aggregate_results 信号。然后您可以将这些实体实例化为

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

    您可以在实例化example1 等实体的级别上将aggregate_results 向量的宽度设为通用。

    获得通用引脚数的唯一方法是将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 &lt;= results,这使得这个实体毫无意义。

    【讨论】:

      【解决方案2】:

      如果块相同,则使用 for/generate 语句:

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

      如果块具有相似的实体但功能不同,您仍然可以使用这种方法:

      ...  
      inst_ex1: example1 
      port map(
          ...,
          result_1 => V(1)
      );
      
      inst_ex2: example2 
      port map(
          ...,
          result_2 => V(2)
      );
      ....
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-04-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多