• 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 SKILL
  3. Force increment step in parameter

Stats

  • Locked Locked
  • Replies 6
  • Subscribers 143
  • Views 15401
  • 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

Force increment step in parameter

Dimitris Kar
Dimitris Kar over 11 years ago

Hi,

 

I am trying to force the minimum increment in parameters that user defines.

 I managed to implement the min max to force the limits of my parameter (i.e. if 3<=x<=10, I write x=max(x 3)   x=min(x 10))

 I can not find the correct expresion on setting the acceptable step i.e. if the grid is 0.1, then values of x.xxx are not accepted.

 

An suggestions will be warmly welcomed!

 

Many thanks!

 

BR,

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 11 years ago

    What kind of parameter are you talking about? It's very unclear as to what tool, what application, what anything you are referring to.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Dimitris Kar
    Dimitris Kar over 11 years ago

    Hi Andrew, 

     

    Say I am giving a parameter via the following code ( shown partialy for reasons of space): 

    ;o------------------------------------------------o;

    cdfCreateParam( cdfId
          ?name     "x"
          ?prompt   "Length"
          ?defValue  3.0
          ?type     "float"
          ?display  "t"
        )

     ;o------------------------------------------------o;

     

    now, in my pCell definition, I have put the upper and lower limit of x

     

    but, what I am missing, is how I can force the limits to be displayed in the parameters form of the pcell when the user exceeds them and how I will also force the grid increment to the input value and its display in the field. 

     

    Now, after a bit of searching I came up with two lines of code for the OnGrid routine: 

    r= 10**-log10(grid)

    round((x*r))/float(r)

     

    which makes my question easier: How to I display the   OnGrid WithinLimits value if the user is violating these rules?

     

    In example: 

     

    say 3<=x<=10

    and grid=0.05

     

    then the user inputs 

     

    Length     4.032

     

    I want to show immediately the value

     Length   4.05

     

    in another case, if user inputs 

     

    Length 2.33

     then field becomes 

    Length 3

     

    Do you have any suggestions? I understand this should be quite triavial but, unfortunatelly can not find the correct approach...

     

    Many thanks! 

     

    D.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 11 years ago

     OK, now you explained that you're talking about a CDF parameter and gave an example, your question is clear.

     Create a function such as this:

     procedure(CCFonGrid(param lower upper grid)
      let((value)
        value=get(cdfgData param)->value
        value=min(max(value lower) upper)
        get(cdfgData param)->value=round((value/float(grid)))*grid
      )
    )

    And then in your cdfCreateParam call, pass:

      ?callback "CCFonGrid('x 3 10 0.05)"

    Note that in the code you showed, r= 10**-log10(grid) is a complicated way of saying r=1/grid. If you rearrange the expression a little, there's no need to find the reciprocal anyway.

    I've written the above callback code to use get() and to pass the parameter name in, because that way you can use it for multiple CDF parameters with different lower and upper limits and different grids.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Dimitris Kar
    Dimitris Kar over 11 years ago

    Hi Andrew! 

     

    Great help, much appreciated! And a very good example for a ...beginner!

     

    Many thanks!

     

    BR,

     

    D.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Dimitris Kar
    Dimitris Kar over 11 years ago

     Hi !

     

    I have a new question, regarding the use of the parametrized value in the above code. 

     

    Say I need to "call" another input parameter, i.e. param2

    I will modify the procedure as follows: 

    ;o------------------------------------------------------------------------------------------o; 

    procedure(SR(param1 param2 upper grid)
      let((value dep dep1 libID cellID)
        libID="My_lib"
        cellID="My_PCELL"
        value=get(cdfgData param1)->value
      

        dep = car(setof(p cdfGetBaseCellCDF(ddGetObj(libID cellID))->parameters p->name==symbolToString(param2)))->value

       get(cdfgData param1)->value=round((value/float(grid)))*grid

    ;o------------------------------------------------------------------------------------------o;

     

     

    Although "primitive", the dep is getting my desired parameter. 

     

    My problem is the following: 

     

    I need a conditional statement, that will depend the lower/upper limit of param1 from the param2 input. 

    I tried  to use a

                value=      case( dep 

                                              (min(max(dep lower) x.xxx) value1)

                                              (min(max(dep yy.yyy) zz.zzz) value2))

     

    When trying to implement it, I get no results...

     

    Any syggestion how to implement it? 

     

    Thanks! 

     

    D.

     

     

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 11 years ago

    I'm guessing that the libId and cellId are for a different cell, which is why you're doing it this way rather than using get(cdfgData param2)? 

    I did realise that actually it's bad practice for me to have suggested using get() for this. The right way is cdfFindParamByName(cdfgData get_string(param1))->value . A bit longer, but this will still work if your CDF parameter name happens to be one of a number of "reserved" slots on the CDF object (e.g. a parameter called "id", amongst others).

    Similarly, your dep variable could be found:

    dep=cdfFindParamByName(cdfGetBaseCellCDF(ddGetObj(libID cellID)) get_string(param2))->value

    rather than looping over all of them yourself.

    Now onto the case(). Two problems - one is that the target values in a case statement have to be literal values, not expressions. In other words, it will not evaluate the target values and so it will in fact be trying to check if the value is either the symbol min, or the list (max dep lower). Which it won't be, which is why it doesn't work. 

    Instead, you could use cond:

    value=cond(
      (dep==min(max(dep lower)) ... value1)
      (dep==min(max(dep yy.yyy)) ... value2)
      (...)
    )

    cond is like a nested if-then-elseif-elseif-else type structure.

    Note however that you should be rather cautious about using == type checks on floating point numbers if there is any chance that the floating point number might suffer from rounding errors. There are a number of solutions and posts on this before, but floating point numbers in SKILL (and C, and Java, and Python and Perl and Tcl for that matter) are represented with IEEE floating point representation, which can suffer from rounding errors even with a 52 bit mantissa (in the same way that 1/3 can't be represented exactly in decimal, 1/10 can't be represented exactly in binary). So it's generally dangerous to do equality checks on floating point numbers - instead one usually does things like abs(value1-value2)<smallNumber to check if value1 and value2 are effectively equal.

    So your condition may want to change a bit.

    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