• 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. Return multiple values from procedure

Stats

  • Locked Locked
  • Replies 1
  • Subscribers 144
  • Views 15504
  • 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

Return multiple values from procedure

ank088
ank088 over 9 years ago

Hello

I am trying to return multiple values from a procedure (actually lists).

Here is what I am hoping to achieve

procedure call  : parseFile(myfile l_dev l_Tuck l_PC_Pitch l_Nfin)

procedure(parseFile(File l_dev l_Tuck l_PC_Pitch l_Nfin)
  let(( strSplit table fpFile fpoutFile  )
     myFile = infile(File)
     while( gets( line myFile )
      strSplit = parseString( line )
         if(nth(0 strSplit)== "Device" then
            tempList=strSplit
            l_dev=remove(nth(0 tempList) tempList)
         else
             tempList=strSplit cdf=nth(1 strSplit)
             tempList=remove(nth(0 tempList) tempList)
              case(nth(0 strSplit)
                 ("Nfin"  l_Nfin=tempList )
                 ("Pitch" l_PC_Pitch=tempList)
                 ("Tuck" l_Tuck=tempList)
                 ("Finger" l_Finger=tempList)
               )
       ))
    close(fpFile)
    l_dev l_Tuck l_PC_Pitch l_Nfin
))

Contents of myfile

Device dev1 dev2 dev3 dev4
Tk single double
Nfin 2 4 8
Pitch 70n 90n

Evidently, what I trying to achieve is to pass a set of lists that are initialized in main, have them populated within the procedure and return the same back to main. The reason is I want to use this procedure as a sort of a generic procedure which can be used across scripts where the list input in "myfile" would depend

 It looks like variables passed to procedure cannot be changed within the procedure (ie Cstyle pass by reference). There probably is a simple method, but I'm not an skill expert. Hence the question

Thanks

Anukul

  • Cancel
Parents
  • Quek
    Quek over 9 years ago

    Hi Anukul

    You can return the various lists as a single list. E.g.

    list(l_dev l_Tuck l_PC_Pitch l_Nfin)

    You can then get the return values using:

    results=parseFile(File l_dev l_Tuck l_PC_Pitch l_Nfin)
    l_dev=nth(0 results)
    l_Tuck=nth(1 results)
    l_PC_Pitch=nth(2 results)
    l_Nfin=nth(3 results)

    Alternatively, you can use a table. E.g.


    procedure( myMainProc()
       let( (myTable)
          myTable=makeTable("myTable" nil)
          parseFile(myfile myTable)
          printf("%L\n" myTable["l_dev")
          ...
       ) ;let
    ) ;procedure

    procedure(parseFile(File myTable)
      let(( strSplit table fpFile fpoutFile  )
         ...
         myTable["l_dev"]=remove(nth(0 tempList) tempList)
         ...
         ("Nfin" myTable["l_Nfin"]=tempList )

         ...
       ) ;let
    ) ;procedure



    Best regards
    Quek


    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • Quek
    Quek over 9 years ago

    Hi Anukul

    You can return the various lists as a single list. E.g.

    list(l_dev l_Tuck l_PC_Pitch l_Nfin)

    You can then get the return values using:

    results=parseFile(File l_dev l_Tuck l_PC_Pitch l_Nfin)
    l_dev=nth(0 results)
    l_Tuck=nth(1 results)
    l_PC_Pitch=nth(2 results)
    l_Nfin=nth(3 results)

    Alternatively, you can use a table. E.g.


    procedure( myMainProc()
       let( (myTable)
          myTable=makeTable("myTable" nil)
          parseFile(myfile myTable)
          printf("%L\n" myTable["l_dev")
          ...
       ) ;let
    ) ;procedure

    procedure(parseFile(File myTable)
      let(( strSplit table fpFile fpoutFile  )
         ...
         myTable["l_dev"]=remove(nth(0 tempList) tempList)
         ...
         ("Nfin" myTable["l_Nfin"]=tempList )

         ...
       ) ;let
    ) ;procedure



    Best regards
    Quek


    • 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