【问题标题】:VHDL recursive component/entityVHDL递归组件/实体
【发布时间】:2012-12-17 08:12:40
【问题描述】:

我希望这是可能的。我希望能够编写这样的递归代码:

entity myEntity
    generic (
      size : natural  -- a power of 2
    )
    port (
       -- whatever
    );
end;

architecture structural of myEntity is
begin
    smallerEntity : entity component.myEntity(structural)
        generic map (
            size => size/2
        );
        port map ( 
            ... 
        );
end;

所以每个架构都会实例化一个较小的版本。但是,在通用“大小”的某个值下,我希望有一个不同的实现。

这可以通过配置来完成吗?如果是这样,怎么做?

至于为什么我希望能够做到这一点 - 这样我就可以构建可重用的代码来计算 FFT/DCT 和类似的转换。

【问题讨论】:

  • 有一篇 Peter Ashenden 的经典论文,名为“Recursive and Repetitive Hardware Models in VHDL”,您可以在 Google 上搜索。

标签: recursion configuration vhdl


【解决方案1】:

可以在 VHDL 中使用递归。但是您需要将您的实例化封装在 if-generate 语句中。比如:

recursive_structure : if size/2 > 0 generate 
    smallerEntity : entity <library_name>.myEntity(structural)
        generic map (
            size => size/2
        )
        port map ( 
            ... 
        );
end generate recursive_structure; 

【讨论】:

  • 即使 generate 语句在 myEntity 的架构中?这对我来说是新的。
  • @Stacey :这就是 VHDL 坚持“单独编译”的重点——实体首先被编译,这意味着它可以在任何设计中使用,然后再编写匹配的架构。
【解决方案2】:

我使用如下函数:

-- convert natural to min vector length
function min_len_uns(arg : natural) return natural is       
begin 
     case arg is

         when 1 | 0 =>
            return 1;
         when others =>
            return 1 + min_len_uns(arg/2);
     end case;
end;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-07-13
    • 2017-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多