• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC Design
  3. Use of array inside a loop in SPECTRE

Stats

  • Locked Locked
  • Replies 1
  • Subscribers 125
  • Views 13767
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Use of array inside a loop in SPECTRE

wang159
wang159 over 10 years ago

If I declare an array in SPECTRE, for example:

>> electrical [1:10] var;

and I use it inside a loop:

>> for (index = 1; index <=total; index=index+1) begin

>>     if (index > 1) begin

>>         I(var[index],var[index-1]) <+V(branch)*R;

>>     end

>>     else ........ (omitted)

>> end

This gives me an error indicating the index of var is out of range. I suspect the origin of this error is SPECTRE checks the validity of index by substituting it with initial and final index values of the for loop. The "var[index-1]" thus becomes "var[0]" when index=1. However, this will never happen, since it is within a if statement. 

I am wondering what is the best solution to resolve this issue. Is there a way that SPECTRE can ignore checking the index range to bypass this error?

Thanks for the help!

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 10 years ago

    Your example wasn't complete - I assume index is a genvar. Anyway, assuming that it was, then with genvar the loop is effectively unwrapped so that it generates contribution statements per index of the for loop - and this is done at compile time rather than run time (in essence). So that means that it will still generate a statement (albeit within the if) with an invalid array bound in the contribution statement. The solution is to write it differently:

        for (index=2; index<=10; index=index+1) begin
            I(var[index],var[index-1])<+V(sig)*R;
        end
        // put else part here

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information