• 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. Creating instances and naming them in a definite manner...

Stats

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

Creating instances and naming them in a definite manner using a loop

Sattiwk
Sattiwk over 4 years ago

Hi,

I am trying to create N instances and name them as xI1, xI2......,xIN using a loop and add them in a list. I have a written code that does the same for 4 instances as shown below (code snippet).

; Create library and cell for the scaled copy
dbCreateLib("__distCalcLib")
x1cp=dbCopyCellView(x1m "__distCalcLib" "__distCalcCell" "symbol")
dbSave(x1cp)
x1cpsch=dbOpenCellViewByType("__distCalcLib" "__distCalcCell" "schematic" "schematic" "w")
dbSave(x1cpsch)

; Have 4 instances(one for OP, three for scaled signals)
; add code-Currently, y spacing is hard coded-modify to determine size and spacing from the size
xI1=schCreateInst(x1cpsch x1m "I1" '(0 0) "R0")
dbCopyProp(x1 xI1)
xI2=schCreateInst(x1cpsch x1m "I2" '(0 5) "R0")
dbCopyProp(x1 xI2)
xI3=schCreateInst(x1cpsch x1m "I3" '(0 10) "R0")
dbCopyProp(x1 xI3)
xI4=schCreateInst(x1cpsch x1m "I4" '(0 15) "R0")
dbCopyProp(x1 xI4)

; One list for the operating point and three for scaled signals
opInstList = cons( xI4 nil )
sigInstList = list( xI1 xI2 xI3 )

-------------------------------------------------------------------------------------------

I tried to write a code to achieve my goal.This is my effort.

-------------------------------------------------------------------------------------------

; Have N instances

numCopies=4

counter=1
instanceIndex='()
opInstList='()
sigInstList='()
while(counter <= numCopies
ySpace=5*counter-5
instanceIndex =append(instanceIndex schCreateInst(x1cpsch x1m sprintf(nil, "xI%d" counter) '(0 ySpace) "R0"))
dbCopyProp(x1 instanceIndex[counter-1])
if(counter==numCopies then
opInstList =cons(nth(counter-1 instanceIndex) opInstList)
else
sigInstList =append(sigInstList nth(counter-1 instanceIndex))
)
counter=counter+1
)

---------------------------------------------------------------------------------------------------------------------------------------------------------------

I am not getting the desired output. The lists are empty and no instances are getting created.But the length of the lists are correct but the 'sigInstList' shows (nil,nil,nil) for N=4.

I am new to skill programming, so I couldn't figure out how to fix this and am seeking for help. Also, before creating the library, I want to add a code to check whether the library of same name exists or not and if it exists, it must be deleted.

I just want to automate the first code for N instances. Please help me out.

I am using cadence version IC6.1.7-64b.500.3.

  • Cancel
Parents
  • ebecheto
    ebecheto over 4 years ago

    Hi,

    You should learn how to use foreach(mapcar ...) functionality. See example :

    ; Create library and cell for the scaled copy
    dbCreateLib("__distCalcLib")
    x1cp=dbCopyCellView(x1m "__distCalcLib" "__distCalcCell" "symbol") dbSave(x1cp)
    cv=dbOpenCellViewByType("__distCalcLib" "__distCalcCell" "schematic" "schematic" "w") dbSave(cv)
    
    ; Have 4 instances(one for OP, three for scaled signals)
    
    ns=linRg(0 3 1);=> (0 1 2 3)
    xys  =foreach(mapcar n ns list(0 n*5));=> ((0 0) (0 5) (0 10) (0 15))
    insts=foreach(mapcar xy xys schCreateInst(cv x1m "I4" xy "R0"));=> (db:... db:... db:... db:...)
    returned=foreach(mapcar inst insts dbCopyProp(x1 inst))
    

    Considering the declaration of a list. When you manually declare a list, you can use quote.

    Myvar='(1 "a" 3) ;=> element in the list are not evaluated

    when you compute a list, you should use list(1 "a" 3)

    Hope it helps

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • mbracht
    mbracht over 4 years ago in reply to ebecheto

    good point!

    I think it'd be even more important to check the return value of schCreateInst() in the first place and indicate at least a warning in CIW or maybe even throw an exception. Just seeing a nil as an element in the list returned by (foreach mapcar...) makes it difficult to relate that to the instance that failed to be placed.

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
Reply
  • mbracht
    mbracht over 4 years ago in reply to ebecheto

    good point!

    I think it'd be even more important to check the return value of schCreateInst() in the first place and indicate at least a warning in CIW or maybe even throw an exception. Just seeing a nil as an element in the list returned by (foreach mapcar...) makes it difficult to relate that to the instance that failed to be placed.

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
Children
  • Sattiwk
    Sattiwk over 4 years ago in reply to mbracht

    Thank you mbracht and ebecheto BlushBlush

    • 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