• 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. how to write a SKILL code for PCELL powergrid

Stats

  • Locked Locked
  • Replies 14
  • Subscribers 142
  • Views 20414
  • 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

how to write a SKILL code for PCELL powergrid

techrddyz
techrddyz over 8 years ago

Hi all,

I am new to SKILL coding. I am trying to create a power grid PCELL using SKILL. The user can switch on and off layers/vias depending on needs. I found some SKILL code online and modified to meet my need. Now, i can create metals (ex. M3) but I dont know how i can turn it on and off when the user checks on/off the checkbox on the 'Edit Instance Properties' window. please see my code below. 

procedure(powerGridPcell(cv "dnn")
let( (rectRodObj)

Nx=7
temp = 1
for(i 0 Nx
temp = 0.63 * i
rectRodObj = rodCreateRect(
?cvId cv
?layer list("M3" "drawing")
?bBox list(0:temp+0.125 5.04:temp+0.505)
)
);End for i

); let
); procedure


;; Create the PCell, the "drawing routine" is encapsulated in the
;; powerGridPcell function which does all the work

pcDefinePCell(
list(ddGetObj("test_rudy") "power_grid_pcell" "layout")
(
)
let( ((cv pcCellView))
powerGridPcell(cv)
); let
)

;; Create the CDF for the 'l' and 'w' parameters
let( (cellId cdfId)
when(cellId = ddGetObj("test_rudy" "power_grid_pcell")
;; if the cell CDF already exists, delete it
when( cdfId = cdfGetBaseCellCDF(cellId)
cdfDeleteCDF(cdfId)
)
;; create the base cell CDF
cdfId = cdfCreateBaseCellCDF(cellId)
;; create the parameters
cdfCreateParam( cdfId
?name "visibilityM3"
?prompt "M3"
?defValue "true"
?type "boolean"
?display "t"
)

cdfSaveCDF(cdfId)
); when
); let

Thanks

  • Cancel
  • skillUser
    skillUser over 8 years ago

    Hi Rudy,

    You need to create a PCell parameter to match the CDF parameter that you created, so call it visibilityM3, and you need to also pass this as an argument to the drawing function.  You can actually start with the drawing function and test that outside of the PCell structure for development and testing purposes, and then later update the PCell to match. But for what you've shown above, the bits you need might look like this:

    
    pcDefinePCell(
    list(ddGetObj("test_rudy") "power_grid_pcell" "layout")
      (
        (visbilityM3 "TRUE")
      )
      let( ((cv pcCellView))
        powerGridPcell(cv visibilityM3)
      ); let
    )
    
    procedure(powerGridPcell(cv m3vis "dt") ;; the template says that the first arg is a db object, second is text string
    let( (rectRodObj Nx temp) ;; added Nx and temp to locally defined variables, don't need to declare i
    
      Nx=7
      temp = 1
      for(i 0 Nx
        when(m3vis=="TRUE"  ;; test the value of the m3vis argument
          temp = 0.63 * i
          rectRodObj = rodCreateRect(
            ?cvId cv
            ?layer list("M3" "drawing")
            ?bBox list(0:temp+0.125 5.04:temp+0.505)
          )
        ); when
      );End for i
    
    ); let
    ); procedure
    
    

    As an aside, I'd probably use a different term than 'visibility' since that has a different connotation for layout, here you are choosing whether to CREATE the M3 shapes or not, not whether they are visible. I have not tried or tested the above code!

    Hopefully this helps you.

    Best regards,

    Lawrence.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • techrddyz
    techrddyz over 8 years ago

    Hi Lawrence,

    Thank you so much. i believe i am one step closer to the solution. I added the above code to my code and it compiles successfully. however, when i unchecked the M3 box, and click OK/Apply. i get the following warning.

    *WARNING* (DB-270000): dbReplaceInstParamList: Datatype for input parameter 'visibilityM3' does not match the definition

    and then cadence automatically put the check mark on the M3 box again.

    I tried putting boolean in  

    list(ddGetObj("test_rudy") "power_grid_pcell" "layout")

    ( (visbilityM3 boolean "TRUE")

    ) 

    or changed TRUE to true but all dont seem to solve the problem. 

    Do you have any idea on this ?? thanks alot

    Rudy

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • skillUser
    skillUser over 8 years ago
    Hi Rudy,

    I've not played with boolean CDF parameters for a while but the important thing is how the value is stored/communicated to the PCell - I assumed it will be a string but it could be a true boolean (i.e. t/nil for the value) when it gets to the PCell formal parameter. One thing you can do is to select an instance and then take a look at the value for both cases (on/off) using car(geGetSelectedSet())~>visibilityM3 look at not just the value but the TYPE also (e.g. "TRUE" vs t). I haven't got time to look into it further but hopefully the above helps.

    Best regards,
    Lawrence.
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • techrddyz
    techrddyz over 8 years ago

    Thanks alot for your suggestion. it works now. true boolean gets pass into the function. I can now turn on/off metal layers created using rectRodObj.

    however, when i do the same for VIA using dbCreateViaShapeArray, i cannot turn off the VIAs by unchecking the box in Edit Instance Properties window. Below is my code. Do you know if there is anything wrong here?

    Thanks

    ;create vias
    procedure(powerGridPcell_via(cv)
       for(i 0 7 ;row
          for(j 0 7 ;col
    if(mod(j 2) == 0 && mod(i 2) == 0 then
    tempx1 = 1.12 * (j/2) + 0.195
    tempy1 = 1.12 * (i/2) + 0.195
    dbCreateViaShapeArray(cv "V2" nil tempx1 tempy1 0.16 0.16 0.08 0.08 3 3)
    else
    tempx1 = 1.12 * (j/2) + 0.825
    tempy1 = 1.12 * (i/2) + 0.825
    dbCreateViaShapeArray(cv "V2" nil tempx1 tempy1 0.16 0.16 0.08 0.08 3 3)
    );if
          );for
       );for
    )
    pcDefinePCell(
      list(ddGetObj("test_rudy") "power_grid_pcell" "layout")
      (
    ...
    (V3 t)
    ...
      )
      let( ((cv pcCellView))
    ...
    powerGridPcell_via(cv) ;V3
    ...
      ); let
    )
    ;; Create the CDF 
    let( (cellId cdfId)
      when(cellId = ddGetObj("test_rudy" "power_grid_pcell")
        ;; if the cell CDF already exists, delete it
        when( cdfId = cdfGetBaseCellCDF(cellId)
          cdfDeleteCDF(cdfId)
        )
        ;; create the base cell CDF
        cdfId = cdfCreateBaseCellCDF(cellId)
        ;; create the parameters
        cdfCreateParam( cdfId
          ?name    "V3"
          ?prompt  "V3"
          ?defValue    "true"
          ?type    "boolean"
          ?display    "t"
        )
        cdfSaveCDF(cdfId)
      ); when
    ); let
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 8 years ago

    Rudy,

    You didn't show any of the code that actually does the conditional part (as far as I can see), so I'm not sure how anyone can help you. It can't be anything to do with the fact that you're calling dbCreateViaShapeArray, it must be to do with the logic that you have around the code which calls this function.

    Kind Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • skillUser
    skillUser over 8 years ago
    Hi Rudy,

    Andrew is right, assuming that "V3" is your boolean, that is not being passed into the powerGridPcell_via function - you will need to add an argument for this and then use it inside that function: when(V3 dbCreateViaShapeArray(cv "V2" nil tempx1 tempy1 0.16 0.16 0.08 0.08 3 3) ) - for example, which only calls the dbCreateViaShapeArray function if the V3 argument is non-nil (again, you will need to check how the boolean is passed into the function, to make sure that it is t/nil, for example, to work with the statement as shown). Remember that you can call your powerGridPcell_via() function directly with a layout cellview open for testing and development purposes, for example: powerGridPcell_via(dbGetEditCellView() t) ;; assuming passing 't' for the create-via argument [to be added to the function]

    Best regards,

    Lawrence.
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • techrddyz
    techrddyz over 8 years ago

    Hi Andrew,

    please find below my code. Based on what SkillUser said above, to turn on/off layers i just need to create  PCell parameters that match cdf parameters. i guess thats what you mean by 'the code that does the conditional part'. I can turn on/off metal layers  but cannot turn on/off vias. You can copy the code below and run it. Thanks alot for you help.

    ;; Create the PCell, the "drawing routine" is encapsulated in the
    ;; powerGridPcell function which does all the work
    pg_layer_list = list(
    list("M1")
    list("M2" "V1")
    )
    coordIndex = 1
    ;;create metal layers
    procedure(powerGridPcell_metal(cv drawMetal rowCol metalLayer)
      let( (rectRodObj)
          for(i 0 rowCol
    when(drawMetal == t
     case(metalLayer
        ("M1"
        coordIndex = 0.63 * i
        rectRodObj = rodCreateRect(
    ?cvId    cv
    ?layer   list(metalLayer "drawing")
    ?bBox    list(0:coordIndex+0.125 5.04:coordIndex+0.505)
        )
        )
    ("M2"
        coordIndex = 0.63 * i
        rectRodObj = rodCreateRect(
    ?cvId    cv
    ?layer   list(metalLayer "drawing")
    ?bBox    list(coordIndex+0.125:0 coordIndex+0.505:5.04)
        )
        )
      );case
    ); when
          );End for i
      ); let
    ); procedure
    ;create vias
    procedure(powerGridPcell_via(cv v_layer row col v_xStart1 v_yStart1 v_xStart2 v_yStart2 v_xPitch v_yPitch v_w v_l v_row v_col rowPitch colPitch)
       for(i 0 row ;row
          for(j 0 col ;col
    if(mod(j 2) == 0 && mod(i 2) == 0 then
    tempx1 = colPitch * (j/2) + v_xStart1
    tempy1 = rowPitch * (i/2) + v_yStart1
    dbCreateViaShapeArray(cv v_layer nil tempx1 tempy1 v_xPitch v_yPitch v_w v_l v_row v_col)
    else
    tempx1 = colPitch * (j/2) + v_xStart2
    tempy1 = rowPitch * (i/2) + v_yStart2
    dbCreateViaShapeArray(cv v_layer nil tempx1 tempy1 v_xPitch v_yPitch v_w v_l v_row v_col)
    );if
          );for
       );for
    )
    pcDefinePCell(
      list(ddGetObj("test_rudy") "power_grid_pcell_test" "layout")
      (
    (M1 t)
    (V1 t)
    (M2 t)
      )
      let( ((cv pcCellView))  
    powerGridPcell_metal(cv M1 7 nth(0 nth(0 pg_layer_list)))
    powerGridPcell_metal(cv M2 7 nth(0 nth(1 pg_layer_list)))
    powerGridPcell_via(cv nth(1 nth(1 pg_layer_list)) 7 7 0.195 0.195 0.825 0.825 0.16 0.16 0.08 0.08 2 2 1.26 1.26)       ;V1
      ); let
    )
    ;; Create the CDF 
    let( (cellId cdfId)
      when(cellId = ddGetObj("test_rudy" "power_grid_pcell_test")
        ;; if the cell CDF already exists, delete it
        when( cdfId = cdfGetBaseCellCDF(cellId)
          cdfDeleteCDF(cdfId)
        )
        ;; create the base cell CDF
        cdfId = cdfCreateBaseCellCDF(cellId)
        ;; create the parameters
        cdfCreateParam( cdfId
          ?name    "M1"
          ?prompt  "M1"
          ?defValue    "true"
          ?type    "boolean"
          ?display    "t"
        )
        cdfCreateParam( cdfId
          ?name    "V1"
          ?prompt  "V1"
          ?defValue    "true"
          ?type    "boolean"
          ?display    "t"
        )
        cdfCreateParam( cdfId
          ?name    "M2"
          ?prompt  "M2"
          ?defValue    "true"
          ?type    "boolean"
          ?display    "t"
        )
        
        cdfSaveCDF(cdfId)
      ); when
    ); let
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • skillUser
    skillUser over 8 years ago

    Hi Rudy,

    You could add a 'when' conditional around your via function where you are calling it from your pcDefinePCell statement, so altering your code it might look like this:

    ...
    powerGridPcell_metal(cv M2 7 nth(0 nth(1 pg_layer_list)))
    when(V1
      powerGridPcell_via(cv nth(1 nth(1 pg_layer_list)) 7 7 0.195 0.195 0.825 0.825 0.16 0.16 0.08 0.08 2 2 1.26 1.26)       ;V1
    ); when
    ); let...

    Hopefully this will help you.

    Best regards,

    Lawrence.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • techrddyz
    techrddyz over 8 years ago
    Hi Lawrence,

    Thanks for you reply. However, adding the when condition doesnt help. I still cannot turn on/off the Vias. any other thoughts??

    Thanks
    Rudy
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • skillUser
    skillUser over 8 years ago
    Hi Rudy,

    You will have to post your code in order for anyone to be able to help debug it. Stating things like "doesn't help" or "doesn't work" provides little or no information that would aid debugging.

    Regards,
    Lawrence.
    • 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