Connect with us

"Algebraic" IF Statement Evaluation

Discussion in 'Electronic Design' started by Jim Thompson, May 19, 2009.

Scroll to continue with content
  1. Jim Thompson

    Jim Thompson Guest

    I need to evaluate...

    IF(t,1,0) (If t is true, output 1, if t is false, output 0 (numeric),
    t may be something like V11 >= 7, for example)

    BUT I have no IF statement handling capability at this level of a
    simulation.

    I do have algebraic capability.

    Is there some cute way to do this algebraically?

    ...Jim Thompson
    --
    | James E.Thompson, P.E. | mens |
    | Analog Innovations, Inc. | et |
    | Analog/Mixed-Signal ASIC's and Discrete Systems | manus |
    | Phoenix, Arizona 85048 Skype: Contacts Only | |
    | Voice:(480)460-2350 Fax: Available upon request | Brass Rat |
    | E-mail Icon at http://www.analog-innovations.com | 1962 |

    "When the government fears the People, that is Liberty.
    When the People fear the Government, that is Tyranny."
    - attributed to Thomas Jefferson by his contemporaries

    "The Constitution is not an instrument for the government to
    restrain the people, it is an instrument for the people to
    restrain the government -- lest it come to dominate our lives and
    interests." - Patrick Henry
     
  2. Jim Thompson

    Jim Thompson Guest

    I don't have INT available, I do have ABS and some trig functions

    ...Jim Thompson
    --
    | James E.Thompson, P.E. | mens |
    | Analog Innovations, Inc. | et |
    | Analog/Mixed-Signal ASIC's and Discrete Systems | manus |
    | Phoenix, Arizona 85048 Skype: Contacts Only | |
    | Voice:(480)460-2350 Fax: Available upon request | Brass Rat |
    | E-mail Icon at http://www.analog-innovations.com | 1962 |

    Stormy on the East Coast today... due to Bush's failed policies.
     
  3. Jim Thompson

    Jim Thompson Guest

    That's what I came up with, except I inserted a small "delta" (smaller
    than my step size) to avoid 0/0. I was hoping for something more
    compact :-(

    ...Jim Thompson
    --
    | James E.Thompson, P.E. | mens |
    | Analog Innovations, Inc. | et |
    | Analog/Mixed-Signal ASIC's and Discrete Systems | manus |
    | Phoenix, Arizona 85048 Skype: Contacts Only | |
    | Voice:(480)460-2350 Fax: Available upon request | Brass Rat |
    | E-mail Icon at http://www.analog-innovations.com | 1962 |

    Stormy on the East Coast today... due to Bush's failed policies.
     
  4. Jim Thompson

    Jim Thompson Guest

    No :-(

    ...Jim Thompson
    --
    | James E.Thompson, P.E. | mens |
    | Analog Innovations, Inc. | et |
    | Analog/Mixed-Signal ASIC's and Discrete Systems | manus |
    | Phoenix, Arizona 85048 Skype: Contacts Only | |
    | Voice:(480)460-2350 Fax: Available upon request | Brass Rat |
    | E-mail Icon at http://www.analog-innovations.com | 1962 |

    Stormy on the East Coast today... due to Bush's failed policies.
     
  5. Jim Thompson

    Jim Thompson Guest

    I don't have function SGN :-(

    ...Jim Thompson
    --
    | James E.Thompson, P.E. | mens |
    | Analog Innovations, Inc. | et |
    | Analog/Mixed-Signal ASIC's and Discrete Systems | manus |
    | Phoenix, Arizona 85048 Skype: Contacts Only | |
    | Voice:(480)460-2350 Fax: Available upon request | Brass Rat |
    | E-mail Icon at http://www.analog-innovations.com | 1962 |

    Stormy on the East Coast today... due to Bush's failed policies.
     
  6. (1+sgn(V11-7))/2 ?
     

  7. y = V11 -7

    (abs(y) + y)/(2*y)
     
  8. P.S. If you want avoid awkward situations very near y == 0 you could
    do

    (abs(y) + y)/(2* abs(y) + e)

    where e is a very small positive number
     
  9. Jasen Betts

    Jasen Betts Guest

    are there any operators or functions that can give a different
    mumeric result depending on the truth of the input.

    many systems have false as 0 and true as 1 (or less common -1)



    else maybe something like (sgn( sgn(V11-7) *2 +1 ) + 1 ) /2
     
  10. ABS has an intrinsic "if" that can do it. Spehro showed the method.
     
  11. Jim Thompson

    Jim Thompson Guest

    No, Though I'm fascinated. How would use of TANH() work in this
    situation?

    ...Jim Thompson
    --
    | James E.Thompson, P.E. | mens |
    | Analog Innovations, Inc. | et |
    | Analog/Mixed-Signal ASIC's and Discrete Systems | manus |
    | Phoenix, Arizona 85048 Skype: Contacts Only | |
    | Voice:(480)460-2350 Fax: Available upon request | Brass Rat |
    | E-mail Icon at http://www.analog-innovations.com | 1962 |

    Stormy on the East Coast today... due to Bush's failed policies.
     
  12. Jim Thompson

    Jim Thompson Guest

    So the equivalent of "SGN"?

    ...Jim Thompson
    --
    | James E.Thompson, P.E. | mens |
    | Analog Innovations, Inc. | et |
    | Analog/Mixed-Signal ASIC's and Discrete Systems | manus |
    | Phoenix, Arizona 85048 Skype: Contacts Only | |
    | Voice:(480)460-2350 Fax: Available upon request | Brass Rat |
    | E-mail Icon at http://www.analog-innovations.com | 1962 |

    Stormy on the East Coast today... due to Bush's failed policies.
     
  13. oopere

    oopere Guest

    Right, it is a "smooth" sign function. It is sometimes called a soft
    limiter (for instance, in PSpice). From this you can build the smooth
    step...

    Pere
     
  14. Jim Thompson

    Jim Thompson Guest

    Yep. I have that in PSpice itself. I use it in my RealPulse©
    function and in all the OpAmp and Comparator device models.

    What I'm using here is a crude editor with limited functions to do
    model binning based of device dimensions.

    ...Jim Thompson
    --
    | James E.Thompson, P.E. | mens |
    | Analog Innovations, Inc. | et |
    | Analog/Mixed-Signal ASIC's and Discrete Systems | manus |
    | Phoenix, Arizona 85048 Skype: Contacts Only | |
    | Voice:(480)460-2350 Fax: Available upon request | Brass Rat |
    | E-mail Icon at http://www.analog-innovations.com | 1962 |

    Stormy on the East Coast today... due to Bush's failed policies.
     
  15. Use PostScript for your simulation, of course.

    with t on stack, {1}{0} ifelse

    http://www.tinaja.com/post01.asp


    --
    Many thanks,

    Don Lancaster voice phone: (928)428-4073
    Synergetics 3860 West First Street Box 809 Thatcher, AZ 85552
    rss: http://www.tinaja.com/whtnu.xml email:

    Please visit my GURU's LAIR web site at http://www.tinaja.com
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-