I should create a structure (entity "A") composed of N components (entities "B"). Each component has several inputs and outputs and an internal signal ID (must be static), that identificates the component from 0 to N-1. Each component perform some operation based on ID. My problem is how to attribuite a static ID to each component at initialization time (during the port mapping). Obviously the components are "created" in for..generate loop, because N could be generic.
Declare a generic for your components, assign it the loop index of the generate, and, internally, assign the generic to the signal:
entity insider is
generic(id: natural);
port(
...
);
end entity insider;
architecture arc of insider is
signal s: natural;
begin
...
s <= id;
...
end architecture arc;
...
architecture arc of outsider is
...
begin
...
g: for i in 1 to 10 generate
i: entity work.insider
generic map(id => i)
port map(
...
);
end generate g;
...
end architecture arc;