开发者

Why do I need to redeclare VHDL components before instantiating them in other architectures?

开发者 https://www.devze.com 2023-01-15 07:17 出处:网络
I\'ve been scratching my head since my first VHDL class and decided to post my question here. Given that 开发者_如何学运维I have a declared entity (and also an architecture of it) and want to instant

I've been scratching my head since my first VHDL class and decided to post my question here.

Given that 开发者_如何学运维I have a declared entity (and also an architecture of it) and want to instantiate it inside another architecture, why is it that I seemingly have to redeclare the "entity" (component) inside this containing architecture before instantiating it?

Isn't the compiler smart enough to match an instantiation to its architecture just by its name? Where is the need for the component declaration?


You can directly instantiate the component, if desired:

  MyInstantiatedEntity : entity work.MyEntity_E
    generic map (
        config          => whatever)
    port map (
        clk             => signal1,
        clk_vid         => signal2,
        ...

Creating a component declaration gives you the extra ability to change what gets bound to the instantiation via a configuration specification or similar.


Back when I did my VHDL assignments back when I was in school, I was required to have all our code all in one file so I don't remember whether or not you could write one file for each module and how it was done.

That being said, you would have to declare the entity you would use when defining the behavior, if you were using it much in the same way that you would define prototypes, structures, classes and whatnot in C or C++. The difference here is that you don't have the luxury of defining header files for this "redeclaration" in VHDL (at least I don't think there is an equivalent). So it seems perfectly reasonable to me to have to do this. Note that VHDL came out when C was very common and the compilers weren't "smart enough" as they are today.

A VHDL guru might have a definitive answer for this but this is how I understand it.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号