Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

generics

1 view
Skip to first unread message

Marco

unread,
May 24, 2006, 8:58:13 AM5/24/06
to
Hi,
there's something i don't understand about generics. Suppose I have to
use a component within my top entity, so in the declarative part of my
architecture I place the component declaration, while in the body of
the architecture I insert its instantiation. Here's my doubt, if I
assign a different value in these 2 places (say I write "my_generic :
integer := 1" inside declaration, while "my_generic => 2" in the
instantiation), which one will be the one considered by the
application?


Component Declaration:

component <component_name>
generic (
my_generic : integer := 1;
<other generics>...
);
port (
<port_name> : <mode> <type>;
<other ports>...
);
end component;

Component Instantiation:

<instance_name> : <component_name>
generic map (
my_generic => 2,
<other generics>...
)
port map (
<port_name> => <signal_name>,
<other ports>...
);

Thanks,
Marco

KJ

unread,
May 24, 2006, 9:13:48 AM5/24/06
to
2 will be used for the generic. The only time 1 will be used is when
you instantiate the component and DON'T supply a generic value....i.e.

Component Instantiation:


<instance_name> : <component_name>
generic map (

--**** my_generic => 2,

Marco

unread,
May 24, 2006, 9:25:23 AM5/24/06
to
Ok, I see, but in any case the assignment within the instantiation, if
present, should be the considered one?
Thanks, Marco

Ben Jones

unread,
May 24, 2006, 9:18:34 AM5/24/06
to

"Marco" <ma...@marylon.com> wrote in message
news:1148475493.0...@j73g2000cwa.googlegroups.com...

> Hi,
> there's something i don't understand about generics. Suppose I have to
> use a component within my top entity, so in the declarative part of my
> architecture I place the component declaration, while in the body of
> the architecture I insert its instantiation. Here's my doubt, if I
> assign a different value in these 2 places (say I write "my_generic :
> integer := 1" inside declaration, while "my_generic => 2" in the
> instantiation), which one will be the one considered by the
> application?

The value you specify in the declaration (my_generic : integer := 1) is the
default value.

The value you specify in the instantiation (generic map my_generic => 2) is
the actual value.

If no actual value is specified, the default value is used. If no actual
value is specified and no default value is specified either, then the
instantiation is an error.

Cheers,

-Ben-


Marco

unread,
May 24, 2006, 10:02:01 AM5/24/06
to
Ok, everything clear.
Thanks,
Marco

Ralf Hildebrandt

unread,
May 24, 2006, 10:44:10 AM5/24/06
to
Ben Jones wrote:


> If no actual value is specified, the default value is used. If no actual
> value is specified and no default value is specified either, then the
> instantiation is an error.


Let me add: This is a common a pitfall during synthesis. If you
synthesize the subcomponent, the default value will be used, if you
don't specify an actual value to the synthesis tool. If you forget it,
your synthesis tool uses the default value and your testbench a
different actual one.


Ralf

Marco

unread,
May 24, 2006, 11:16:44 AM5/24/06
to
Ralf,
do you mean that if I set a default value in the declaration part,
while I forget to specify a value in the instantiation, I'll synthesize
with the inserted default value and I'll have a testbeanch with another
one, different from the default one?
Thanks, Marco

Ralf Hildebrandt

unread,
May 24, 2006, 3:03:44 PM5/24/06
to
Marco wrote:

If you have a component as in your example

component <component_name>
generic (
my_generic : integer := 1;
<other generics>...
);
port (
<port_name> : <mode> <type>;
<other ports>...
);
end component;

and you synthesize this component alone without giving a different
actual value to the generic my_generic, the synthesis tool will
synthesize with the default value which is 1.
Now, if you simulate your netlist inside your design making an
instantiation as in your example

Component Instantiation:

<instance_name> : <component_name>
generic map (
my_generic => 2,
<other generics>...
)
port map (
<port_name> => <signal_name>,
<other ports>...
);

then this will lead to wrong behavior, because the instantiation assumes
my_generic to be 2, but the netlist was synthesized with my_generic=1.
The netlist is fixed.


This pitfall is not a special behavior, but simply something, that can
be easily forgotten.


Ralf

Andy

unread,
May 30, 2006, 5:03:06 PM5/30/06
to
Hmmm...

I think if the entity declaration has a default value, it may take
that, in the absense of either a default declaration on the component,
or an actual value in the generic map of the instance.

BTW, most tools (synpsys still has a few troubles with it) take entity
instantiations, obviating the need for component declarations,
configurations, default bindings, etc.

u1: entity entity_name(architecture_name)
generic_map(...

This has been a feature of vhdl since 1993!

Andy

0 new messages