• 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. function that get a floating point list

Stats

  • Locked Locked
  • Replies 9
  • Subscribers 144
  • Views 15865
  • 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

function that get a floating point list

Ricky81
Ricky81 over 10 years ago

Hello everibody ,

this is my skill code:

procedure(CreateForm()
     let(( mlStartOffset mlOldOffsetA mlNewOffsetA mlOldOffsetB mlNewOffsetB movepins sep3)

        
        mlStartOffset=hiCreateFloatField(
                ?name 'mlStartOffset
                ?prompt "Enter X coordinate to start(e.g.prboundary)"
                )
     mlOldOffsetA=hiCreateFloatField(
                ?name 'mlOldOffsetA
                ?prompt "Enter Old Offset"
                )
     mlOldOffsetB=hiCreateListField(
                ?name 'mlOldOffsetB
                ?prompt "Enter a list of X coord. -OLD Pins position-"
                )
         mlNewOffsetA =hiCreateFloatField(
                ?name 'mlNewOffsetA
                ?prompt "Enter New Offset"
                )
         mlNewOffsetB =hiCreateListField(
                ?name 'mlNewOffsetB
                ?prompt "Enter a list of X coord. -NEW Pins position-"
                )
         movepins=hiCreateButton(
                ?name 'movepins
                ?buttonText "Move Pins after selection"
                ?callback "mlOffsetSelPin()"
                )
    sep3=hiCreateSeparatorField(?name 'sep3);separatore grafico sul menu'
          ;      ?callback "DisplayUserDataForm()"
           ;     )
        hiCreateAppForm(
            ?name 'ExampleForm
            ?formTitle "This skill set a new offset and move pins in new X coordinates"
            ?fields
                list(
                    list(mlStartOffset 0:0 600:30 300)
                    list(mlOldOffsetA 0:30 600:30 300)
                    list(mlOldOffsetB 0:60 600:30 300)
                list(mlNewOffsetA 0:90 600:30 300)
                    list(mlNewOffsetB 0:120 600:30 300)
                    list(movepins 250:170 170:20)
                    list(sep3 0:205 600:0)
                    )
            )
        )
     )
/***************************************************************
*                                                              *
*                      mlOffsetSelPin()                        *
*                                                              *
*              Callback code to move pins                      *
*                                                              *
***************************************************************/
procedure( mlOffsetSelPin()
  let( (oldX oldX1 nblocks1 nblocks oldOffr oldOff newOff newX)
    foreach( i geGetSelectedSet()
        when( i->objType == "rect" && i->purpose == "pin"
            oldX = xCoord(lowerLeft(i->bBox))    ; old X coord
            oldX1 = oldX - mlStartOffset        ; subtract starting offset
            nblocks1 = oldX1/mlOldOffsetA        ; count number of preceding blocks
            nblocks = int( nblocks1 )        ; round it to integer value
            oldOffr = (nblocks1 - nblocks) * mlOldOffsetA    ; calc offset inside the block
            oldOff = round(oldOffr*1000)/1000.0        ; round it to the grid
            ; look for the pin offset
            newOff = 0
            for( n 0 length(mlOldOffsetB)
                when( nth( n mlOldOffsetB ) == oldOff
                    newOff = nth( n mlNewOffsetB)
                )
            )
            ; pin doesn't match the offset list
            if( newOff == 0 then
                printf( "offset not found for pin %s at %L\n" i->net->name lowerLeft(i->bBox) )
            else ; pin found: move it to the new location
                newX = nblocks * mlNewOffsetA +mlStartOffset + newOff
                dbMoveFig(i i->cellView list(newX-oldX:0 "R0"))
            )
        )
    )
  )
)

It doesn't work because I can't find a right way to introduce a list of floating point in mlOldOffsetB mlNewOffsetB variables, to be read in mlOffsetSelPin() procedure.

Could you please help me?? thanks in advance

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 10 years ago

    Isn't this just ExampleForm->mlOldOffsetB->value and ExampleForm->mlNewOffsetB->value ?

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • theopaone
    theopaone over 10 years ago

    Note that the local variables defined in CreateForm such as mlStartOffset are in scope when the form is created but out of scope when the form is displayed. They held the field ID's which are then attached to the form when it is created. The variables are out of scope but the fields are not as they are now accessed through the form symbol.
     
    What Andrew is showing is accessing the field values starting with the form symbol (ExampleForm), the field symbol or name (mlOldOffsetB) and the attribute of value, his example retrieves the value from the field.

    As a good coding practice, the operation function mlOffsetSelPin (the one that moves the pins) should not be tied to the form. This allows the testing of the function without having to manually inputting data in the form. A function tied to a form is very hard to automatically test. I would recommend passing in all the values as an argument to the function, you may be able to reuse the function at a later time with a different form.

    Callback for the movePins button:

    mlOffsetSelPin(ExampleForm->mlStartOffset->value  ExampleForm->mlOldOffsetA->value ExampleForm->mlNewOffsetA->value ExampleForm->mlOldOffsetB->value ExampleForm->mlNewOffsetB->value)

    The callback function would then have arguments through which the values are passed:

    procedure( mlOffsetSelPin(mlStartOffset mlOldOffsetA mlNewOffsetA mlOldOffsetB mlNewOffsetB) ...)

    Just saying...

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Ricky81
    Ricky81 over 10 years ago

    Thanks for support Andrew and theopane!

    I'm a beginner with skill code...

    I'm just implemented your valuable advice, but it doesn' work 'cause in CIW appeare this message                                                                                                           

    *Error* lenght: argument must be a list or an array

     

    this is my new code:

     

     

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

    /***************************************************************
    *                                                              *
    *                       CreateForm()                       *
    *                                                              *
    *                     Create the main form                     *
    *                                                              *
    ***************************************************************/




    procedure(CreateForm()
         let(( mlStartOffset mlOldOffsetA mlOldOffsetB mlNewOffsetB mlNewOffsetA movepins sep3)

            
            mlStartOffset=hiCreateFloatField(
                    ?name 'mlStartOffset
                    ?prompt "Enter X coordinate to start(e.g.prboundary)"
                    )
         mlOldOffsetA=hiCreateFloatField(
                    ?name 'mlOldOffsetA
                    ?prompt "Enter Old Offset"
                    )
         mlOldOffsetB=hiCreateListField(
                    ?name 'mlOldOffsetB
                    ?prompt "Enter a list of X coord. -OLD Pins position-"
                    )
             mlNewOffsetA =hiCreateFloatField(
                    ?name 'mlNewOffsetA
                    ?prompt "Enter New Offset"
                    )
             mlNewOffsetB =hiCreateListField(
                    ?name 'mlNewOffsetB
                    ?prompt "Enter a list of X coord. -NEW Pins position-"
                    )
             movepins=hiCreateButton(
                    ?name 'movepins
                    ?buttonText "Move Pins after selection"
                    ?callback "mlOffsetSelPin(ExampleForm->mlStartOffset->valuei ExampleForm->mlOldOffsetA->value ExampleForm->mlOldOffsetB->value ExampleForm->mlNewOffsetA->value ExampleForm->mlNewOffsetB->value)"
                                    )
                   
        sep3=hiCreateSeparatorField(?name 'sep3);separatore grafico sul menu'
              ;      ?callback "DisplayUserDataForm()"
               ;     )
            hiCreateAppForm(
                ?name 'ExampleForm
                ?formTitle "This skill set a new offset and move pins in new X coordinates"
                ?fields
                    list(
                        list(mlStartOffset 0:0 600:30 300)
                        list(mlOldOffsetA 0:30 600:30 300)
                        list(mlOldOffsetB 0:60 600:30 300)
                    list(mlNewOffsetA 0:90 600:30 300)
                        list(mlNewOffsetB 0:120 600:30 300)
                        list(movepins 250:170 170:20)
                        list(sep3 0:205 600:0)
                        )
                )
            )
         )
    /***************************************************************
    *                                                              *
    *                      mlOffsetSelPin()                        *
    *                                                              *
    *              Callback code to move pins                      *
    *                                                              *
    ***************************************************************/
    procedure( mlOffsetSelPin(mlStartOffset mlOldOffsetA mlNewOffsetA mlOldOffsetB mlNewOffsetB)
      let( (oldX oldX1 nblocks1 nblocks oldOffr oldOff newOff newX)
        foreach( i geGetSelectedSet()
            when( i->objType == "rect" && i->purpose == "pin"
                oldX = xCoord(lowerLeft(i->bBox))    ; old X coord
                oldX1 = oldX - mlStartOffset        ; subtract starting offset
                nblocks1 = oldX1/mlOldOffsetA        ; count number of preceding blocks
                nblocks = int( nblocks1 )        ; round it to integer value
                oldOffr = (nblocks1 - nblocks) * mlOldOffsetA    ; calc offset inside the block
                oldOff = round(oldOffr*1000)/1000.0        ; round it to the grid
                ; look for the pin offset
                newOff = 0
                for( n 0 length(mlOldOffsetB)
                    when( nth( n mlOldOffsetB ) == oldOff
                       

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

     


    If I start function mlOffsetSelPin() alone it works, but inserting each time the values by hand like this:

    ----------------------------------------------------------------------------------------------------------------
    ;old
    mlOldOffsetA =  101.52
    mlOldOffsetB = list(4.22 14.28 34.48 44.54 54.98 65.04 85.24 95.3 )
    ;
    ;new
    mlNewOffsetA =  103.32
    mlNewOffsetB= list(4.47 14.47 35.19 45.19 56.13 66.13 86.85 96.85 )
    ;
    ; start 114.92
    mlStartOffset = 114.92




    procedure( mlOffsetSelPin()
      let( (oldX oldX1 nblocks1 nblocks oldOffr oldOff newOff newX)
        foreach( i geGetSelectedSet()
            when( i->objType == "rect" && i->purpose == "pin"
                oldX = xCoord(lowerLeft(i->bBox))    ; old X coord
                oldX1 = oldX - mlStartOffset        ; subtract starting offset
                nblocks1 = oldX1/mlOldOffsetA        ; count number of preceding blocks
                nblocks = int( nblocks1 )        ; round it to integer value
                oldOffr = (nblocks1 - nblocks) * mlOldOffsetA    ; calc offset inside the block
                oldOff = round(oldOffr*1000)/1000.0        ; round it to the grid
                ; look for the pin offset
                newOff = 0
                for( n 0 length(mlOldOffsetB)
                    when( nth( n mlOldOffsetB ) == oldOff
                        newOff = nth( n mlNewOffsetB)
                    )
                )
                ; pin doesn't match the offset list
                if( newOff == 0 then
                    printf( "offset not found for pin %s at %L\n" i->net->name lowerLeft(i->bBox) )
                else ; pin found: move it to the new location
                    newX = nblocks * mlNewOffsetA +mlStartOffset + newOff
                    dbMoveFig(i i->cellView list(newX-oldX:0 "R0"))
                )
            )
        )
      )
    )

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

     

    Any suggestions?

     

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Ricky81
    Ricky81 over 10 years ago
    I'm trying and trying , but I think that hiCreateListField() It's not the right way to introduce a list of floating point number(the list of X Coordinates). When I get mlOdOffsetB->value , it return only one floating point number,the first .
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 10 years ago

    hiCreateListField is the correct function to use. There were a couple of issues with the code as you pasted it - the end part of the callback function was missing (so I copied it from the second version which didn't have the argument list) and in the ?callback field for the movepins button you had valuei rather than value for the first argument (and hence it always passed nil).

    Anyway, having fixed those little things, the real reason that you have a problem is that you have mlOldOffsetB and mlNewOffsetB specified as list fields, and that is what  your callback is expecting. The callback function is defined:

    procedure( mlOffsetSelPin(mlStartOffset mlOldOffsetA mlNewOffsetA mlOldOffsetB mlNewOffsetB)

    but in the callback function for movepins, it calls it with the fields in this order:

    mlOffsetSelPin(ExampleForm->mlStartOffset->value ExampleForm->mlOldOffsetA->value ExampleForm->mlOldOffsetB->value ExampleForm->mlNewOffsetA->value ExampleForm->mlNewOffsetB->value)

    So that's a different order. You define it as needing the old and new offsetA followed by old and new offsetB, but actually call it with the two old offsets and then the two new offsets.

    I can see that the complete lists are being passed (if you call trace(mlOffsetSelPin) you'll see this in the CIW), and the code completes (I don't have an example that works because I couldn't quite see what the code is supposed to be doing, but hopefully this is sufficient to get you moving).

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Ricky81
    Ricky81 over 10 years ago

    Hi Andrew I really appreciate your suggestions, thanks a lot for this.


    But unfortunatelly skill code still doesn't work.

    This below my latest code fixed as you suggested:

    /***************************************************************
    *                                                              *
    *                       CreateForm()                           *
    *                                                              *
    *                     Create the main form                     *
    *                                                              *
    ***************************************************************/
    procedure(CreateForm()
         let(( mlStartOffset mlOldOffsetA mlOldOffsetB mlNewOffsetA mlNewOffsetB movepins )

            
            mlStartOffset=hiCreateFloatField(
                    ?name 'mlStartOffset
                    ?prompt "Enter X coordinate to start"
                    )
         mlOldOffsetA=hiCreateFloatField(
                    ?name 'mlOldOffsetA
                    ?prompt "Enter Old Offset"
                    )
         mlOldOffsetB=hiCreateListField(
                    ?name 'mlOldOffsetB
                    ?prompt "Enter a list of X coord. -OLD Pins position-"
                    )
             mlNewOffsetA =hiCreateFloatField(
                    ?name 'mlNewOffsetA
                    ?prompt "Enter New Offset"
                    )
             mlNewOffsetB =hiCreateListField(
                    ?name 'mlNewOffsetB
                    ?prompt "Enter a list of X coord. -NEW Pins position-"
                    )
             movepins=hiCreateButton(
                    ?name 'movepins
                    ?buttonText "Move Pins after selection"
                    ?callback "mlOffsetSelPin(ExampleForm->mlStartOffset->value ExampleForm->mlOldOffsetA->value ExampleForm->mlOldOffsetB->value ExampleForm->mlNewOffsetA->value ExampleForm->mlNewOffsetB->value)"
                                    )
            hiCreateAppForm(
                ?name 'ExampleForm
                ?formTitle "This skill set a new offset and move pins in new X coordinates"
                ?fields
                    list(
                        list(mlStartOffset 0:0 600:30 300)
                        list(mlOldOffsetA 0:30 600:30 300)
                        list(mlOldOffsetB 0:60 600:30 300)
                    list(mlNewOffsetA 0:90 600:30 300)
                        list(mlNewOffsetB 0:120 600:30 300)
                        list(movepins 250:170 170:20)
                        )
                )
            )
         )
    /***************************************************************
    *                                                              *
    *                      mlOffsetSelPin()                        *
    *                                                              *
    *              Callback code to move pins                      *
    *                                                              *
    ***************************************************************/
    procedure( mlOffsetSelPin(mlStartOffset mlOldOffsetA mlOldOffsetB mlNewOffsetA mlNewOffsetB)
      let( (oldX oldX1 nblocks1 nblocks oldOffr oldOff newOff newX)
        foreach( i geGetSelectedSet()
            when( i->objType == "rect" && i->purpose == "pin"
                oldX = xCoord(lowerLeft(i->bBox))    ; old X coord
                oldX1 = oldX - mlStartOffset        ; subtract starting offset
                nblocks1 = oldX1/mlOldOffsetA        ; count number of preceding blocks
                nblocks = int( nblocks1 )        ; round it to integer value
                oldOffr = (nblocks1 - nblocks) * mlOldOffsetA    ; calc offset inside the block
                oldOff = round(oldOffr*1000)/1000.0        ; round it to the grid
                ; look for the pin offset
                newOff = 0
                for( n 0 length(mlOldOffsetB)
                    when( nth( n mlOldOffsetB ) == oldOff
                        newOff = nth( n mlNewOffsetB)
                    )
                )
                ; pin doesn't match the offset list
                if( newOff == 0 then
                    printf( "offset not found for pin %s at %L\n" i->net->name lowerLeft(i->bBox) )
                else ; pin found: move it to the new location
                    newX = nblocks * mlNewOffsetA +mlStartOffset + newOff
                    dbMoveFig(i i->cellView list(newX-oldX:0 "R0"))
                )
            )
        )
      )
    )
    /***************************************************************
    *                                                              *
    *                       OffsetExample()                        *
    *                                                              *
    *                       Main entry point                       *
    *                                                              *
    ***************************************************************/
    procedure(OffsetExample()
         unless(boundp('ExampleForm)
            CreateForm()
            )
            )
         hiDisplayForm(ExampleForm)

    When I start skill on CIW , enter all values on form and push botton 'movepins with ?callback mlOffsetSelPin function


    an error message appear:

    *Error* length: argument must be a list or an array - 103.32

     

    But this value is relative to mlNewOffsetA, so... I don't understand!

     


    Thanks again for your support

     



        

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

    This is almost certainly because you have the unless(boundp('ExampleForm)..) code there. What is happening is that if the ExampleForm variable exists, it doesn't recreate the form.

    So you have your old form with the callbacks in the wrong order.

    Make sure the form isn't on the screen, and then do:

    ExampleForm='unbound

    and then run OffsetExample() (which by the way has the last parenthesis in the wrong place - presumably something that broke when you pasted it).

    That will force the form to be re-created and all will be OK. Also quitting virtuoso and re-starting would have solved this too. Or manually calling CreateForm()

    Regards,

    Andrew.

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

    I meant to say that the code worked for me (well, it didn't work, but it didn't break). I filled in the values you had on the form, selected four pins on my layout, and then when I hit the "Move" button, I got:

    offset not found for pin a at (-5.8 4.41)
    offset not found for pin b at (-2.91 3.695)
    offset not found for pin c at (-0.205 4.485)
    offset not found for pin d at (3.885 5.575)

    in the CIW. No length error...

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Ricky81
    Ricky81 over 10 years ago

    Finally It works!!!

    Many thanks for your support.

    Best regards

    Ricky

    • 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