• 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. Skill octagon on-grid

Stats

  • Locked Locked
  • Replies 5
  • Subscribers 143
  • Views 3463
  • 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

Skill octagon on-grid

ArbLouis
ArbLouis 10 months ago

Hi. I'm trying to draw an octagon on-grid using this code: 

for(i 0 7;
; Calculate coordinates for the octagonal ring (mid-width)

; Initialize point list
angle =-3*45/2+45+(i-1)*45
; Calculate x and y for each vertex
x = pog(stx + SRR_out_R * cos(angle * pi / 180)) ; 
y = pog(sty + SRR_out_R * sin(angle * pi / 180))

pointList = append(pointList list(x:y))


); end for

pog() is a custom function which sets points on-grid.

round(pt / grid_tech) * grid_tech

Unfortunately, the result I achieve is: 

As you can notice, the edges are not orthogonal and the angles are not perfectly at 45 degrees. Most probably, this is due to the fact that the pog rounds in different way the vertexes of the same edge. Do you have an easy workaround?

  • Cancel
  • Andrew Beckett
    Andrew Beckett 10 months ago

    I'm surprised you hit such a rounding error if your grid is not really fine (and given that the slope is pretty visible in your picture, it seems unlikely). What is pi set to? I wonder whether you have too limited precision on your value of pi (which could certainly cause this). I would suggest:

    defMathConstants('MYCONSTS)
    pi=MYCONSTS.PI

    which you'll see is at full precision:


    sstatus(fullPrecision t)
    pi

    outputs: 3.141592653589793

    Of course, you could always ensure as you walk around the points that your delta between successive points is always either dx==dy or dx==0 or dy==0 (even then though you need to ensure that the diagonals are the same length and the horizontals/verticals are the same length - so you could compute the deltas for a diagonal and the deltas for a horizontal/vertical, and then use those as you walk around the octagon.

    If you had access to Cadence PCell Designer, there's a built-in quarter octagon command which has all the work done to ensure that everything is on grid (and in fact it's a polygon, so the outer vertices are on grid).

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • ArbLouis
    ArbLouis 10 months ago in reply to Andrew Beckett

    Thanks for your answer. 

    Indeed, I've defined pi as you suggest and I get the value: 3.141592653589793

    my grid is: grid_tech=0.005

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett 10 months ago in reply to ArbLouis

    What value of SRR_out_R are you using that shows this problem?

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • ArbLouis
    ArbLouis 10 months ago in reply to Andrew Beckett

    SRR_out_R=12.1

    If I reduce the grid_tech, the error is reduced. 

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett 10 months ago in reply to ArbLouis

    OK, I tried it, and the issue is this line:

    angle =-3*45/2+45+(i-1)*45

    The trouble is that the 3*45/2 will end up being 67 rather than 67.5 - the operands of the division are integers, so it does an integer division. If you change it to:

    angle =-3*45/2.0+45+(i-1)*45

    then that forces the division to do a floating point division as one of the operands is a float, and so that will give -67.5 degrees as the first part of the expression.

    What's happening is that your octagon is very slightly rotated...

    Andrew

    • Cancel
    • Vote Up +1 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