• 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 Design
  3. ADE Assembler: variable values with leading zeros interpreted...

Stats

  • Locked Locked
  • Replies 6
  • Subscribers 125
  • Views 12351
  • 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

ADE Assembler: variable values with leading zeros interpreted as octal in ICADVM20.1

dontpanic
dontpanic over 4 years ago

Hi! We recently switched to ICADVM20.1 and started to get weird results in many old testbenches. After a close lookup, it turns out that all the variables with values starting with zero ("0") are being interpreted as octal!

We have lots of testbenches where we use leading zeros as indentation in values to improve clarity, e.g (note leading zeros in front of 503 and 61):

As changing all these existing maestro views would mean a colossal work, we look for a workaround. Will this behavior be corrected in the future (or maybe has been already corrected?)?

Thanks in advance for any help!

KR, Jorge.

  • Cancel
Parents
  • dontpanic
    dontpanic over 4 years ago

    Thank you all for your replies. Interesting situation to say the least! (I wonder about the origins of the idea of using "0" as a prefix for octal--never heard of that before in my entire career!)

    I guess we'll have to explore the solution of automatically updating it via skill, but that will be a problem for "future Jorge". For the time being I guess we'll have to update manually on a per-case basis...

    Cheers,

    Jorge.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 4 years ago in reply to dontpanic

    Hi Jorge,

    The C language also treats literal integers which start with a 0 as octal, so it's not unique to SKILL. Of course, most designers would not necessarily expect this - in the same way that designers get confused by the fact that 1/2 in expressions is 0!

    I wrote some code that I think will do the job of the cleanup. Caveat emptor, since I've really not done a huge amount of testing - you might want to try using abCleanOctalLikeNumbersInVars() on an open session or two before trying abRegOctalLikeNumbers() to do it automatically when a maestro view is opened (if you really want that). Hopefully I got the regular expression right!

    Regards,

    Andrew

    /* abCleanOctalLikeNumbers.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Apr 01, 2021 
    Modified   
    By         
    
    Provide functions to clean up numbers that will be interpreted
    in SKILL as octal, even though that wasn't what the designer intended
    
    abCleanOctalLikeNumbersInVars([session]
        cleans up all design and global variables in the given (or current)
        ADE XL/Explorer/Assembler session
    
    abRegCleanOctalLikeNumbers()
        registers a trigger to do the cleanup whenever a maestro or adexl
        view is opened. Use once you're happy it works properly (I
        have only done limited testing)
    
    ***************************************************
    
    SCCS Info: @(#) abCleanOctalLikeNumbers.il 04/02/21.10:25:24 1.2
    
    */
    
    /************************************************************************
    *                                                                       *
    *                  abCleanOctalLikeNumbers(expression)                  *
    *                                                                       *
    * Take a string expression, and replace any number that starts with a 0 *
    * so that it doesn't start with a number any more. This avoids numbers  *
    *              starting with 0 as being treated as octal.               *
    *                                                                       *
    ************************************************************************/
    
    procedure(abCleanOctalLikeNumbers(expression)
        ;--------------------------------------------------------------------
        ; pattern looks for a non-word non-dot character, followed by one 
        ; or more zeros, followed by one or more digits
        ;--------------------------------------------------------------------
        let(((pat pcreCompile("(^|[^\\w.])0+(\\d+)")))
            if(stringp(expression) && pcreExecute(pat expression) then
                pcreReplace(pat expression "\\1\\2" 0)
            else
                expression
            )
        )
    )
    
    /***********************************************************************
    *                                                                      *
    *                abCleanOctalLikeNumbersForHandle(sdb)                 *
    *                                                                      *
    *   Passed either a handle for the whole view (for global variables)   *
    * or for a test (for design variables) and iterates over all variables *
    *        and tries cleaning them up to avoid octal-like values         *
    *                                                                      *
    ***********************************************************************/
    
    procedure(abCleanOctalLikeNumbersForHandle(sdb)
        let((var curValue newValue)
            foreach(varName cadr(axlGetVars(sdb))
                var=axlGetVar(sdb varName)
                curValue=axlGetVarValue(var)
                newValue=abCleanOctalLikeNumbers(curValue)
                unless(newValue==curValue
                    printf("Changing Expression %s to %s\n" curValue newValue)
                    axlPutVar(sdb varName newValue)
                )
            )
            t
        )
    )
    
    /***************************************************************
    *                                                              *
    *           abCleanOctalLikeNumbersInVars([session])           *
    *                                                              *
    *     Fixes all the octal-like numbers in a given session      *
    *                 (defaults to current window)                 *
    *                                                              *
    ***************************************************************/
    
    procedure(abCleanOctalLikeNumbersInVars(
            @optional (session axlGetWindowSession()))
        let((sdb test)
            sdb=axlGetMainSetupDB(session)
            abCleanOctalLikeNumbersForHandle(sdb)
            foreach(testName cadr(axlGetTests(sdb))
                test=axlGetTest(sdb testName)
                abCleanOctalLikeNumbersForHandle(test)
            )
            t
        )
    )
    
    /***************************************************************
    *                                                              *
    *           abRegCleanOctalLikeNumbersInit(session)            *
    *                                                              *
    *   Registers a trigger to do the cleanup once the UI is up    *
    *                                                              *
    ***************************************************************/
    
    procedure(abRegCleanOctalLikeNumbersInit(session)
        axlSessionConnect(session "postInstall" 'abCleanOctalLikeNumbersInVars)
    )
    
    /***************************************************************
    *                                                              *
    *                 abRegCleanOctalLikeNumbers()                 *
    *                                                              *
    *   Registers the postInstall trigger at startup of the view   *
    *                                                              *
    ***************************************************************/
    
    procedure(abRegCleanOctalLikeNumbers()
        axlSessionRegisterCreationCallback('abRegCleanOctalLikeNumbersInit)
    )
    
    /***************************************************************
    *                                                              *
    *                abTestCleanOctalLikeNumbers()                 *
    *                                                              *
    *            Test code to check for a few examples             *
    *                                                              *
    ***************************************************************/
    
    procedure(abTestCleanOctalLikeNumbers()
        assert(abCleanOctalLikeNumbers("0123")=="123")
        assert(abCleanOctalLikeNumbers("(0562+0*012)/073^02")=="(562+0*12)/73^2")
        assert(abCleanOctalLikeNumbers("TRIM_024_VAL+014")=="TRIM_024_VAL+14")
        assert(abCleanOctalLikeNumbers("0.0033")=="0.0033")
        assert(abCleanOctalLikeNumbers("if( 012==12 0515 0632 )")==
            "if( 12==12 515 632 )")
        t
    )
    

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett over 4 years ago in reply to dontpanic

    Hi Jorge,

    The C language also treats literal integers which start with a 0 as octal, so it's not unique to SKILL. Of course, most designers would not necessarily expect this - in the same way that designers get confused by the fact that 1/2 in expressions is 0!

    I wrote some code that I think will do the job of the cleanup. Caveat emptor, since I've really not done a huge amount of testing - you might want to try using abCleanOctalLikeNumbersInVars() on an open session or two before trying abRegOctalLikeNumbers() to do it automatically when a maestro view is opened (if you really want that). Hopefully I got the regular expression right!

    Regards,

    Andrew

    /* abCleanOctalLikeNumbers.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Apr 01, 2021 
    Modified   
    By         
    
    Provide functions to clean up numbers that will be interpreted
    in SKILL as octal, even though that wasn't what the designer intended
    
    abCleanOctalLikeNumbersInVars([session]
        cleans up all design and global variables in the given (or current)
        ADE XL/Explorer/Assembler session
    
    abRegCleanOctalLikeNumbers()
        registers a trigger to do the cleanup whenever a maestro or adexl
        view is opened. Use once you're happy it works properly (I
        have only done limited testing)
    
    ***************************************************
    
    SCCS Info: @(#) abCleanOctalLikeNumbers.il 04/02/21.10:25:24 1.2
    
    */
    
    /************************************************************************
    *                                                                       *
    *                  abCleanOctalLikeNumbers(expression)                  *
    *                                                                       *
    * Take a string expression, and replace any number that starts with a 0 *
    * so that it doesn't start with a number any more. This avoids numbers  *
    *              starting with 0 as being treated as octal.               *
    *                                                                       *
    ************************************************************************/
    
    procedure(abCleanOctalLikeNumbers(expression)
        ;--------------------------------------------------------------------
        ; pattern looks for a non-word non-dot character, followed by one 
        ; or more zeros, followed by one or more digits
        ;--------------------------------------------------------------------
        let(((pat pcreCompile("(^|[^\\w.])0+(\\d+)")))
            if(stringp(expression) && pcreExecute(pat expression) then
                pcreReplace(pat expression "\\1\\2" 0)
            else
                expression
            )
        )
    )
    
    /***********************************************************************
    *                                                                      *
    *                abCleanOctalLikeNumbersForHandle(sdb)                 *
    *                                                                      *
    *   Passed either a handle for the whole view (for global variables)   *
    * or for a test (for design variables) and iterates over all variables *
    *        and tries cleaning them up to avoid octal-like values         *
    *                                                                      *
    ***********************************************************************/
    
    procedure(abCleanOctalLikeNumbersForHandle(sdb)
        let((var curValue newValue)
            foreach(varName cadr(axlGetVars(sdb))
                var=axlGetVar(sdb varName)
                curValue=axlGetVarValue(var)
                newValue=abCleanOctalLikeNumbers(curValue)
                unless(newValue==curValue
                    printf("Changing Expression %s to %s\n" curValue newValue)
                    axlPutVar(sdb varName newValue)
                )
            )
            t
        )
    )
    
    /***************************************************************
    *                                                              *
    *           abCleanOctalLikeNumbersInVars([session])           *
    *                                                              *
    *     Fixes all the octal-like numbers in a given session      *
    *                 (defaults to current window)                 *
    *                                                              *
    ***************************************************************/
    
    procedure(abCleanOctalLikeNumbersInVars(
            @optional (session axlGetWindowSession()))
        let((sdb test)
            sdb=axlGetMainSetupDB(session)
            abCleanOctalLikeNumbersForHandle(sdb)
            foreach(testName cadr(axlGetTests(sdb))
                test=axlGetTest(sdb testName)
                abCleanOctalLikeNumbersForHandle(test)
            )
            t
        )
    )
    
    /***************************************************************
    *                                                              *
    *           abRegCleanOctalLikeNumbersInit(session)            *
    *                                                              *
    *   Registers a trigger to do the cleanup once the UI is up    *
    *                                                              *
    ***************************************************************/
    
    procedure(abRegCleanOctalLikeNumbersInit(session)
        axlSessionConnect(session "postInstall" 'abCleanOctalLikeNumbersInVars)
    )
    
    /***************************************************************
    *                                                              *
    *                 abRegCleanOctalLikeNumbers()                 *
    *                                                              *
    *   Registers the postInstall trigger at startup of the view   *
    *                                                              *
    ***************************************************************/
    
    procedure(abRegCleanOctalLikeNumbers()
        axlSessionRegisterCreationCallback('abRegCleanOctalLikeNumbersInit)
    )
    
    /***************************************************************
    *                                                              *
    *                abTestCleanOctalLikeNumbers()                 *
    *                                                              *
    *            Test code to check for a few examples             *
    *                                                              *
    ***************************************************************/
    
    procedure(abTestCleanOctalLikeNumbers()
        assert(abCleanOctalLikeNumbers("0123")=="123")
        assert(abCleanOctalLikeNumbers("(0562+0*012)/073^02")=="(562+0*12)/73^2")
        assert(abCleanOctalLikeNumbers("TRIM_024_VAL+014")=="TRIM_024_VAL+14")
        assert(abCleanOctalLikeNumbers("0.0033")=="0.0033")
        assert(abCleanOctalLikeNumbers("if( 012==12 0515 0632 )")==
            "if( 12==12 515 632 )")
        t
    )
    

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
  • Andrew Beckett
    Andrew Beckett over 4 years ago in reply to Andrew Beckett

    Hi Jorge,

    I updated the code I posted yesterday - so don't use the code in any email notification from yesterday; use the latest code in the thread above (I replaced it in the post with version 1.2 to avoid having two versions in the thread). I suddenly realised (in the middle of the night, as you do) that it would rather unhelpfully "clean" floating point numbers that had zeros (e.g. "0.0012" would have become "0.12", which is clearly wrong). Hopefully there aren't other issues (other than I know it will still remove leading zeros in numbers inside double quotes within the expression - I decided that was fairly unlikely to happen and probably not worth the complexity of trying to deal with).

    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