• 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. Using functions in Assembler global variables

Stats

  • Locked Locked
  • Replies 5
  • Subscribers 125
  • Views 11126
  • 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

Using functions in Assembler global variables

Brad RFeng
Brad RFeng over 3 years ago

Hi

I need to sweep the impedance of an analogLib port component including both resistance and the reactance parameters. To do this a little complex math is required to calculate R and X including functions real(),imag() and complex().
When i attempt to use complex() in a global variable assignment I get a sim err and the spectre.out shows "Cannot run the simulation because the expression of the parameter `j': Function `complex' is not defined. Update the netlist to define the function."

The expressions i'm using to calculate R and X work fine if I type them into the CIW. Is there a way to make complex() work in a global variable assignment?


It sure would be convenient to handle this with the Assembler global variables block on the gui but I'm starting to suspect I'll need to define my functions in an included .scs file. 

Using IC6.1.8-64b.500.23

Regards,
Brad

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 3 years ago

    Hi Brad,

    First of all, this only stands any chance of working if the expressions are valid SKILL expressions and can be computed before simulation starts. It sounds as if ADE has sent the expressions to spectre, but that's going to fail because spectre does not have a function complex in its expression language.

    Normally ADE will do some checks on expressions in the global variables to see whether it thinks they can be handled by spectre, and if so passes them to the simulator. Otherwise it tries to evaluate them in SKILL, and then sends the results to the netlist. If the SKILL evaluation fails for some reason, then it still passes the expression to the netlist on the off chance that spectre will be able to handle it anyway.

    Can you please share the details of your expressions so that I can check? I may be able to figure out what's wrong and give you a workaround.

    Regards,

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Brad RFeng
    Brad RFeng over 3 years ago in reply to Andrew Beckett

    Hi Andrew,

    I misspoke when I said I was using function complex(). Actually I'm creating a complex variable by using sqrt(-1) in an expression and this works fine in the CIW. The error returned in the spectre.out file includes the phase "Function 'complex' is not defined.." and that lead to my not so clear description (it was late in the evening).

    I'm attaching the expressions now.

    Regards,

    Brad

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 3 years ago in reply to Brad RFeng

    Brad,

    This is a tricky one. What's happening is that there is an issue where sqrt() was not recognised as a spectre function, and so was being calculated in SKILL always. Usually you want as many functions that could be evaluated in spectre to be passed to the netlist, as that then allows sweeps within the simulator and dependencies to be tracked there. We've just fixed the issue with sqrt not being passed to the simulator - this will be fixed in IC6.1.8 ISR26 (out in July if my memory is correct).

    However, that's not going to help you. Spectre can't handle complex arithmetic, so in fact you really don't want the expressions to be passed to spectre. Unfortunately most of the expressions here appears to ADE to be the kind of things that spectre would be able to handle, and it doesn't know that the result of the calculation for j would prevent that. You're getting the complex(0, -1) in the netlist because ADE evaluated the sqrt(-1) but it is going to fail because nothing knows how to deal with complex(0, -1). Even if ADE passed it through, it would ultimately fail with something like:

      FATAL (SFE-1996): "testsqrt.scs" 3: Cannot run the simulation because the
    expression of the parameter `i': Attempt to take the square root of a
    negative number (-1).
    , correct the expression and rerun the simulation.
     

    The way to workaround this is to create some functions and load from your .cdsinit:

    defMathConstants('CCFmath)
    procedure(CCFcalcG(Gabs Gang)
      let(((j sqrt(-1)))
        Gabs*exp(j*Gang*CCFmath.PI/180)
      )
    )
    
    procedure(CCFcalcZ(Gabs Gang)
      let((G)
        G=CCFcalcG(Gabs Gang)
        (1+G)/(1-G)
      )
    )

    Leave the definitions of Ro, Xo, Gang, RLoss_dB, Gabs as you have them, and remove the j and G expressions. Then make:

    Z=CCFcalcZ(Gabs Gang)

    You'll still see the Z appearing in the netlist as complex(NNN, MMM) but that is OK - because nothing references it in the netlist.

    Yes, it's a bit of a hack - but at the moment there's no clear way to force an expression to definitely be handled in ADE or in Spectre.

    Regards,

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Brad RFeng
    Brad RFeng over 3 years ago in reply to Andrew Beckett

    Andrew,

    Thanks for the quick response and helpful work around.

    A few related questions -

    Can I preload an .il for a given assembler session without manually using load("my.il") in CIW or including in my .cdsinit? Just wondering what my options are.

    I'm not familiar with CCFmath I assume it is an .il file? Where can I find the file and can I inspect the contents?

    Is there a def file that includes matrix math expressions?
    I'm somewhat new to SKILL but I'm already thinking about the possibility of overloaded operators to handle matrix math.

    "it's a bit of a hack" [Andrew]

    I don't mind working with custom functions in fact I like the possibilities that approach opens up. On the other hand it sure seems
    the Cadence development guys really don't have RF designers in mind otherwise this basic RF 101 task that I attempted would have been easily handled in GUI from day 1.

    Regards,

    Brad

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 3 years ago in reply to Brad RFeng

    CCFmath isn't anything special - it's just a name. If you do:

    defMathConstants('someName) 

    then you can do:

    someName.PI ; returns pi
    someName.? ; shows available names
    someName.TWO_OVER_PI

    All that was for was to provide a convenient SKILL way of getting an accurate pi constant without needing to type 3.14159265358979323.

    There's no standard way of loading a per-Assembler piece of SKILL code prior to netlisting. I can think of a way of possibly implementing this (so you could add the code into the documents folder of the maestro view and have it auto-loaded) but I've not written such a customisation.

    So for now, the best thing is to load this code from your .cdsinit. Loading it in the CIW may not be sufficient if running multiple simulations as netlisting will be done in a background process and won't see what you've loaded in the CIW.

    I'm not sure you can draw the conclusion that we don't have RF designers in mind from this. Yes, it's something that frequency-domain RF designers may want to do, but there are a lot of challenges that are caused by allowing arbitrary ideal frequency domain expressions/modelling by virtue of the fact that such frequency domain descriptions do not reliably translate into something causal and stable in the time domain. OK if you were only doing linear simulation in the frequency domain, but even with harmonic balance you need to ensure that any transient assist can handle the frequency domain part (so a complex port impedance is only supported in frequency domain analyses, for example). We have to handle the whole range of design types and not just RF, but there are continual efforts to improve the experience for RF designers within the Virtuoso platform.

    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