0
\$\begingroup\$

I have this code that attaches a label to components instantiated inside a for...generate statement. So far everything works fine:

outer: for index in 17 downto 0 generate
attribute RLOC of EX_do1: label is "X0Y" & integer'image(index / 4);
begin
  EX_do1: FDC port map( ... );
end generate;

However, I want the attribute only on instances 0..15. So I tried this:

outer: for index in 17 downto 0 generate
begin

  inner: if index < 16 generate
    attribute RLOC of EX_do1: label is "X0Y" & integer'image(index / 4);
  begin end generate;

  EX_do1: FDC port map( ... );
end generate;

Now I'm getting the error message <EX_do1> is not declared. I tried moving inner before the begin of the outer statement, but same result. How can I refer to the flipflop?

I assume it would be possible by pulling the component initialization into the if-block and repeating it again in an if-not-block, but I am trying to avoid redundant code.

\$\endgroup\$

bumped to the homepage by Community yesterday

This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

  • \$\begingroup\$ I think it would be clearer if you just had two generate loops, one for 17..16, and one for 15..0. \$\endgroup\$ – Dave Tweed Feb 6 at 14:52
  • \$\begingroup\$ Dave: that is my work-around for the moment. But it requires me to repeat everything that is declared in the outer block twice. This bloats the code and makes it hard to maintain. \$\endgroup\$ – travelboy Feb 6 at 15:06
  • 1
    \$\begingroup\$ Yeah, VHDL is like that. I sometimes write scripts to generate my code for me. The m4 macro preprocessor can help quite a bit, too. I'm not a VHDL expert by any means -- there may be a way to do what you want within the language. \$\endgroup\$ – Dave Tweed Feb 6 at 15:35
0
\$\begingroup\$

I found an old comp.lang.vhdl post that led me to the FAQ.

Section 4.2.3 seems to suggest that you can use one or more additional for loops to assign your attributes, by referring to the instances of your FDCs using the syntax outer(index).EX_do1.

I'm not set up to verify this myself — let me know whether or not it's helpful.

\$\endgroup\$
  • \$\begingroup\$ This does not work :-( although it would make a lot of sense if it did. Illegal name in specification. I think the FAQ article refers to configuring components but the same syntax cannot be used for attaching attributes. \$\endgroup\$ – travelboy Feb 6 at 19:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.