• 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. Modulo of a signal? Converting a signal to float?

Stats

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

Modulo of a signal? Converting a signal to float?

Magistus
Magistus over 8 years ago

Hi,

I want to calculate the phase difference between two signals (details are not important). But the expression I created sometimes results in differences greater than 360 degree. Therefore I want to calculate something like

mod(ph_diff, 360).

But mod() doesn’t accept signals I’m afraid. modf() also doesn’t work. I think I have to convert the signal to float first.

Has anyone an idea?

Thank you!
Magistus

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 8 years ago

    This will do it. In IC617 you can easily register this with the calculator by hitting the "Fx" button above the function panel in the calculator to load the file and set up the form - or you can just type it in.

    Regards,

    Andrew

    /* abModulo.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Jul 06, 2005 
    Modified   Nov 23, 2005 
    By         A.D.Beckett
    
    Example use:
    
    plot(abModulo(phaseDegUnwrapped(v("/Pif" ?result "pss_fd"))))
    
    ***************************************************
    
    SCCS Info: @(#) abModulo.il 11/23/05.18:05:09 1.2
    
    */
    
    /***************************************************************
    *                                                              *
    *          (abModulo waveform @optional (modulo 360))          *
    *                                                              *
    *       Take a waveform and return a modulus - strictly        *
    *     positive. Useful for wrapping phase waveforms to be      *
    *               between (say) 0 and 360 degrees.               *
    *                                                              *
    ***************************************************************/
    
    (procedure (abModulo waveform @optional (modulo 360))
      (cond
       ;---------------------------------------------------------------------
       ; Handle ordinary waveform
       ;---------------------------------------------------------------------
       ((drIsWaveform waveform)
        (let (oldyvec newyvec len newwave yval)
             (setq oldyvec (drGetWaveformYVec waveform))
             (setq len (drVectorLength oldyvec))
             (setq newyvec (drCreateVec 'double len))
             ;---------------------------------------------------------------
             ; Iterate over the points, computing the modulus of each point
             ;---------------------------------------------------------------
             (for point 0 (sub1 len)
                  (setq yval (drGetElem oldyvec point))
                  (setq yval 
                        (difference yval 
                                    (times 
                                     (fix (quotient yval modulo))
                                     modulo)))
                  (drSetElem newyvec point yval)
                  )
             ;---------------------------------------------------------------
             ; Set the expression so the name of the waveform is correct
             ;---------------------------------------------------------------
             (putpropq newyvec 
                       (list 'abModulo (getq oldyvec expression) modulo) expression)
             (setq newwave
                   (drCreateWaveform
                    (drGetWaveformXVec waveform)
                    newyvec
                    ))
             ;---------------------------------------------------------------
             ; Inherit the plot style and scale
             ;---------------------------------------------------------------
             (putpropq newwave (getq waveform plotStyle) plotStyle)
             (putpropq newwave (getq waveform plotStyle) xScale)
             newwave
             )
        )
       ;---------------------------------------------------------------------
       ; Family waveforms should be handled OK
       ;---------------------------------------------------------------------
       ((famIsFamily waveform)
        (famMap 'abModulo waveform modulo)
        ) ; family
       ;---------------------------------------------------------------------
       ; And straight numbers
       ;---------------------------------------------------------------------
       ((numberp waveform)
        (difference waveform 
                    (times 
                     (fix (quotient waveform modulo))
                     modulo)))
       (t
        (error "abModulo - can't handle %L\n" waveform)
        )
       )
      )
    
    • Cancel
    • Vote Up +1 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