Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VHDL recursive component/entity

I hope this is possible. I want to be able to write recursive code like this:

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;

So each architecture instantiates a smaller version of itself. At some value of the generic 'size' I want to have a different implementation however.

Can this be done with configurations? If so, how?

As to why I'd like to be able to do this - so I can build reusable code for computing FFTs/DCTs and similar transforms.

like image 897
Bob Avatar asked Dec 17 '12 08:12

Bob


1 Answers

You can use recursion in VHDL. But you need to encapsulate your instantiation in an if-generate statement. Something like:

recursive_structure : if size/2 > 0 generate 
    smallerEntity : entity <library_name>.myEntity(structural)
        generic map (
            size => size/2
        )
        port map ( 
            ... 
        );
end generate recursive_structure; 
like image 95
Hendrik Avatar answered Nov 05 '22 15:11

Hendrik