• 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. problem wih simulating symbols with cdf

Stats

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

problem wih simulating symbols with cdf

Skywalker121
Skywalker121 over 5 years ago

HI everyone,

I imported a standard cell library with spiceIn, and got many schematics corrosponding to defferent symbols.(device map: W w L l)

The cdl file contains some sub-circuits with parameters, as the first figure shows.

The circuits containing these sub-circuits are thus converted into schematics with symbols of corrresponding circuits, as the second figure shows

the sizes of the mosfets in the symbol circuit are correctly recorded in the cdf parameters of the symbol, as the next figure shows.

I tried to use these schematics for simulation ,but I need to set some parameter in ADE to make the circuit work.

The problem is that there are more than one symbols with the same four parameters "PW","PL","NW","NL", but the values are different. I can only set four parameter valuse in the ADE, thus setting all the symbols in the same way, which is wrong.

so how can I set all the sizes correctly during simulation?Or did I imported the cdl netlist in a wrong way?Aanyone can  help me with this? Thanks in advance!

  • Cancel
Parents
  • Skywalker121
    Skywalker121 over 5 years ago

    anyone met the same situation?

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • ShawnLogan
    ShawnLogan over 5 years ago in reply to Skywalker121

    Dear Skywalker121,

    Skywalker121 said:

    he problem is that there are more than one symbols with the same four parameters "PW","PL","NW","NL", but the values are different. I can only set four parameter valuse in the ADE, thus setting all the symbols in the same way, which is wrong.

    so how can I set all the sizes correctly during simulation?Or did I imported the cdl netlist in a wrong way?Aanyone can  help me with this? Thanks in advance!

    I may understand your concern - and if so I apologize - but it seems you can set a unique numeric value to each of the four parameters for each subcircuit. If you would rather not set a numeric value to each, you can enter a new variable name. The variable can be used in your Assembler or Explorer simulations. Of course, a different set of 4 variables is required for each subcircuit if you wish each to be unique values. The fact that the CDF parameter names is the same for each symbol is not an issue and should not prevent you from setting the parameter differently between subcircuit instances.

    Does this make sense? as a means to check this, you can create a netlist from your schematic. The CDF parameter names will not show up in your list of parameters at the beginning of your input.scs.

    I hope I umderstood your question,

    Shawn

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Skywalker121
    Skywalker121 over 5 years ago in reply to ShawnLogan

    Dear ShawnLogan

    I created a netlist as u said, but the CDF parameter names showed up at the beginning of input.scs file. I dont know what is going on here...   :(

    // Generated for: spectre
    // Generated on: Jun 7 12:38:25 2020
    // Design library name: QVGA_V1A
    // Design cell name: SC_test
    // Design view name: schematic
    simulator lang=spectre
    global 0 GND! VDD!
    parameters NL NW PL PW
    include "/home/eng/designs/lib/HHGrace/Models/gd018.scs" section=tt

    // Library name: GSMC18_SC
    // Cell name: IVG
    // View name: schematic
    subckt IVG A GND! VDD! Z
    MN0 (Z A GND! GND!) NCH w=(220n) l=NL as=194f ad=194f ps=1.84u \
    pd=1.84u count=(1)*(1) nrd=1.31818 nrs=1.31818 misfactor=1
    MP0 (VDD! A Z VDD!) PCH w=(220n) l=PL as=194f ad=194f ps=1.84u \
    pd=1.84u count=(1)*(1) nrd=1.31818 nrs=1.31818 misfactor=1
    ends IVG
    // End of subcircuit definition.

    // Library name: GSMC18_SC
    // Cell name: AND2HD2X
    // View name: schematic
    subckt AND2HD2X A B Z
    XI2 (NET26 GND! VDD! Z) IVG
    MP1 (VDD! B NET26 VDD!) PCH w=(8E-07) l=1.8E-07 as=194f ad=194f \
    ps=1.84u pd=1.84u count=(1)*(1) nrd=1.31818 nrs=1.31818 \
    misfactor=1
    MP0 (VDD! A NET26 VDD!) PCH w=(8E-07) l=1.8E-07 as=194f ad=194f \
    ps=1.84u pd=1.84u count=(1)*(1) nrd=1.31818 nrs=1.31818 \
    misfactor=1
    MN0 (NET26 B NET6 GND!) NCH w=(6.6E-07) l=1.8E-07 as=194f ad=194f \
    ps=1.84u pd=1.84u count=(1)*(1) nrd=1.31818 nrs=1.31818 \
    misfactor=1
    MN1 (NET6 A GND! GND!) NCH w=(6.6E-07) l=1.8E-07 as=194f ad=194f \
    ps=1.84u pd=1.84u count=(1)*(1) nrd=1.31818 nrs=1.31818 \
    misfactor=1
    ends AND2HD2X
    // End of subcircuit definition.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Skywalker121
    Skywalker121 over 5 years ago in reply to ShawnLogan

    Dear ShawnLogan,

    Thanks for ur response! The simuation seems to be different from what u said. I created the netlist, but the CDF parameter sitll showed up at the beginning of my input.scs file. Disappointed

    Is there anything wrong?

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • ShawnLogan
    ShawnLogan over 5 years ago in reply to Skywalker121

    Dear Skywalker121,

    Skywalker121 said:
    Thanks for ur response! The simuation seems to be different from what u said. I created the netlist, but the CDF parameter sitll showed up at the beginning of my input.scs file

    Would you mind posting your input.scs? This might help.

    Shawn

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Skywalker121
    Skywalker121 over 5 years ago in reply to ShawnLogan

    Dear ShawnLogan,

    I copied the contain of the input.scs file in the previous reply bacause I dont know to to add an attachment. Please check it. :)

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 5 years ago in reply to Skywalker121

    The issue is that SPICEIN doesn't handle parameterised blocks using the ADE/CDF way of parameter passing - it uses the older "NLP" parameter passing. This then doesn't work if you use ADE to netlist instances of the block. Cadence Change Request (CCR) 817161 is asking for this enhancement, but it's not been implemented yet.

    In response to this, I wrote some SKILL code to try to deal with it and convert the passed parameters into pPar expressions instead. I'm not sure how robust this code is, but it's been tried on a  few different examples (by other AEs too). So you might find this useful. It also requires abInvokeCdfCallbacks.il which you can find in this post.

    To use it, see the comments at the top of the code.

    Regards,

    Andrew.

    /* abConvertSPICEINvarsToPPar.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Jul 18, 2013 
    Modified   Jan 31, 2018 
    By         A.D.Beckett
    
    Example of usage:
    
    abConvertSPICEINvarsToPParForTopLCV(
        ?lib "mylib" ?cell "mycell" ?view "schematic" 
        ?updateCDF t ?verbose t ?callCallbacks t 
        ?order list("w" "l")
    )
    
    For a PAS-created PDK (such as gpdk045) you may need to pass some of 
    the additional arguments that abInvokeCdfCallbacks offers (this is
    to use instance CDF rather than effective CDF, and to call the init proc
    to do some initialisation that the callbacks need):
    
    abConvertSPICEINvarsToPParForTopLCV(
        ?lib "mylib" ?cell "mycell" ?view "schematic" 
        ?updateCDF t ?verbose t ?callCallbacks t 
        ?useInstCDF t ?callInitProc t
        ?order list("fw" "l")
    )
    
    Modified to handle AEL reserved words (such as "ln")
    as variable names. Note that the code will not work correctly
    if a variable appears in an expression both as a variable
    and a function - so if you have "ln+ln(2.0)". However,
    this seems an unlikely scenario
    
    Also added a ?updateCDF argument to correct CDF parameters
    created by SPICEIN which don't have parseAsCEL or parseAsNumber
    set. This also takes care of converting m parameters (for m-factor)
    into CDF parameters.
    
    ***************************************************
    
    SCCS Info: @(#) abConvertSPICEINvarsToPPar.il 01/31/18.10:23:13 1.5
    
    */
    
    /***************************************************************
    *                                                              *
    *     (abConvertInstSPICEINvarsToPPar inst @key updateCDF)     *
    *                                                              *
    * Look for variables in CDF parameters, and then convert them  *
    *   into pPar() expressions. This is because SPICE IN leaves   *
    *    parameters in the CDL/SPICE as bare variables - which     *
    *          correspond to design variables, not pPar.           *
    *                                                              *
    ***************************************************************/
    
    (defun abConvertInstSPICEINvarsToPPar (inst @key updateCDF)
      (let (env cdf cdfParam pat value changed
                (reserved '("acos" "acosh" "asin" "asinh" "atan" "atan2"
                            "atanh" "ceil" "complex" "conjugate" "cos"
                            "cosh" "exp" "fabs" "floor" "hypot" "ln"
                            "log" "log10" "pow" "sin" "sinh" "sqrt" "tan"
                            "tanh"))
                reservedPat unmapReservedPat
                )
        (setq reservedPat (pcreCompile (strcat "(.*)(^|\\W)(" 
                                               (buildString reserved "|")
                                               ")(\\W|$)(.*)")))
        (setq unmapReservedPat (pcreCompile "(.*)_RESERVED(\\w+)(?U)RESERVED_(.*?)"))
        (setq cdf (cdfGetInstCDF inst))
        (foreach prop (dbGetq inst prop)
                 (setq cdfParam (get cdf (dbGetq prop name)))
                 (when (and (equal (dbGetq prop valueType) "string")
                            (or
                              (and
                                cdfParam
                                (getq cdfParam parseAsCEL)
                                (nequal (getq cdfParam editable) "nil")
                                (nequal (dbGetq prop name) "model")
                                )
                              (equal (dbGetq prop name) "m")
                              )
                            )
                   (when (and updateCDF
                              (equal (dbGetq prop name) "m")
                              (null cdfParam))
                     (abConvertSPICEINvarsToPParFixMfactor 
                       (dbGetq (dbGetq inst master) cell))
                     )
                   ;---------------------------------------------------------
                   ; First we have to handle any variables which happen
                   ; to be reserved words (such as "ln"). Map these to
                   ; an unlikely name so that they can be mapped back afterwards
                   ;---------------------------------------------------------
                   (setq value (dbGetq prop value))
                   (while (pcreExecute reservedPat value)
                          (setq value 
                                (pcreSubstitute "\\1\\2_RESERVED\\3RESERVED_\\4\\5"))
                          )
                   ;---------------------------------------------------------
                   ; Compile the expression using AEL - this will collect
                   ; any variables as "deferred globals" - and then
                   ; we can (carefully) substitute these one by one
                   ;---------------------------------------------------------
                   (setq env (aelEnvCreate "f"))
                   (aelEnvCompile env value)
                   (foreach var (aelEnvListDeferredGlobals env)
                            ;------------------------------------------------
                            ; Have to use "[^\\w\"]" in pattern rather than \\W
                            ; because need to not match the variable if surrounded by
                            ; quotation marks (which is what the pPar() will 
                            ; have ended up as)
                            ;------------------------------------------------
                            (setq pat (pcreCompile (strcat "(.*)(^|[^\\w\"])(" var ")([^\\w\"]|$)(.*)")))
                            ;------------------------------------------------
                            ; Has a loop, because there might be multiple occurrences
                            ; of the variable in the expression
                            ;------------------------------------------------
                            (while (pcreExecute pat value)
                                   (setq value (pcreSubstitute "\\1\\2pPar(\"\\3\")\\4\\5"))
                                   )
                            )
                   ;---------------------------------------------------------
                   ; Undo the mapping of reserved words
                   ;---------------------------------------------------------
                   (while (pcreExecute unmapReservedPat value)
                          (setq value 
                                (pcreSubstitute "\\1\\2\\3"))
                          )
                   ;---------------------------------------------------------
                   ; Finally, if it changed, record the change and store the
                   ; value back on the property
                   ;---------------------------------------------------------
                   (unless (equal value (dbGetq prop value))
                     (setq changed t)
                     (dbSetq prop value value)
                     )
                   )
                 )
        changed
        )
      )
    
    /***************************************************************
    *                                                              *
    *      (abConvertSPICEINvarsToPPar cv @key callCallbacks       *
    *         updateCDF @rest argsForInvokeCdfCallbacks)           *
    *                                                              *
    *  Convert the expressions on all instances in the cellView,   *
    *   and optionally call the callbacks. Can also pass in any    *
    *   keyword arguments that abInvokeInstCdfCallbacks accepts,   *
    *                         e.g. ?order.                         *
    *                                                              *
    ***************************************************************/
    
    (defun abConvertSPICEINvarsToPPar (cv @key callCallbacks updateCDF
                                          @rest argsForInvokeCdfCallbacks)
      (let (changed)
        (foreach inst (dbGetq cv instances)
                 (setq changed 
                       (or (abConvertInstSPICEINvarsToPPar 
                             inst ?updateCDF updateCDF)
                           changed))
                 (when callCallbacks
                   (setq changed t)
                   (apply 'abInvokeInstCdfCallbacks inst argsForInvokeCdfCallbacks)
                   )
                 )
        (when changed
          (schCheck cv)
          (dbSave cv)
          (artGenerateHierSymbolCDF cv t nil)
          )
        changed
        )
      )
    
    /******************************************************************
    *                                                                 *
    *             (abConvertSPICEINvarsToPParFixCDF ddId)             *
    *                                                                 *
    *   SPICE IN has an issue where it creates CDF parameters, but    *
    * doesn't set parseAsCEL and parseAsNumber to "yes". That's a bit *
    *  of a problem, so this function goes through and corrects the   *
    *    CDF to set these attributes. It only does this if the CDF    *
    *    exists and is writable (hence the checks for the property    *
    *                              bag)                               *
    *                                                                 *
    ******************************************************************/
    
    (defun abConvertSPICEINvarsToPParFixCDF (ddId)
      (let (bag baseCDF)
        (warn "") (getWarn)
        (setq bag (dbOpenBag ddId))
        (getWarn)
        (when bag
          (if (dbReOpenBag bag "a")
            (progn
              (setq baseCDF (cdfGetBaseCellCDF ddId))
              (when baseCDF
                (foreach param (getq baseCDF parameters)
                         (putpropq param "yes" parseAsNumber)
                         (putpropq param "yes" parseAsCEL)
                         )
                (cdfSaveCDF baseCDF)
                (cdfRefreshCDF baseCDF)
                (dbCloseBag bag)
                )
              )
            (getWarn)
            )
          )
        t
        )
      )
    
    /***************************************************************
    *                                                              *
    *         (abConvertSPICEINvarsToPParFixMfactor ddId)          *
    *                                                              *
    *     If the instance had a parameter "m", and it was not      *
    *        a CDF parameter, create it as a CDF parameter.        *
    *                                                              *
    ***************************************************************/
    
    (defun abConvertSPICEINvarsToPParFixMfactor (ddId)
      (let (bag baseCDF)
        (warn "") (getWarn)
        (setq bag (dbOpenBag ddId))
        (getWarn)
        (when bag
          (if (dbReOpenBag bag "a")
            (progn
              (setq baseCDF (cdfGetBaseCellCDF ddId))
              (when baseCDF
                (cdfCreateParam
                  baseCDF
                  ?name "m"
                  ?type "string"
                  ?defValue "1"
                  ?parseAsNumber "yes"
                  ?parseAsCEL "yes"
                  ?prompt "Multiplier"
                  )
                (cdfSaveCDF baseCDF)
                (dbCloseBag bag)
                )
              )
            (getWarn)
            )
          )
        t
        )
      )
    
    /***************************************************************
    *                                                              *
    *             (abConvertSPICEINvarsToPParForTopLCV             *
    *             @key cv lib cell view callCallbacks              *
    *                           verbose                            *
    *    done cdfDone (switchList (list "schematic" "cmos_sch"))   *
    *               @rest argsForInvokeCdfCallbacks)               *
    *                                                              *
    *      Recursive function which traverses the hierarchy,       *
    *    converting SPICEIN variables to pPars, and optionally     *
    *             calling CDF callbacks as it does so.             *
    *                                                              *
    ***************************************************************/
    
    (defun abConvertSPICEINvarsToPParForTopLCV 
      (@key cv lib cell view callCallbacks updateCDF
            verbose topLib
            done cdfDone (switchList (list "schematic" "cmos_sch"))
            @rest argsForInvokeCdfCallbacks)
      (let (switchMaster lcv lc)
        (unless done 
          (setq done (makeTable 'visited nil)))
        (unless topLib
          (setq topLib lib))
        (unless (dbobjectp cv)
          (setq cv (dbOpenCellViewByType lib cell view "" "a"))
          )
        ;--------------------------------------------------------------------
        ; Now descend into any children recursively
        ;--------------------------------------------------------------------
        (foreach instMaster (dbGetq cv instanceMasters)
                 (setq switchMaster (dbOpenCellViewByType
                                      (dbGetq instMaster libName)
                                      (dbGetq instMaster cellName)
                                      switchList
                                      ""
                                      "a"))
                 (when (and switchMaster (nequal (dbGetq switchMaster mode) "r")
                            (null (arrayref done 
                                            (setq lcv
                                                  (list 
                                                    (dbGetq switchMaster libName)
                                                    (dbGetq switchMaster cellName)
                                                    (dbGetq switchMaster viewName))
                                                  ))))
                   (setarray done lcv t)
                   (when verbose
                     (printf "Updating %s/%s/%s\n" (car lcv) (cadr lcv) (caddr lcv))
                     )
                   (apply 'abConvertSPICEINvarsToPParForTopLCV
                          ?cv switchMaster ?callCallbacks callCallbacks
                          ?updateCDF updateCDF ?done done ?cdfDone cdfDone 
                          ?topLib topLib ?switchList switchList 
                          argsForInvokeCdfCallbacks)
                   (dbClose switchMaster)
                   )
                 )
        ;--------------------------------------------------------------------
        ; Update the CDF for any child masters if not already done
        ;--------------------------------------------------------------------
        (when updateCDF
          (unless cdfDone 
            (setq cdfDone (makeTable 'visited nil)))
          (foreach instMaster (dbGetq cv instanceMasters)
                   (setq lc (list (dbGetq instMaster libName) (dbGetq instMaster cellName)))
                   (unless (or (arrayref cdfDone lc) 
                               (nequal (dbGetq instMaster libName) topLib))
                     (abConvertSPICEINvarsToPParFixCDF 
                       (ddGetObj (dbGetq instMaster libName) (dbGetq instMaster cellName)))
                     (setarray cdfDone lc t)
                     )
                   )
          )
        ;--------------------------------------------------------------------
        ; Update any instances in this cellView
        ;--------------------------------------------------------------------
        (apply 'abConvertSPICEINvarsToPPar cv ?callCallbacks callCallbacks
               ?updateCDF updateCDF argsForInvokeCdfCallbacks)
        t
        )
      )
    

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett over 5 years ago in reply to Skywalker121

    The issue is that SPICEIN doesn't handle parameterised blocks using the ADE/CDF way of parameter passing - it uses the older "NLP" parameter passing. This then doesn't work if you use ADE to netlist instances of the block. Cadence Change Request (CCR) 817161 is asking for this enhancement, but it's not been implemented yet.

    In response to this, I wrote some SKILL code to try to deal with it and convert the passed parameters into pPar expressions instead. I'm not sure how robust this code is, but it's been tried on a  few different examples (by other AEs too). So you might find this useful. It also requires abInvokeCdfCallbacks.il which you can find in this post.

    To use it, see the comments at the top of the code.

    Regards,

    Andrew.

    /* abConvertSPICEINvarsToPPar.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Jul 18, 2013 
    Modified   Jan 31, 2018 
    By         A.D.Beckett
    
    Example of usage:
    
    abConvertSPICEINvarsToPParForTopLCV(
        ?lib "mylib" ?cell "mycell" ?view "schematic" 
        ?updateCDF t ?verbose t ?callCallbacks t 
        ?order list("w" "l")
    )
    
    For a PAS-created PDK (such as gpdk045) you may need to pass some of 
    the additional arguments that abInvokeCdfCallbacks offers (this is
    to use instance CDF rather than effective CDF, and to call the init proc
    to do some initialisation that the callbacks need):
    
    abConvertSPICEINvarsToPParForTopLCV(
        ?lib "mylib" ?cell "mycell" ?view "schematic" 
        ?updateCDF t ?verbose t ?callCallbacks t 
        ?useInstCDF t ?callInitProc t
        ?order list("fw" "l")
    )
    
    Modified to handle AEL reserved words (such as "ln")
    as variable names. Note that the code will not work correctly
    if a variable appears in an expression both as a variable
    and a function - so if you have "ln+ln(2.0)". However,
    this seems an unlikely scenario
    
    Also added a ?updateCDF argument to correct CDF parameters
    created by SPICEIN which don't have parseAsCEL or parseAsNumber
    set. This also takes care of converting m parameters (for m-factor)
    into CDF parameters.
    
    ***************************************************
    
    SCCS Info: @(#) abConvertSPICEINvarsToPPar.il 01/31/18.10:23:13 1.5
    
    */
    
    /***************************************************************
    *                                                              *
    *     (abConvertInstSPICEINvarsToPPar inst @key updateCDF)     *
    *                                                              *
    * Look for variables in CDF parameters, and then convert them  *
    *   into pPar() expressions. This is because SPICE IN leaves   *
    *    parameters in the CDL/SPICE as bare variables - which     *
    *          correspond to design variables, not pPar.           *
    *                                                              *
    ***************************************************************/
    
    (defun abConvertInstSPICEINvarsToPPar (inst @key updateCDF)
      (let (env cdf cdfParam pat value changed
                (reserved '("acos" "acosh" "asin" "asinh" "atan" "atan2"
                            "atanh" "ceil" "complex" "conjugate" "cos"
                            "cosh" "exp" "fabs" "floor" "hypot" "ln"
                            "log" "log10" "pow" "sin" "sinh" "sqrt" "tan"
                            "tanh"))
                reservedPat unmapReservedPat
                )
        (setq reservedPat (pcreCompile (strcat "(.*)(^|\\W)(" 
                                               (buildString reserved "|")
                                               ")(\\W|$)(.*)")))
        (setq unmapReservedPat (pcreCompile "(.*)_RESERVED(\\w+)(?U)RESERVED_(.*?)"))
        (setq cdf (cdfGetInstCDF inst))
        (foreach prop (dbGetq inst prop)
                 (setq cdfParam (get cdf (dbGetq prop name)))
                 (when (and (equal (dbGetq prop valueType) "string")
                            (or
                              (and
                                cdfParam
                                (getq cdfParam parseAsCEL)
                                (nequal (getq cdfParam editable) "nil")
                                (nequal (dbGetq prop name) "model")
                                )
                              (equal (dbGetq prop name) "m")
                              )
                            )
                   (when (and updateCDF
                              (equal (dbGetq prop name) "m")
                              (null cdfParam))
                     (abConvertSPICEINvarsToPParFixMfactor 
                       (dbGetq (dbGetq inst master) cell))
                     )
                   ;---------------------------------------------------------
                   ; First we have to handle any variables which happen
                   ; to be reserved words (such as "ln"). Map these to
                   ; an unlikely name so that they can be mapped back afterwards
                   ;---------------------------------------------------------
                   (setq value (dbGetq prop value))
                   (while (pcreExecute reservedPat value)
                          (setq value 
                                (pcreSubstitute "\\1\\2_RESERVED\\3RESERVED_\\4\\5"))
                          )
                   ;---------------------------------------------------------
                   ; Compile the expression using AEL - this will collect
                   ; any variables as "deferred globals" - and then
                   ; we can (carefully) substitute these one by one
                   ;---------------------------------------------------------
                   (setq env (aelEnvCreate "f"))
                   (aelEnvCompile env value)
                   (foreach var (aelEnvListDeferredGlobals env)
                            ;------------------------------------------------
                            ; Have to use "[^\\w\"]" in pattern rather than \\W
                            ; because need to not match the variable if surrounded by
                            ; quotation marks (which is what the pPar() will 
                            ; have ended up as)
                            ;------------------------------------------------
                            (setq pat (pcreCompile (strcat "(.*)(^|[^\\w\"])(" var ")([^\\w\"]|$)(.*)")))
                            ;------------------------------------------------
                            ; Has a loop, because there might be multiple occurrences
                            ; of the variable in the expression
                            ;------------------------------------------------
                            (while (pcreExecute pat value)
                                   (setq value (pcreSubstitute "\\1\\2pPar(\"\\3\")\\4\\5"))
                                   )
                            )
                   ;---------------------------------------------------------
                   ; Undo the mapping of reserved words
                   ;---------------------------------------------------------
                   (while (pcreExecute unmapReservedPat value)
                          (setq value 
                                (pcreSubstitute "\\1\\2\\3"))
                          )
                   ;---------------------------------------------------------
                   ; Finally, if it changed, record the change and store the
                   ; value back on the property
                   ;---------------------------------------------------------
                   (unless (equal value (dbGetq prop value))
                     (setq changed t)
                     (dbSetq prop value value)
                     )
                   )
                 )
        changed
        )
      )
    
    /***************************************************************
    *                                                              *
    *      (abConvertSPICEINvarsToPPar cv @key callCallbacks       *
    *         updateCDF @rest argsForInvokeCdfCallbacks)           *
    *                                                              *
    *  Convert the expressions on all instances in the cellView,   *
    *   and optionally call the callbacks. Can also pass in any    *
    *   keyword arguments that abInvokeInstCdfCallbacks accepts,   *
    *                         e.g. ?order.                         *
    *                                                              *
    ***************************************************************/
    
    (defun abConvertSPICEINvarsToPPar (cv @key callCallbacks updateCDF
                                          @rest argsForInvokeCdfCallbacks)
      (let (changed)
        (foreach inst (dbGetq cv instances)
                 (setq changed 
                       (or (abConvertInstSPICEINvarsToPPar 
                             inst ?updateCDF updateCDF)
                           changed))
                 (when callCallbacks
                   (setq changed t)
                   (apply 'abInvokeInstCdfCallbacks inst argsForInvokeCdfCallbacks)
                   )
                 )
        (when changed
          (schCheck cv)
          (dbSave cv)
          (artGenerateHierSymbolCDF cv t nil)
          )
        changed
        )
      )
    
    /******************************************************************
    *                                                                 *
    *             (abConvertSPICEINvarsToPParFixCDF ddId)             *
    *                                                                 *
    *   SPICE IN has an issue where it creates CDF parameters, but    *
    * doesn't set parseAsCEL and parseAsNumber to "yes". That's a bit *
    *  of a problem, so this function goes through and corrects the   *
    *    CDF to set these attributes. It only does this if the CDF    *
    *    exists and is writable (hence the checks for the property    *
    *                              bag)                               *
    *                                                                 *
    ******************************************************************/
    
    (defun abConvertSPICEINvarsToPParFixCDF (ddId)
      (let (bag baseCDF)
        (warn "") (getWarn)
        (setq bag (dbOpenBag ddId))
        (getWarn)
        (when bag
          (if (dbReOpenBag bag "a")
            (progn
              (setq baseCDF (cdfGetBaseCellCDF ddId))
              (when baseCDF
                (foreach param (getq baseCDF parameters)
                         (putpropq param "yes" parseAsNumber)
                         (putpropq param "yes" parseAsCEL)
                         )
                (cdfSaveCDF baseCDF)
                (cdfRefreshCDF baseCDF)
                (dbCloseBag bag)
                )
              )
            (getWarn)
            )
          )
        t
        )
      )
    
    /***************************************************************
    *                                                              *
    *         (abConvertSPICEINvarsToPParFixMfactor ddId)          *
    *                                                              *
    *     If the instance had a parameter "m", and it was not      *
    *        a CDF parameter, create it as a CDF parameter.        *
    *                                                              *
    ***************************************************************/
    
    (defun abConvertSPICEINvarsToPParFixMfactor (ddId)
      (let (bag baseCDF)
        (warn "") (getWarn)
        (setq bag (dbOpenBag ddId))
        (getWarn)
        (when bag
          (if (dbReOpenBag bag "a")
            (progn
              (setq baseCDF (cdfGetBaseCellCDF ddId))
              (when baseCDF
                (cdfCreateParam
                  baseCDF
                  ?name "m"
                  ?type "string"
                  ?defValue "1"
                  ?parseAsNumber "yes"
                  ?parseAsCEL "yes"
                  ?prompt "Multiplier"
                  )
                (cdfSaveCDF baseCDF)
                (dbCloseBag bag)
                )
              )
            (getWarn)
            )
          )
        t
        )
      )
    
    /***************************************************************
    *                                                              *
    *             (abConvertSPICEINvarsToPParForTopLCV             *
    *             @key cv lib cell view callCallbacks              *
    *                           verbose                            *
    *    done cdfDone (switchList (list "schematic" "cmos_sch"))   *
    *               @rest argsForInvokeCdfCallbacks)               *
    *                                                              *
    *      Recursive function which traverses the hierarchy,       *
    *    converting SPICEIN variables to pPars, and optionally     *
    *             calling CDF callbacks as it does so.             *
    *                                                              *
    ***************************************************************/
    
    (defun abConvertSPICEINvarsToPParForTopLCV 
      (@key cv lib cell view callCallbacks updateCDF
            verbose topLib
            done cdfDone (switchList (list "schematic" "cmos_sch"))
            @rest argsForInvokeCdfCallbacks)
      (let (switchMaster lcv lc)
        (unless done 
          (setq done (makeTable 'visited nil)))
        (unless topLib
          (setq topLib lib))
        (unless (dbobjectp cv)
          (setq cv (dbOpenCellViewByType lib cell view "" "a"))
          )
        ;--------------------------------------------------------------------
        ; Now descend into any children recursively
        ;--------------------------------------------------------------------
        (foreach instMaster (dbGetq cv instanceMasters)
                 (setq switchMaster (dbOpenCellViewByType
                                      (dbGetq instMaster libName)
                                      (dbGetq instMaster cellName)
                                      switchList
                                      ""
                                      "a"))
                 (when (and switchMaster (nequal (dbGetq switchMaster mode) "r")
                            (null (arrayref done 
                                            (setq lcv
                                                  (list 
                                                    (dbGetq switchMaster libName)
                                                    (dbGetq switchMaster cellName)
                                                    (dbGetq switchMaster viewName))
                                                  ))))
                   (setarray done lcv t)
                   (when verbose
                     (printf "Updating %s/%s/%s\n" (car lcv) (cadr lcv) (caddr lcv))
                     )
                   (apply 'abConvertSPICEINvarsToPParForTopLCV
                          ?cv switchMaster ?callCallbacks callCallbacks
                          ?updateCDF updateCDF ?done done ?cdfDone cdfDone 
                          ?topLib topLib ?switchList switchList 
                          argsForInvokeCdfCallbacks)
                   (dbClose switchMaster)
                   )
                 )
        ;--------------------------------------------------------------------
        ; Update the CDF for any child masters if not already done
        ;--------------------------------------------------------------------
        (when updateCDF
          (unless cdfDone 
            (setq cdfDone (makeTable 'visited nil)))
          (foreach instMaster (dbGetq cv instanceMasters)
                   (setq lc (list (dbGetq instMaster libName) (dbGetq instMaster cellName)))
                   (unless (or (arrayref cdfDone lc) 
                               (nequal (dbGetq instMaster libName) topLib))
                     (abConvertSPICEINvarsToPParFixCDF 
                       (ddGetObj (dbGetq instMaster libName) (dbGetq instMaster cellName)))
                     (setarray cdfDone lc t)
                     )
                   )
          )
        ;--------------------------------------------------------------------
        ; Update any instances in this cellView
        ;--------------------------------------------------------------------
        (apply 'abConvertSPICEINvarsToPPar cv ?callCallbacks callCallbacks
               ?updateCDF updateCDF argsForInvokeCdfCallbacks)
        t
        )
      )
    

    • 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