<@U01819B63HP> could you please share a testbench ...
# xschem
j
@Stefan Schippers could you please share a testbench for Monte Carlo and offset voltage calculation for an OTA? I've tried multiple approaches but haven't had much success. Thanks
s
The attached testbench does a 200run montecarlo sim and shows the differential input at the OTA.
j
Thank you very much
s
Following example does a 1000 run and also plots the distribution
message has been deleted
PS: the 'freq' x-label of the distribution is wrong. a copy paste from another example. Should be Vdiff or something similar.
j
Can you please also add the mean and variance since I need to plot the distribution
s
following example shows mean and root mean square of the diferential input.
message has been deleted
j
Thank you very much @Stefan Schippers 🙏🏻
s
the values are calculated by processing the raw data , check the attributes of the "load waves" launcher, there is some embedded TCL code that calculates mean and variance.
d
Attached is how I do it. In the github link I give there is an octave script which can be used to output mean and stdevs.
@Stefan Schippers: Your histogram code is exactly what I am looking for right now! I want to do a histogram plot of a transient noise sim to determine noise power (see attached screenshot). I was planning to read it into octave and do it there but the raw data requires a bit of post processing before I can do this so it is much easier to do plot the histogram in xschem. When I open your example as an .sch file I get a lot of flashing symbols and im not sure the tcl script for "distrib" loads in since it says "google" in mine (see attached). I have attached the .sch file I am using. From that would you be able to get me started on this as its not immedietly obvious to me. Much appreciated! Thanks
s
@Diarmuid Collins Thanks to your example I fixed a bug in xschem. The
xschem raw values
command that extract values from a loaded raw file was rounding each value to 8 significant digits. For noise simulations this is undesirable, so now the command returns the full precision values as they are stored. Following that I have changed your example (attached here) to show the correct distribution and also calculate rms and mean. The plots are around the 0.9V center value for better readablity (better to read '10n instead of 0.90000001)
j
@Stefan Schippers is there a way to check which device contributed how much in the random mismatch, If so can you please provide a testbench
s
@Jnanapurushothama it is not clear to me how resistors generate noise. In @Diarmuid Collins example the only one device generating noise is the TRNOISE voltage source. the vout node (that does not have such source) is without any noise, despite the
noisy=1
parameter on resistors. There should be a sqrt(4kTRB) (B=bandwidth, R=total resistance) rms noise due to the resistors, according to ngspice manual and physics.
j
No, In my ota mismatch I wanted to know which devices are contributing how much to the total offset or mismatch, This is present in Cadence tools. I wanted to check this in xschem for better analysis
s
@Jnanapurushothama Cadence uses Spectre or some other proprietary simulator that have a specific .MC or similar command. These commands do a complete montecarlo analysis, create the histogram and also breakdown the total variation by the contributions of the various devices in the circuit. This is usually achieved by running a dc sensitivity analysis and applying the calculated sensitivity together with the variation parameter of each device in the circuit to see the effect on the output mismatch. This process is not automated in ngspice, so you have to write your own control file. See sens analysis in the ngspice user manual: 13.5.72 Sens: Run a sensitivity analysis
@Diarmuid Collins udated circuit with more general get_histo procedure (you might copy/paste the procedure and use for other examples).
d
@Stefan Schippers Wow ... this looks amazing!!! I had got my octave post processing script to work but having xschem report it like shown is so much more efficient and elegant. Thanks very much for that. I will run the example in the next day or two, cross-check with my octave script, and then get back to you. Cheers
s
For complex data analysis Octave is certainly more powerful, 🙂
d
@Stefan Schippers: I have run a kT/C example with the following numbers: R = 5k, C = 1p => ENBW = 500MHz, fmin = 100kHz, fmax = 500MHz => vnrms = 64.4uVrms. xschem and my octave script give identical results (see attached) which correlate well with the expected 64uVrms number. However, I cant get the histogram to plot (see attached). It should appear like the histogram in my octave script with limits = +/- 200uV. Attached is the .sch file. Do you see anything obvious as I didnt alter the .tcl scripts or change net names? Thanks.
s
@Diarmuid Collins can you test the attached one (i renamed it with _stef). For some reason in my ngspice all component values that are parameters need to be in single quotes (like '`xRvar'` instead of
xRvar
). I think this will be fine with your ngspice as well (it is recommended in the manual). the "Load waves" launcher does the mean/rms calculation as well as building the histogram. The
get_histo
procedure accepts 5 parameters:
node_name, mean_value, min_value, max_value, step_size
. the
step_size
determines the number of categories in the histogram. This value must be reasonable with the data sample. (too many categories with a limited sample size will not produce a gaussian shape). The
xschem raw switch 0
instruction at the beginning of the
get_histo
procedure "switches" the current raw file to the first one that was loaded, that is
tran.raw
. This is needed so following
xschem raw values
instructions will pick data from the right simulation (there is a tran.raw loaded in memory and a noise_density.raw). The procedure creates a new raw file in memory called "distrib" with sim type "distrib" (the names are arbitrary, a single raw file usually is a container for multiple sim types). the sweep variable for this "distrib" plot are the vout3-mean values, while the y- values are the frequencies (how many samples fall within the quantized category). The graph is shown rotated, that is sweep variable on y axis and values on x axis, so the y values for "tran" and "distrib" are aligned. since it is rotated the graph "`Mode`" is
HistoH
.
message has been deleted
message has been deleted
d
@Stefan Schippers: Looks like an early Christmas present for me! Works perfect on v3.4.6. Thanks for the help with this. Much appreciated!
oops, pic doesnt show mean
j
@Diarmuid Collins can you pls share the testbench where you calculated the standard deviation
d
@Jnanapurushothama tb is checked into: https://github.com/SLICESemiconductor/OpenSourceTool_Examples/tree/main/Running_transient_noise_in_ngspice Let me know if you cant see it. It is public but others cant see it so most probably you cant. No idea why so am looking into it.
j
Its not accessible
d
@Jnanapurushothama thanks for the feedback. I'll look into this and reply when I get it sorted out.
@Stefan Schippers I am running the histogram plots on a new tb (resistor loaded PMOS) using the above method. The resulting rms value is in line with expectations, however as shown below, the histogram doesnt seem to plot. I've replicated the previous setup but seems I am missing something. Attached is my .sch file if you could take a quick look. Thanks.
@Stefan Schippers Please ignore. The issue was I just hadnt the correct limits / step size set. All working now as shown below.