The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Apr 30th, 2024, 11:17am
Pages: 1
Send Topic Print
AMS simulator time control misundertanding (Read 20218 times)
Pavel
Senior Member
****
Offline



Posts: 174
Lausanne/Switzerland
AMS simulator time control misundertanding
Nov 02nd, 2006, 1:20am
 
Hello

I have some misunderstanding concerning simulator timestep in transition analysis.
Could you, please, have a glance on two pictures in attachment file - "bad" and "good".

Signal IN is noised signal. Frequency of noise is 10Meg.
In BAD case I set maxstep (AMS Option->Tran Analysis->Convergence/Accuracy) to 1us.
The signal at filter output fltr_out is completely disfigured.
In GOOD case maxstep = 10n.
As you see the form of fltr_out is perfect (at least corresponds to reality).

So in order to have credible results one must know the max frequency in the circuit?
But if this frequency is unknown - some parasitic oscillation or something else, what happens? Simulator will not show it?

Other problem: if the high frequency behaviour occurs only during small part of time simulation, setting
maxstep to some small value (either in AMS option or using $bound_step function in Verilog-A code)
will slow down total simulation time what isn't justified vis-a-vis less "agitated" parts of simulation time.

Is there any "smart" approach?

Thanks in advance.

Best regards.

Pavel
Back to top
 

good_bad.JPG
View Profile   IP Logged
Ken Kundert
Global Moderator
*****
Offline



Posts: 2384
Silicon Valley
Re: AMS simulator time control misundertanding
Reply #1 - Nov 2nd, 2006, 8:53pm
 
If you have a high frequency stimulus it is possible for the simulator to completely miss it because of aliasing. When I was developing Spectre this happened in the first transient analysis I ran. The source produced a 1MHz sinewave, the simulation interval was 100 μs, and Spectre started by taking a step 1% of the simulation interval. In doing so it happened to sample the signal at its zero point after the first period, so it did not sense any change in the circuit, so it continued taking the same step, each time seeing no activity. The computed result was a flat line. I hunted around for quite a while before I realized what the problem was. When I found it I added the bound_step feature. The sine source uses it to tell kernel not to take a time step larger than a quarter period of the sinusoid. In this way the simulator is guaranteed to notice the input signal. It can then use its normal timestep control to get an accurate answer.

So, if you build a Verilog-A model that is time varying (like all sources are) you must be aware of this issue. This is particularly true with time variations that are smooth (as a sinusoid is). It is discussed on page 77 of my Verilog-AMS book. To solve this problem you use the $bound_step function in the source. The bound itself can vary with time, which helps if the source turns off or changes frequency.

-Ken
Back to top
 
 
View Profile WWW   IP Logged
Pavel
Senior Member
****
Offline



Posts: 174
Lausanne/Switzerland
Re: AMS simulator time control misundertanding
Reply #2 - Nov 3rd, 2006, 1:22am
 
Thank you for answer Ken

Quote:
When I found it I added the bound_step feature. The sine source uses it to tell kernel not to take a time step larger than a quarter period of the sinusoid. In this way the simulator is guaranteed to notice the input signal. It can then use its normal timestep control to get an accurate answer.


So at start I shold fix maxtime at some small value for "right departure" of simulator and then, after some time (some nanoseconds) I can relax or even disable $bound_step function.
Or maybe like this
analog begin
@(initial_stop) $bound_step(1n);

What I can't understand, basically circuits simulators must adapt theirs step time dynamically. I thought that the profit of maxtime is to embellish signal form (that nevertheless should be recognized).

If apriori I don't know the maxstep, how should I proceed?
If some time after start, an amplifier gets down to oscillatation with frequency superior to its input frequency... Simulator won't show it?

Best regards.

Pavel
Back to top
 
 
View Profile   IP Logged
Ken Kundert
Global Moderator
*****
Offline



Posts: 2384
Silicon Valley
Re: AMS simulator time control misundertanding
Reply #3 - Nov 3rd, 2006, 8:08am
 
bound_step() is not like maxstep. maxstep bounds all time steps, bound_step() only bounds the current step. So if you used
@(initial_step) $bound_step(1n);
you would only be placing a bound on the first time step.

-Ken
Back to top
 
 
View Profile WWW   IP Logged
Pavel
Senior Member
****
Offline



Posts: 174
Lausanne/Switzerland
Re: AMS simulator time control misundertanding
Reply #4 - Nov 6th, 2006, 12:08am
 
If I understood the things in rigtht way, Spectre cannot adapt its timestep dynamically, and it always need initial suggestion,
otherwise it can miss some high-frequency behaviour.

Regards.

Pavel.
Back to top
 
 
View Profile   IP Logged
Ken Kundert
Global Moderator
*****
Offline



Posts: 2384
Silicon Valley
Re: AMS simulator time control misundertanding
Reply #5 - Nov 6th, 2006, 12:47am
 
No. Spectre, along with all Spice-like simulators, dynamically adapt their time step to the activity currently present in the circuit. But if you write a behavioral model that acts like a high frequency source you need to bound the timestep. If you don't, aliasing can occur that is not detectable by Spectre, or by any simulator. You don't have to "control" the timestep for Spectre. For example, to get a good result, you typically need at least 10-20 timepoints per cycle of an input sinusoid. However, you don't need to bound the step to 0.1T or 0.05T. It is sufficient to bound the step to 0.3T. With that bound it is not possible to undersample the waveform and produce a constant-valued waveform. Rather, the waveform will vary on a per step basis, and then the simulator will observe the variation and then shrink the step automatically to render the waveform accurately.

-Ken
Back to top
 
 
View Profile WWW   IP Logged
ywguo
Community Fellow
*****
Offline



Posts: 943
Shanghai, PRC
Re: AMS simulator time control misundertanding
Reply #6 - Nov 1st, 2009, 7:42pm
 
Hi,

I simulated a verilog-A model of sigma-delta data converter with very slow clock, say 100 kHz. The rise time and fall time for the clock are specified to be 1ns.

If set maxstep = 1ns, the simulator goes very slowly. If NOT, the simulator goes very fast but the result is obviously wrong.  Please look at the picture below, which is plotted with wavescan. Now the fall time is about 1.6us.

How do I make the simulation fast and accurate? Thanks.

Best Regards,
Yawei

Back to top
 

Verilog-A_transient_simulation.PNG
View Profile   IP Logged
rajdeep
Senior Member
****
Offline



Posts: 220
UK
Re: AMS simulator time control misundertanding
Reply #7 - Nov 2nd, 2009, 1:33am
 
Did you use a cross statement on the clock input in your sigma-delta Verilog-A code to detect the clock edge?

Rajdeep
Back to top
 
 

Design is fun, verification is a requirement.
View Profile   IP Logged
Ken Kundert
Global Moderator
*****
Offline



Posts: 2384
Silicon Valley
Re: AMS simulator time control misundertanding
Reply #8 - Nov 2nd, 2009, 12:23pm
 
Using maxstep to control simulation error is almost always the wrong thing to do because it slows the simulator unnecessarily. Using maxstep is like using a hammer, while it make work, you might not like the outcome. Instead, you need to take the time to understand the situation and then use the right tool. Your choice of tools are things like cross, transition, bound_step. Which is right depends on what you are trying to do, and cannot be discerned from a waveform.

I recommend that you try to understand what is going wrong and then try to figure out which of these tools can solve the problem with the least possible overhead. If you need help, be sure to describe what you are trying to model, give the code that is not working for you, and then describe the behavior you are trying to avoid. If you ask a vague question, you will get vague answers (if you get any answers at all).

Also, when presenting a new problem, you should start a new topic rather than appending to someone else's topic, even though they may be related.

-Ken
Back to top
 
 
View Profile WWW   IP Logged
ywguo
Community Fellow
*****
Offline



Posts: 943
Shanghai, PRC
Re: AMS simulator time control misundertanding
Reply #9 - Nov 10th, 2009, 8:02pm
 
Hi Ken,

Thank you very much for so much good advices.  

This is a sigma-delta modulator. The opamps, switches, and all logic gates are written in Verilog-A language. They are the cells in ahdlLib or bmslib. I want to set up a testbench using those cells to reduce the simulation time at the initial stage of the design.

Part of the circuit is shown below. For example, an ideal pulse voltage source is fed to the input of a xor/xnor gate. Other pulse sources go to corresponding logic gates like NAND and NOR. One part of its verilog-A code for xor/xnor gate is listed here.

Code:
	@ (cross(V(vin1) - vtrans, 1))  logic1 = 1;
	@ (cross(V(vin1) - vtrans, -1)) logic1 = 0;

	@ (cross(V(vin2) - vtrans, 1))  logic2 = 1;
	@ (cross(V(vin2) - vtrans, -1)) logic2 = 0; 



I belived the cross function must affect the time step. But it obviously failed.

I tried two spectre versions. One is spectre of sub-version  7.1.1.187.isr11.  The other is spectre of sub-version 5.10.41_USR6.081308.


Best Regards,
Yawei
Back to top
 

picture1.PNG
View Profile   IP Logged
sheldon
Community Fellow
*****
Offline



Posts: 751

Re: AMS simulator time control misundertanding
Reply #10 - Nov 14th, 2009, 1:00am
 
Yawei,

  You might want to try using the optional arguments of the
cross function, time tolerance and expression tolerance.
These can be used to control the accuracy of the decision.
If memory serves, you can see examples of these functions
in the bmslib logic library.

     @ (cross(V(vin2) - vtrans, -1, 10p, 100u )) logic2 = 0;


                                                        Best Regards,

                                                           Sheldon
Back to top
 
 
View Profile   IP Logged
ywguo
Community Fellow
*****
Offline



Posts: 943
Shanghai, PRC
Re: AMS simulator time control misundertanding
Reply #11 - Nov 17th, 2009, 12:29am
 
Sheldon,

Thank you. That's what I need.

Yawei
Back to top
 
 
View Profile   IP Logged
rajdeep
Senior Member
****
Offline



Posts: 220
UK
Re: AMS simulator time control misundertanding
Reply #12 - Nov 17th, 2009, 6:25am
 
Hi!

I was off for a week almost!!

Yes the tolerance really helps!! But it is funny that depending on the situation i,e. what is the overall design sometimes I need it, sometimes I can safely omit it!! To make it general, I usually keep it. And the irony is that bigger the whole design gets I find explicit tolerance declaration more important, and that is when (bigger design) I look for simulation speed up with the models :-D

Just wanted to share!!

cheers!
Rajdeep
Back to top
 
 

Design is fun, verification is a requirement.
View Profile   IP Logged
ywguo
Community Fellow
*****
Offline



Posts: 943
Shanghai, PRC
Re: AMS simulator time control misundertanding
Reply #13 - Nov 22nd, 2009, 7:00am
 
Hi Rajdeep,

You are right. The bigger the design is the explicit tolerance declaration becomes more important. I don't know the reason. But it seems true in my simulations.

Another point is that the longer stop time is for tran analysis, the explicit tolerance declaration becomes more important.


Yawei
Back to top
 
 
View Profile   IP Logged
rajdeep
Senior Member
****
Offline



Posts: 220
UK
Re: AMS simulator time control misundertanding
Reply #14 - Nov 23rd, 2009, 1:42am
 
Hi  Yawei,

I once tried to read about circuit simulators from a book written by Pillage. It was really interesting, and was written in a lucid way without 'troubling' us (the poor users) with too much of integration signs  :-D

And there, I read about how numerical circuit simulators fix up time steps, and came across few terms like stiff circuit.....what was the other one... Undecided It is like a design with different time constants, and the differene between time constants is quite large. You can imagine in a bigger design such possibilty is higher, and thus makes the simulators time step determination method more complex. It also depends on the total simulation time, as you have also observed!

Since I dont remember anything I should stop right here, but can suggest you to read this book  
Electronic Circuit & System Simulation Methods by L.E. Pillage. It is easy to read. Unfortunately I dont have that book with me any more (I borrowed it from my frnd back in uni), otherwise I wud have gone thru that portion again and wud have loved to answer your questions!!

Thanks!
Rajdeep
Back to top
 
 

Design is fun, verification is a requirement.
View Profile   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.