• 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. Pin width change

Stats

  • Locked Locked
  • Replies 9
  • Subscribers 143
  • Views 15370
  • 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

Pin width change

Gurup
Gurup over 6 years ago

Hi, 

 I am writing a code to change the pin width cyclically, and be lwo is my code

sel_pin=css()

if(sel_pin ~>objType == "rect" && sel_pin~>children != nil then

p_width=caadr(sel_path~>bBox)-caar(sel_path~>bBox)

cond(
(p_width<0.2   p_width=0.5)
(p_width<=0.2 && p_width<0.6 p_width=0.6)
(p_width>=0.6 && p_width<1 p_width=1)
(p_width>=1 && p_width<2 p_width=2)
(p_width>=2 p_width=.2)
);end cond

pin_width=p_width
crd1=car(sel_pin~>bBox)
crd2=list(car(crd1)+pin_width cadr(crd1)+pin_width)
sel_pin~>bBox=list(crd1 crd2)
sel_pin~>children~>xy=list(car(crd1)+(pin_width/2.0) cadr(crd1)+(pin_width/2.0))
sel_pin~>children~>height=(pin_width/2)

);end if

When I exucte the code for pin width 0.2, then the Cond statement not changing the p_width to 0.6.

Its taking p_width<0.2 is true when pin width is 0.2.

Please correct me if any thing is wrong

  • Cancel
  • mbracht
    mbracht over 6 years ago

    HI Gurup,

    That sound's like one of these infamous rounding issues to me, try

    (printf "%2.20f" p_width)

    ...and you will most likely find that p_with is just close to but not exactly 0.2.

    There is a solution for this problem:

    https://support.cadence.com/apex/ArticleAttachmentPortal?id=a1Od0000000naf2EAA&pageName=ArticleContent

    Max

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Gurup
    Gurup over 6 years ago

    And in  different coordinate the p_width is changing .. and in some coordinate its struck one value

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 6 years ago in reply to Gurup

    One way to deal with these floating point rounding errors (which have been covered many times in these forums and elsewhere for numerous programming languages - this is not an issue unique to SKILL) is to introduce an error term (epsilon) in the comparisons. In this case I set it to a small number (e.g. one tenth of your probably database unit - often people have a DBU of 1nm, so I set it to 0.1nm). Then make the comparison including this term:

    epsilon=1e-4 ; assuming you have a DBUperUU of 0.001 this would be a tenth of the resolution (could be tighter still)
    cond(
      (p_width<0.2-epsilon p_width=0.5)
      (p_width>=0.2-epsilon && p_width<0.6-epsilon p_width=0.6)
      (p_width>=0.6-epsilon && p_width<1-epsilon p_width=1)
      (p_width>=1-epsilon && p_width<2-epsilon p_width=2)
      (p_width>=2-epsilon p_width=.2)
    );end cond

    By the way, your second branch in the cond statement had (I believe) the comparison the wrong way around (it had <= rather than >=)

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Gurup
    Gurup over 6 years ago in reply to Andrew Beckett

    Thank you very much mbracht and Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Gurup
    Gurup over 6 years ago in reply to Andrew Beckett

    Same scripts works for path/pathSeg width , but only for Pin its giving error even for floatnum path width

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 6 years ago in reply to Gurup
    Gurup said:
    Same scripts works for path/pathSeg width , but only for Pin its giving error even for floatnum path width

    There's probably a difference in the floating point calculation in the two cases. One you're doing a difference of the bounding box, and in the other case you're directly reading the width from the database. The subtraction is likely to lead to a floating point rounding error, whereas the direct database access isn't. So this is not unexpected.

    As I've said here (and in many, many other places), this is something that would happen in most programming languages and is well covered across the internet. Coding it similar to the way that I proposed will defend against such rounding errors.

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Gurup
    Gurup over 6 years ago in reply to Andrew Beckett

    I searched for  same problem, but don't know what search exactly :)    Ok Thanks For the info  Andrew. 

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • RK56
    RK56 over 6 years ago in reply to Andrew Beckett

    Andrew,

    How about creating some sticky post on such topics? This can ensure more hit ratio of catching people's eye and such questions can be avoided.

    -Ramakrishnan

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 6 years ago in reply to RK56

    Hi Ramakrishnan,

    Two issues:

    1. Nobody reads the forum guidelines which are a sticky post at the top of each forum (OK, I'm sure it's not "nobody", but given the number of times posts are made in violation of the guidelines, I suspect very few read them)
    2. This specific issue is quite hard to cover in a way that you'd actually think of it when you hit an issue. There are an enormous range of symptoms and situations where it occurs, and the summary would tend to be "never do an equality check on floating point numbers" which is describing the answer, not the problem - so you wouldn't necessary spot that this is relevant.
    3. There are lots of common topics that come up - this is just one of them. Cherry picking those is quite hard
    4. I can't count to two.

    In general the search ought to find lots of cases, but that tends on only be where you've got a situation with similar symptoms.

    On the support site, we have some FAQs to try to address such common topics, but I normally find it's the search that finds things, not looking at the FAQs.

    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