• 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. spectre bsource for current stimuli

Stats

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

spectre bsource for current stimuli

saumyaj
saumyaj over 5 years ago

Hi,

I am a new spectre user. 

I need to implement a current stimuli which starts at a time tstart >0, has a linear rise till a certain time trise until the current reaches a peak Ipeak and then has an exponential fall with time constant taufall.

I understand that I can implement an exponential function : Ixy (x y) bsource I=Ipeak*exp(-($time - trise)/taufall)

But how can join the linear rise part to this? 

This is not a periodic source.

I would also like to add, when I try the similar function with an inhouse SPICE simulator, I have the possibility of using an if else statement in behavioral source, which functions like below :

if time <= trise + tstart, then 

     if time < tstart

       Ixy = 0

    else

     Ixy … defining a pwl function

else

I=Ipeak*exp(-($time - trise)/taufall)

Is something similar possible in spectre?

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 5 years ago

    Yes, this is possible with the "ternary" operator condition?thenExpr:elseExpr which allows you to do this kind of thing in-line. I don't have time right now to put together your example, but it might help if I showed one I created a few years ago. Before spectre supported the edgetype=halfsine option on a vsource (which I requested for a customer), I implemented this using a bsource:

    //
    
    inline subckt sinsq (a b)
    parameters rise=1n fall=1n period=20n width=10n delay=1n v1=1 v2=5 pi=3.1415926535
    sinsq (a b) bsource v=\
    ($time-floor($time/period)*period)<delay?v1:\
    ($time-floor($time/period)*period)<delay+rise?\
    cos((($time-floor($time/period)*period)-delay-rise)*pi/rise)*(v2-v1)/2+(v1+v2)/2:\
    ($time-floor($time/period)*period)<delay+rise+width?v2:\
    ($time-floor($time/period)*period)<delay+rise+width+fall?\
    cos((($time-floor($time/period)*period)-delay-rise-width)*pi/fall)*(v2-v1)/2+(v1+v2)/2:\
    v1
    ends sinsq
    
    v1 (1 0) sinsq rise=2n fall=2n
    
    tran tran stop=40n maxstep=0.01n
    

    The idea is that it's a pulse source with the rise and fall parts replaced with half a sine wave, and so this uses the ternary operators to piece-wise join up the segments of the waveform as needed. I could have just used M_PI instead of defining pi (not sure why I didn't do that). Anyway, hopefully this gives you some idea as to how you could go about it?

    Regards,

    Andrew.

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • saumyaj
    saumyaj over 5 years ago in reply to Andrew Beckett

    Dear Andrew,

    Thank you so much for your reply. I am impressed by your response time. Your solution certainly worked!!

    I used the ternary operators in SPICE, however forgot the keyword "ternary". Thanks a lot once more.

    • 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