• 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. [permutation] how can I make all Instance combinations?

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 143
  • Views 13538
  • 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

[permutation] how can I make all Instance combinations?

pacowon
pacowon over 12 years ago

Hi, I have a question with my skill language.

I wanna make permutation list with plural cell Instances.

For example , If I have a,b,c instances

 I wanna return list(a b c) list(a c b) list(b a c) list(b c a) list(c a b) list(c b a) => 3*2*1 lists!!

 I tried all day with

procedure(permutaion(()

prog(()

 Inst = list(a b c d)

foreach(***********)

)) but may be I'm not smart enogh to deal with this skill .....

 

somebody help  me out...

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 12 years ago

    Hopefully this code will help you:

    /* abPermutations.ils
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Mar 28, 2012 
    Modified   
    By         
    
    Generate permutations in lexical order
    
    Almost certainly there's a fancier way to do this...
    
    A few versions of doing this. One based on a perl algorithm (uses arrays), 
    and the second two are more LISPy ways of doing this
    Some of these functions require SKILL++ lexical scoping so please
    ensure file keeps the ".ils" suffix *************************************************** SCCS Info: @(#) abPermutations.ils 03/28/12.09:50:21 1.1 */
    (defun abPermutations (listOfObjects) (let (arrayOfObjects size indexArray) ;-------------------------------------------------------------------- ; Convert everything to arrays to allow faster manipulation ;-------------------------------------------------------------------- (setq arrayOfObjects (listToVector listOfObjects)) (setq size (sub1 (length arrayOfObjects))) (setq indexArray (makeVector (add1 size))) (for i 0 size (setarray indexArray i i)) ;-------------------------------------------------------------------- ; Local function to swap two array entries ;-------------------------------------------------------------------- (defun swap (a b) (let (tmp) (setq tmp (arrayref indexArray a)) (setarray indexArray a (arrayref indexArray b)) (setarray indexArray b tmp) ) ) ;-------------------------------------------------------------------- ; Local function that can be called recursively to generate permutations ;-------------------------------------------------------------------- (defun genPerm () (let ((k (sub1 size)) (j size) retVal) (setq retVal (foreach mapcar ind (vectorToList indexArray) (arrayref arrayOfObjects ind))) (while (and (geqp k 0) (greaterp (arrayref indexArray k) (arrayref indexArray (add1 k)))) (postdecrement k)) (if (minusp k) (list retVal) (progn (while (greaterp (arrayref indexArray k) (arrayref indexArray j)) (postdecrement j)) (swap j (postincrement k)) (setq j size) (while (greaterp j k) (swap (postdecrement j) (postincrement k)) ) (cons retVal (genPerm)) ) ) ) ) (genPerm) ) ) (defun abPerms (l) ;---------------------------------------------------------------------- ; Local function to remove only the first match in a list ; which means that it copes with repeated values in the list ;---------------------------------------------------------------------- (defun removeFirst (val l) (let (found) (setof elem l (cond (found t) ((equal val elem) (setq found t) nil) (t t) )))) (if (null l) '(nil) (mapcan (lambda (x) (mapcar (lambda (y) (cons x y)) (abPerms (removeFirst x l )))) l))) (defun abPermsUniqueList (l) (if (null l) '(nil) (mapcan (lambda (x) (mapcar (lambda (y) (cons x y)) (abPermsUniqueList (remove x l )))) l)))

     

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • pacowon
    pacowon over 12 years ago

    Wow!!! Thanks!!

     

    This is exactily what I wanted!!

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

    I just noticed that there's a typo in the comments of the file - it should really have a ".ils" suffix because some of the functions use SKILL++ lexical scoping - so my advice is that if you use this, please ensure that it has a .ils suffix.

    I'll edit the post with the code to make this clearer.

    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