• 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. Replace a pattern with groups using pcre or regex

Stats

  • Locked Locked
  • Replies 1
  • Subscribers 143
  • Views 14077
  • 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

Replace a pattern with groups using pcre or regex

VenuA
VenuA over 10 years ago

If I have a a string say:

myString="((pPar(\"area\"))*(pPar(\"m\")))" 

I want to convert it to myStringAfter = area*m 

If I use recReplace or pcre functions, I am getting myStringAfter=(area)*(m)

But, I can not evaluate as (mi) or (area) are considered as functions in Skill for my purpose.

Is there any way I can use pPar(\"[a-z A-Z 0-9]+\") or any smart regular expressions and group the "area" and "m" and replace them without open and close brackets?

I tried in possible combinations, and I am not successful so far.

Regards,

Venu

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

    Venu,

    I think to remove matched parentheses with regular expressions isn't that easy in a single shot - the issue is knowing where you want the expressions and where you don't (for example, you'd want (3+area)*(m) to only remove the parentheses around the m. You could probably do this with repeated calls to strip out () around a variable name though.

    Anyway, I'd also consider using the AEL functions to evaluate the expression, rather than making it look like SKILL (which it isn't). For example, something like this:

    /* abIPar.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Aug 28, 2003 
    Modified   
    By         
    
    Function that can be used in an opParamExprList()
    CDF setup to get an instance's parameter value.
    
    Note, this is not the _simulated_ value necessarily...
    
    ***************************************************
    
    SCCS Info: @(#) abIPar.il 07/01/08.21:14:26 1.3
    
    */
    
    (procedure (abIPar paramName @optional (inst ilInst) (slot 'value))
      (let (env lineage session cdf unevaluated evaluated compiled top)
           (setq top (geGetTopLevelCellView))
           (getWarn)
           (unless top (error "Can't find parameter %s" paramName))
           ;-----------------------------------------------------------------
           ; Get the original parameter value
           ;-----------------------------------------------------------------
           (setq cdf (cdfGetInstCDF inst))
           (setq unevaluated (get (get cdf (concat paramName)) slot))
           ;-----------------------------------------------------------------
           ; If it is a string, evaluate it as an AEL expression
           ;-----------------------------------------------------------------
           (if (stringp unevaluated) 
               (progn
                (setq env (aelEnvCreate "f"))
                ;-----------------------------------------------------------
                ; set the path down to this element
                ;-----------------------------------------------------------
                (setq lineage (append1 (reverse 
                                        (mapcar 'car (geGetHierMemInst))) 
                                       top))
                (setq lineage (cons inst lineage))
                (aelSetLineage env lineage)
                ;-----------------------------------------------------------------
                ; Get the current session
                ;-----------------------------------------------------------------
                (setq session (asiGetSession (hiGetCurrentWindow)))
                ;-----------------------------------------------------------------
                ; define all the global variables
                ;-----------------------------------------------------------------
                (foreach designVar 
                         (or (and session (asiGetDesignVarList session))
                             (artGetCellViewDesignVarList top))
                         (aelEnvSetGlobals env (car designVar) (cadr designVar))
                         )
                ;-----------------------------------------------------------------
                ; Evaluate the expression
                ;-----------------------------------------------------------------
                (if (or (null unevaluated)
                        (equal unevaluated "")) 
                    (setq evaluated 0.0)
                    (progn
                     (setq compiled (aelEnvCompile env unevaluated))
                     (if compiled
                         (setq evaluated (aelNumber (aelEnvExecute compiled)))
                         (progn
                          (printf "*ERROR* %s " (aelEnvGetErrStr))
                          (setq evaluated nil)))
                     ))
                evaluated
                )
               ;-------------------------------------------------------------
               ; Otherwise, if not a string, return it as it is
               ;-------------------------------------------------------------
               unevaluated
               )
           )
      )
    

    Note that this is figuring out the "lineage" (i.e. hierarchical path" from how you pushed through the hierarchy, so you might need a different approach depending on what your goal is.

    Kind Regards,

    Andrew.

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

    Venu,

    I think to remove matched parentheses with regular expressions isn't that easy in a single shot - the issue is knowing where you want the expressions and where you don't (for example, you'd want (3+area)*(m) to only remove the parentheses around the m. You could probably do this with repeated calls to strip out () around a variable name though.

    Anyway, I'd also consider using the AEL functions to evaluate the expression, rather than making it look like SKILL (which it isn't). For example, something like this:

    /* abIPar.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Aug 28, 2003 
    Modified   
    By         
    
    Function that can be used in an opParamExprList()
    CDF setup to get an instance's parameter value.
    
    Note, this is not the _simulated_ value necessarily...
    
    ***************************************************
    
    SCCS Info: @(#) abIPar.il 07/01/08.21:14:26 1.3
    
    */
    
    (procedure (abIPar paramName @optional (inst ilInst) (slot 'value))
      (let (env lineage session cdf unevaluated evaluated compiled top)
           (setq top (geGetTopLevelCellView))
           (getWarn)
           (unless top (error "Can't find parameter %s" paramName))
           ;-----------------------------------------------------------------
           ; Get the original parameter value
           ;-----------------------------------------------------------------
           (setq cdf (cdfGetInstCDF inst))
           (setq unevaluated (get (get cdf (concat paramName)) slot))
           ;-----------------------------------------------------------------
           ; If it is a string, evaluate it as an AEL expression
           ;-----------------------------------------------------------------
           (if (stringp unevaluated) 
               (progn
                (setq env (aelEnvCreate "f"))
                ;-----------------------------------------------------------
                ; set the path down to this element
                ;-----------------------------------------------------------
                (setq lineage (append1 (reverse 
                                        (mapcar 'car (geGetHierMemInst))) 
                                       top))
                (setq lineage (cons inst lineage))
                (aelSetLineage env lineage)
                ;-----------------------------------------------------------------
                ; Get the current session
                ;-----------------------------------------------------------------
                (setq session (asiGetSession (hiGetCurrentWindow)))
                ;-----------------------------------------------------------------
                ; define all the global variables
                ;-----------------------------------------------------------------
                (foreach designVar 
                         (or (and session (asiGetDesignVarList session))
                             (artGetCellViewDesignVarList top))
                         (aelEnvSetGlobals env (car designVar) (cadr designVar))
                         )
                ;-----------------------------------------------------------------
                ; Evaluate the expression
                ;-----------------------------------------------------------------
                (if (or (null unevaluated)
                        (equal unevaluated "")) 
                    (setq evaluated 0.0)
                    (progn
                     (setq compiled (aelEnvCompile env unevaluated))
                     (if compiled
                         (setq evaluated (aelNumber (aelEnvExecute compiled)))
                         (progn
                          (printf "*ERROR* %s " (aelEnvGetErrStr))
                          (setq evaluated nil)))
                     ))
                evaluated
                )
               ;-------------------------------------------------------------
               ; Otherwise, if not a string, return it as it is
               ;-------------------------------------------------------------
               unevaluated
               )
           )
      )
    

    Note that this is figuring out the "lineage" (i.e. hierarchical path" from how you pushed through the hierarchy, so you might need a different approach depending on what your goal is.

    Kind 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