Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

VHDL component instantiation

Status
Not open for further replies.

shaiko

Advanced Member level 5
Joined
Aug 20, 2011
Messages
2,644
Helped
303
Reputation
608
Reaction score
297
Trophy points
1,363
Activity points
18,302
Is it possible to put a component inside a package ?
If so, what is the correct syntax to instatiate it ?
 

Is it possible to put a component inside a package ?
If so, what is the correct syntax to instatiate it ?
The best place to put a component is inside a package...in the same file as the entity. So if you have an entity called 'Widget', the entity would be...
Code:
[LEFT][TABLE="class: vhdl syntaxHighlighter expand"]
[TR]
[TD="colspan: 2"]Code VHDL - [[COLOR=#226c22]expand[/COLOR]][/TD]
[/TR]
[TR="class: li1"]
[TD]
123[/TD]
[TD]
[COLOR=#000080][B]entity[/B][/COLOR] Widget [COLOR=#000080][B]is[/B][/COLOR] ...[COLOR=#000080][B]end[/B][/COLOR] Widget[COLOR=#000066];[/COLOR][/TD]
[/TR]
[/TABLE]
[/LEFT]

You would have a component definition like this...
Code:
[LEFT][TABLE="class: vhdl syntaxHighlighter expand"]
[TR]
[TD="colspan: 2"]Code VHDL - [[COLOR=#226c22]expand[/COLOR]][/TD]
[/TR]
[TR="class: li1"]
[TD]
123[/TD]
[TD]
[COLOR=#000080][B]component[/B][/COLOR] Widget [COLOR=#000080][B]is[/B][/COLOR] ...[COLOR=#000080][B]end[/B][/COLOR] [COLOR=#000080][B]component[/B][/COLOR] Widget[COLOR=#000066];[/COLOR][/TD]
[/TR]
[/TABLE]
[/LEFT]

Which you could then put into a package like this...

Code:
[LEFT][TABLE="class: vhdl syntaxHighlighter expand"]
[TR]
[TD="colspan: 2"]Code VHDL - [[COLOR=#226c22]expand[/COLOR]][/TD]
[/TR]
[TR="class: li1"]
[TD]
12345[/TD]
[TD]
[COLOR=#000080][B]package[/B][/COLOR] pkg_Widget    [COLOR=#000080][B]component[/B][/COLOR] Widget [COLOR=#000080][B]is[/B][/COLOR]     ...    [COLOR=#000080][B]end[/B][/COLOR] [COLOR=#000080][B]component[/B][/COLOR] Widget[COLOR=#000066];[/COLOR][COLOR=#000080][B]end[/B][/COLOR] [COLOR=#000080][B]package[/B][/COLOR] pkg_Widget[/TD]
[/TR]
[/TABLE]
[/LEFT]

To use the Widget, you would instantiate it like this....

Code:
[LEFT][TABLE="class: vhdl syntaxHighlighter expand"]
[TR]
[TD="colspan: 2"]Code VHDL - [[COLOR=#226c22]expand[/COLOR]][/TD]
[/TR]
[TR="class: li1"]
[TD]
123456[/TD]
[TD]
[COLOR=#000080][B]use[/B][/COLOR] [COLOR=#0000ff]work[/COLOR].pkg_Widget.[COLOR=#000080][B]all[/B][/COLOR][COLOR=#000066];[/COLOR]...[COLOR=#000080][B]architecture[/B][/COLOR] rtl [COLOR=#000080][B]of[/B][/COLOR] Use_The_Widget [COLOR=#000080][B]is[/B][/COLOR][COLOR=#000080][B]begin[/B][/COLOR]   The_Widget [COLOR=#000066]:[/COLOR] widget [COLOR=#000080][B]generic[/B][/COLOR] [COLOR=#000080][B]map[/B][/COLOR][COLOR=#000066]([/COLOR]...[COLOR=#000066])[/COLOR] [COLOR=#000080][B]port[/B][/COLOR] [COLOR=#000080][B]map[/B][/COLOR][COLOR=#000066]([/COLOR]...[COLOR=#000066])[/COLOR][COLOR=#000066];[/COLOR][COLOR=#000080][B]end[/B][/COLOR] rtl[COLOR=#000066];[/COLOR][/TD]
[/TR]
[/TABLE]
[/LEFT]

However, an even better way is to not even bother with components. They provide value in only a few specialized cases, for the most part they are just a near duplicate of the entity which then you need to manually make sure they stay the same (i.e. change a signal type, do it in both places; add or subtract a signal, do it in both places). While keeping the component and entity in the same file facilitates making the changes it is still unneeded work. Same example, but this time no component definition, you would instantiate it like this...

Code:
[LEFT][TABLE="class: vhdl syntaxHighlighter expand"]
[TR]
[TD="colspan: 2"]Code VHDL - [[COLOR=#226c22]expand[/COLOR]][/TD]
[/TR]
[TR="class: li1"]
[TD]
123456[/TD]
[TD]
...[COLOR=#000080][B]architecture[/B][/COLOR] rtl [COLOR=#000080][B]of[/B][/COLOR] Use_The_Widget [COLOR=#000080][B]is[/B][/COLOR][COLOR=#000080][B]begin[/B][/COLOR]   The_Widget [COLOR=#000066]:[/COLOR] [COLOR=#000080][B]entity[/B][/COLOR] [COLOR=#0000ff]work[/COLOR].widget [COLOR=#000080][B]generic[/B][/COLOR] [COLOR=#000080][B]map[/B][/COLOR][COLOR=#000066]([/COLOR]...[COLOR=#000066])[/COLOR] [COLOR=#000080][B]port[/B][/COLOR] [COLOR=#000080][B]map[/B][/COLOR][COLOR=#000066]([/COLOR]...[COLOR=#000066])[/COLOR][COLOR=#000066];[/COLOR][COLOR=#000080][B]end[/B][/COLOR] rtl[COLOR=#000066];[/COLOR][/TD]
[/TR]
[/TABLE]
[/LEFT]

Much simpler, less to go wrong.

Kevin Jennings
 
Last edited:
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top