• 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. Mixed-Signal Design
  3. How to convert analog value to digital in calculator

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 64
  • Views 18229
  • 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

How to convert analog value to digital in calculator

pyohayo
pyohayo over 6 years ago

Hello,

The expression like this:

value(VT("aaa") 1.0e-6) > 1.0

doesn't work in calculator because return value is either t either nil.

Does exist a function that converts nil to 0 and t to 1 ?

Thanks.

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

    Try:

    if(value(VT("aaa") 1.0e-6) > 1.0 then 1 else 0)

    Regards,

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • pyohayo
    pyohayo over 6 years ago in reply to Andrew Beckett

    Unfortunately doesn't work:

    - Warning -
    <Calculator>
    Evaluation error(ERROR : ("greaterp" 12 t nil ("*Error* greaterp: can't handle (drwave:261157656 > 1.0)"))). Expression: if(value(VT("/I8/osb<7>") 6.5e-05) > 1.0 then 1 else 0)*128

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • pyohayo
    pyohayo over 6 years ago in reply to Andrew Beckett

    Unfortunately doesn't work:

    - Warning -
    <Calculator>
    Evaluation error(ERROR : ("greaterp" 12 t nil ("*Error* greaterp: can't handle (drwave:261157656 > 1.0)"))). Expression: if(value(VT("/I8/osb<7>") 6.5e-05) > 1.0 then 1 else 0)*128

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

    It's getting a waveform (I'm guessing you're doing this on ADE XL/Explorer/Assembler results, or doing a parametric sweep), so you need something more complex. Probably using abApplyToWave found in this post would help. Probably better to use this newer version that can be more easily registered with the calculator.

    You could then do something like:

    abApplyToWave(lambda((val) if(val>1.0 then 1 else 0)) value(VT("aaa") 1.0e-6))

    Note, I didn't test this, but I think that would be OK. Anyway, here's the updated code:

    /* abApplyToWave.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       May 24, 2011 
    Modified   Dec 20, 2017 
    By         A.D.Beckett
    
    Function to apply a unary function to every element
    in a waveform. For example:
    
    abApplyToWave('round waveform)
    
    This can be registered with the calculator using the fx
    button in the Function Panel in IC617 and later. Includes
    the GUI builder template
    
    ***************************************************
    
    SCCS Info: @(#) abApplyToWave.il 12/20/17.14:21:36 1.5
    
    */
    
    /******************************************************************
    *                                                                 *
    *                    (abApplyToWave func arg)                     *
    *                                                                 *
    *  And finally, the function that does the work. You give it the  *
    *  name of a unary function (takes one argument) which works on   *
    * numbers, and then this is applied to all members of a waveform. *
    *                      Handles families too.                      *
    *                                                                 *
    ******************************************************************/
    (defun abApplyToWave (func arg)
      ;----------------------------------------------------------------------
      ; convert string function name to symbol
      ;----------------------------------------------------------------------
      (when (stringp func)
        (setq func (concat func)))
      (cond 
        ((numberp arg) (funcall func arg))
        ((drIsDataVector arg) (vecMap 'abApplyToWave func arg))
        ((drIsWaveform arg) 
         ;-------------------------------------------------------------------
         ; Create new waveform, but transfer units if not set on 
         ; new waveform already. This ensures plotting on the same y-axis
         ;-------------------------------------------------------------------
         (let (new yVec)
           (setq new (wfMap 'abApplyToWave func arg))
           (setq yVec (drGetWaveformYVec new))
           (unless (getq yVec units)
             (putpropq yVec (getq (drGetWaveformYVec arg) units) units)
             )
           new
           )
         )
        ((famIsFamily arg) (famMap 'abApplyToWave func arg))
        (t
          (error "abApplyToWave: can't apply %L to %L\n"
                 func arg)
          )
        )
      )
    
    ;
    ;;;;;;;;;;;;;;;;;;;;;;;;;; GUI builder information ;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ocnmRegGUIBuilder(
     '(nil
      function abApplyToWave
      name abApplyToWave
      description "Apply func to waveform"
      category ("Custom Functions")
      analysis (nil
          general (nil
            args (func arg )
              signals (nil
                    arg (nil
                          prompt "Signal"
                          tooltip "Signal"
                          )
               )
              params(nil
                     func (nil
                           prompt "Function Name"
                           tooltip "Name of function"
                           guiRowHint 0
                           type string
                           default "round"
                           required t
                     )
              )
            inputrange t
          )
      )
      outputs(result)
     )
    )
    

    • 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