• 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. Acess array elements using plist

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 143
  • Views 15400
  • 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

Acess array elements using plist

frasheed
frasheed over 11 years ago

 Hello,

 

I am wrting a SKILL code in which I am stuck at a point here I want to access the array element defined through plist:

EXAMPLE:

 setplist( 'B1 '( p 200 y list(1 2 3 4 5 6 ) )

IN = B1

; I want to access the value of y[0], I nam trying this

IN->y[0]

; but It's giving me error  *Error* arrayref: can't handle y[0]

 

Can anyone plese tell me where I am going wrong ?

 

  • Cancel
Parents
  • Andrew Beckett
    Andrew Beckett over 11 years ago

    The main problemis that lists are not arrays. They are linked-lists which are separate data types to arrays, and are sequential in nature. Generally speaking if you think of lists as arrays, you will make the mistake of assuming that they are random-access, when they are sequential, and write code that is inefficient. 

    Secondly, there are a number of mistakes in your example, so it can't work as is. The second single quote in the setplist will cause the list() not to be evaluated. So it should be:

    setplist('B1 list('p 200 'y list(1 2 3 4 5 6)))
    IN='B1

    Or:

    setplist('B1 `(p 200 y ,list(1 2 3 4 5 6)))  ; note the backquote and also comma before the bits you want to evaluate
    IN='B1

    Then you could use:

    nth(0 IN->y)

    Or, if you really want an array:

    setplist('B1 `(p 200 y ,listToVector(list(1 2 3 4 5 6))))
    IN='B1
    IN->y[0]

    I'm wondering if you really want to use a plist on a symbol either. Maybe some other data structure would be more appropriate - but depends on your application?

    For example - you could do:

    defstruct(MyStruct p y)
    IN=make_MyStruct(?p 200 ?y listToVector(list(1 2 3 4 5 6)))
    OUT=make_MyStruct(?p 100 ?y listToVector(list(7 8 9 10 11 12)))
    IN->y[3]
    OUT->y[3]

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett over 11 years ago

    The main problemis that lists are not arrays. They are linked-lists which are separate data types to arrays, and are sequential in nature. Generally speaking if you think of lists as arrays, you will make the mistake of assuming that they are random-access, when they are sequential, and write code that is inefficient. 

    Secondly, there are a number of mistakes in your example, so it can't work as is. The second single quote in the setplist will cause the list() not to be evaluated. So it should be:

    setplist('B1 list('p 200 'y list(1 2 3 4 5 6)))
    IN='B1

    Or:

    setplist('B1 `(p 200 y ,list(1 2 3 4 5 6)))  ; note the backquote and also comma before the bits you want to evaluate
    IN='B1

    Then you could use:

    nth(0 IN->y)

    Or, if you really want an array:

    setplist('B1 `(p 200 y ,listToVector(list(1 2 3 4 5 6))))
    IN='B1
    IN->y[0]

    I'm wondering if you really want to use a plist on a symbol either. Maybe some other data structure would be more appropriate - but depends on your application?

    For example - you could do:

    defstruct(MyStruct p y)
    IN=make_MyStruct(?p 200 ?y listToVector(list(1 2 3 4 5 6)))
    OUT=make_MyStruct(?p 100 ?y listToVector(list(7 8 9 10 11 12)))
    IN->y[3]
    OUT->y[3]

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
No Data

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