Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > clarification on generics

Reply
Thread Tools

clarification on generics

 
 
MattLFerraro
Guest
Posts: n/a
 
      02-11-2008
Hello,

I'm looking for clarification on a few points about using generics

1) In the component declaration, do all generics need to be defined?
For example; my entity declaration has 30 generics - and only want to
modify one in the component instantiation. So, can i just include
that one generic definition in the component declaration?

2) If I had a generic DATA_WIDTH : integer = 32 defined in my entity
declaration; what would happen if the component declaration changed
that definition to DATA_WIDTH : integer = 16 - and the component
instantiation does not have a generic mapping defined? Does the
components default assignment of the generic override the entities
default assignment of the generic?

Thanks,

Matt
 
Reply With Quote
 
 
 
 
KJ
Guest
Posts: n/a
 
      02-11-2008
On Feb 11, 11:10*am, MattLFerraro <(E-Mail Removed)> wrote:
> Hello,
>
> I'm looking for clarification on a few points about using generics
>
> 1) In the component declaration, do all generics need to be defined?
> For example; my entity declaration has 30 generics - and only want to
> modify one in the component instantiation. *So, can i just include
> that one generic definition in the component declaration?
>


As long as the other 29 generics have default values defined then yes
you only need to set the entry for the one that you want to modify.

> 2) If I had a generic DATA_WIDTH : integer = 32 *defined in my entity
> declaration; what would happen if the component declaration changed
> that definition to DATA_WIDTH : integer = 16 - and the component
> instantiation does not have a generic mapping defined? *Does the
> components default assignment of the generic override the entities
> default assignment of the generic?
>


I don't know...but the reason for not knowing is that I don't use
component definitions instead I use direct entity instantiation.
Maintenance of components definitions is a waste of time and prone to
sometimes subtle, sometimes not so subtle errors as well as
uncertainties in situations like the one you mention.

In any case, having ANY differences between the component definition
and the entity definition is just asking for trouble, there is no good
reason for them to have any differences...which leaves 'OOPS!' and !@#
%&(! as the reasons why they might be...which is why direct entity
instantiation is the better way to go.

Example:
U1 : my_widget generic map(...) port map(...); -- Using components
U1 : entity work.my_widget generic map(...) port map(...); -- Using
DEI

The only time you 'have' to use components is when the thing you are
instantiating is some form of 'black box' (i.e. you don't have the
source, only a pre-compiled something) that you are using in your
design. However in that situation, whoever it is that you got the
'black box' component from is not giving you the entity or
architecture in an editable form so you don't need to maintain that
code to insure that component/entity match.

Kevin Jennings
 
Reply With Quote
 
 
 
 
MattLFerraro
Guest
Posts: n/a
 
      02-12-2008
Thanks for the feedback. I didn't know you could instantiate
components that way.

I have not seen any examples or reference designs from FPGA vendors
that use that method. It is more like Verilog. And less time
consuming. Why wouldn't that method be shown more often?

On second glance; that method has always been described on my VHDL
quick ref card.

LABEL: COMPID
[[generic map ( {GENID => expr,} )]
port map ( {PORTID => SIGID,} )];

LABEL: entity [LIBID.]ENTITYID [(ARCHID)]
[[generic map ( {GENID => expr,} )]
port map ( {PORTID => SIGID,} )];

LABEL: configuration [LIBID.]CONFID
[[generic map ( {GENID => expr,} )]
port map ( {PORTID => SIGID,} )];

On Feb 11, 12:00 pm, KJ <(E-Mail Removed)> wrote:
> On Feb 11, 11:10 am, MattLFerraro <(E-Mail Removed)> wrote:
>
> > Hello,

>
> > I'm looking for clarification on a few points about using generics

>
> > 1) In the component declaration, do all generics need to be defined?
> > For example; my entity declaration has 30 generics - and only want to
> > modify one in the component instantiation. So, can i just include
> > that one generic definition in the component declaration?

>
> As long as the other 29 generics have default values defined then yes
> you only need to set the entry for the one that you want to modify.
>
> > 2) If I had a generic DATA_WIDTH : integer = 32 defined in my entity
> > declaration; what would happen if the component declaration changed
> > that definition to DATA_WIDTH : integer = 16 - and the component
> > instantiation does not have a generic mapping defined? Does the
> > components default assignment of the generic override the entities
> > default assignment of the generic?

>
> I don't know...but the reason for not knowing is that I don't use
> component definitions instead I use direct entity instantiation.
> Maintenance of components definitions is a waste of time and prone to
> sometimes subtle, sometimes not so subtle errors as well as
> uncertainties in situations like the one you mention.
>
> In any case, having ANY differences between the component definition
> and the entity definition is just asking for trouble, there is no good
> reason for them to have any differences...which leaves 'OOPS!' and !@#
> %&(! as the reasons why they might be...which is why direct entity
> instantiation is the better way to go.
>
> Example:
> U1 : my_widget generic map(...) port map(...); -- Using components
> U1 : entity work.my_widget generic map(...) port map(...); -- Using
> DEI
>
> The only time you 'have' to use components is when the thing you are
> instantiating is some form of 'black box' (i.e. you don't have the
> source, only a pre-compiled something) that you are using in your
> design. However in that situation, whoever it is that you got the
> 'black box' component from is not giving you the entity or
> architecture in an editable form so you don't need to maintain that
> code to insure that component/entity match.
>
> Kevin Jennings


 
Reply With Quote
 
Mike Treseler
Guest
Posts: n/a
 
      02-12-2008
MattLFerraro wrote:
> I didn't know you could instantiate
> components that way.


Yes.
The vhdl language has no marketing department.

> I have not seen any examples or reference designs from FPGA vendors
> that use that method.


The FPGA vendors would prefer that I
instance their black box netlist rather than
portable code. This translates
into an unbound component instance 'wizard' synthesis
and a purposely non-synthesizable simulation model.
This causes no end of confusion and questions to
this newsgroup.

To their credit, the vendors do document
some synthesis templates in but I have never seen
a direct instance example.

Here two that I dug up:

From http://home.comcast.net/~mike_treseler/oe_demo.vhd:

oe_demo_1 : entity work.oe_demo
port map (reset => reset_s, -- [in]
clock => clock_s, -- [in]
data => data_s, -- [inout]
ready => ready_s, -- [out]
oe => oe_s); -- [in]

From: http://home.comcast.net/~mike_treseler/test_uart.vhd

dut : entity work.uart
generic map (char_len_g => tb_char_g, -- for vsim cmd line
tic_per_bit_g => tb_tics_g)
port map (
clock => clk_s, -- [in] -- by tb_clk
reset => rst_s, -- [in] -- by tb_clk
address => address_s, -- [in] -- by main
writeData => writeData_s, -- [in] -- by main
write_stb => write_stb_s, -- [in] -- by main
readData => readData_s, -- [out]-- by uut
read_stb => read_stb_s, -- [in] -- by main
serialIn => serialIn_s, -- [in] -- by main,loopback dest
serialOut => serialOut_s -- [out]-- by uut, loopback src
);

> It is more like Verilog. And less time consuming.


Exactly

> Why wouldn't that method be shown more often?


Tradition.

-- Mike Treseler
 
Reply With Quote
 
Andy
Guest
Posts: n/a
 
      02-12-2008
On Feb 12, 11:15 am, Mike Treseler <(E-Mail Removed)> wrote:
> MattLFerraro wrote:
> > I didn't know you could instantiate
> > components that way.

>
> Yes.
> The vhdl language has no marketing department.
>
> > I have not seen any examples or reference designs from FPGA vendors
> > that use that method.

>
> The FPGA vendors would prefer that I
> instance their black box netlist rather than
> portable code. This translates
> into an unbound component instance 'wizard' synthesis
> and a purposely non-synthesizable simulation model.
> This causes no end of confusion and questions to
> this newsgroup.
>
> To their credit, the vendors do document
> some synthesis templates in but I have never seen
> a direct instance example.
>
> Here two that I dug up:
>
> Fromhttp://home.comcast.net/~mike_treseler/oe_demo.vhd:
>
> oe_demo_1 : entity work.oe_demo
> port map (reset => reset_s, -- [in]
> clock => clock_s, -- [in]
> data => data_s, -- [inout]
> ready => ready_s, -- [out]
> oe => oe_s); -- [in]
>
> From:http://home.comcast.net/~mike_treseler/test_uart.vhd
>
> dut : entity work.uart
> generic map (char_len_g => tb_char_g, -- for vsim cmd line
> tic_per_bit_g => tb_tics_g)
> port map (
> clock => clk_s, -- [in] -- by tb_clk
> reset => rst_s, -- [in] -- by tb_clk
> address => address_s, -- [in] -- by main
> writeData => writeData_s, -- [in] -- by main
> write_stb => write_stb_s, -- [in] -- by main
> readData => readData_s, -- [out]-- by uut
> read_stb => read_stb_s, -- [in] -- by main
> serialIn => serialIn_s, -- [in] -- by main,loopback dest
> serialOut => serialOut_s -- [out]-- by uut, loopback src
> );
>
> > It is more like Verilog. And less time consuming.

>
> Exactly
>
> > Why wouldn't that method be shown more often?

>
> Tradition.
>
> -- Mike Treseler


Direct entity instantiation was added to VHDL in 1993, so many tools
were initially developed before it was adopted, and therefore did not
use it. Updating working examples in tool documentation would be nice,
but has a lower priority than fixing non-working examples.

Andy
 
Reply With Quote
 
Paul Uiterlinden
Guest
Posts: n/a
 
      02-12-2008
KJ wrote:

>> 2) If I had a generic DATA_WIDTH : integer = 32 defined in my entity
>> declaration; what would happen if the component declaration changed
>> that definition to DATA_WIDTH : integer = 16 - and the component
>> instantiation does not have a generic mapping defined? Does the
>> components default assignment of the generic override the entities
>> default assignment of the generic?


Yes indeed, that is how it works.

> The only time you 'have' to use components is when the thing you are
> instantiating is some form of 'black box' (i.e. you don't have the
> source, only a pre-compiled something) that you are using in your
> design.


As long as there is a compiled entity in a library, it should not matter how
the instantiation is done. I would expect that both direct- and component-
instantiation work.

--
Paul Uiterlinden
www.aimvalley.nl
e-mail addres: remove the not.
 
Reply With Quote
 
Mike Treseler
Guest
Posts: n/a
 
      02-12-2008
Paul Uiterlinden wrote:

> As long as there is a compiled entity in a library, it should not matter how
> the instantiation is done. I would expect that both direct- and component-
> instantiation work.


I wonder if a direct instance of
an entity with a null architecture would
would look enough like an unbound component
for vendor synthesis to match the netlist id.
Hmmm. Worth a try.

-- Mike Treseler
 
Reply With Quote
 
Mark McDougall
Guest
Posts: n/a
 
      02-13-2008
MattLFerraro wrote:

> 2) If I had a generic DATA_WIDTH : integer = 32 defined in my entity
> declaration; what would happen if the component declaration changed
> that definition to DATA_WIDTH : integer = 16 - and the component
> instantiation does not have a generic mapping defined? Does the
> components default assignment of the generic override the entities
> default assignment of the generic?


Since the instantiation "sees" the component declaration and not the
entity declaration, I'd *guess* that it would use the value of the generic
from the component. But it's only a guess...

Regards,

--
Mark McDougall, Engineer
Virtual Logic Pty Ltd, <http://www.vl.com.au>
21-25 King St, Rockdale, 2216
Ph: +612-9599-3255 Fax: +612-9599-3266
 
Reply With Quote
 
KJ
Guest
Posts: n/a
 
      02-13-2008
On Feb 12, 5:34*pm, Paul Uiterlinden <(E-Mail Removed)> wrote:
> KJ wrote:


> > The only time you 'have' to use components is when the thing you are
> > instantiating is some form of 'black box' (i.e. you don't have the
> > source, only a pre-compiled something) that you are using in your
> > design.

>
> As long as there is a compiled entity in a library, it should not matter how
> the instantiation is done. I would expect that both direct- and component-
> instantiation work.
>


Both methods 'work', my only point is that using components is more
prone to producing otherwise avoidable errors when you're actively
designing the widget and the interface to the widget is somewhat in
flux (i.e. the entity and therefore the component signals/parameters
are changing). Using direct instantiation the compiler will
immediately flag when any usage of widget does not match the entity
definition if you do a 'compile all'.

When you use components you have to update the component definition
(preferably by copy/paste) to match what you just typed in for the
change to the entity and then go to each of the usages of the widget
and update. If you forget to update the component, things compile
just fine and won't fail until elaboration when you thought you ready
to start sim.

If you follow the traditional approach of defining the component prior
to every usage (the worst possible way in my view) then you make even
more work since a change to the entity needs to be reflected in
updated component definition at each point of use.

I'd much prefer the computer to do the work of catching places where
I've forgotten to update a usage of a widget then to spend my own time
trying to figure it out. From my perspective, the advantages of using
components (i.e. can compile files in any order; can change default
values) do not even come close to the advantages of not using them.

Kevin Jennings
 
Reply With Quote
 
KJ
Guest
Posts: n/a
 
      02-13-2008
On Feb 12, 7:07*pm, Mark McDougall <(E-Mail Removed)> wrote:
> MattLFerraro wrote:
> > 2) If I had a generic DATA_WIDTH : integer = 32 *defined in my entity
> > declaration; what would happen if the component declaration changed
> > that definition to DATA_WIDTH : integer = 16 - and the component
> > instantiation does not have a generic mapping defined? *Does the
> > components default assignment of the generic override the entities
> > default assignment of the generic?

>
> Since the instantiation "sees" the component declaration and not the
> entity declaration, I'd *guess* that it would use the value of the generic
> from the component. But it's only a guess...
>


You're correct. In the sample below, Modelsim reports that the
generic has taken on the default value as assigned by the component
definition overriding the default value as assigned by the entity
definition.

KJ
------------------
entity Foo_Entity is generic(Parm: integer := 1);
end Foo_Entity;
architecture RTL of Foo_Entity is
begin
end RTL;

entity tb_Foo_Entity is
end tb_Foo_Entity;
architecture RTL of tb_Foo_Entity is
component Foo_Entity is
generic(Parm: integer := 10);
end component Foo_Entity;
begin
DUT : Foo_Entity;
end RTL;
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
generics depending on generics Soul VHDL 0 02-02-2009 09:14 AM
generics Object.getClass clarification. "<?>" vs "<? extends Object>" odwl Java 1 06-15-2006 09:17 PM
Clarification Term: "Behavioural Description" Nikos Mitas VHDL 2 09-27-2005 05:36 AM
Can't convert a generics list of objects into a generics list ofinterfaces Juergen Berchtel Java 1 05-20-2005 02:07 PM
clarification =?Utf-8?B?c3JpbmF0aGU=?= Microsoft Certification 0 05-22-2004 11:06 AM



Advertisments