run an optimization procedure and define the constraints
ASCO can of course be used with a proper interface to the circuit simulator. If your simulator supports Monte Carlo, you can also do it inside that environment, by defining the variables as random variables within the constraints above. Sometimes, quite interesting configurations can pop out.
See Circuit optimization with ngspice
Why do you suggest Monte Carlo ? Is it a separate optimization method since I notice that ASCO is using differential evolution algorithm ?
* Effecting a Monte Carlo calculation in ngspice
V1 N001 0 AC 1 DC 0
R1 N002 N001 141
*
C1 OUT 0 1e-09
L1 OUT 0 10e-06
C2 N002 0 1e-09
L2 N002 0 10e-06
L3 N003 N002 40e-06
C3 OUT N003 250e-12
*
R2 0 OUT 141
.control
let mc_runs = 5
let run = 0
set curplot=new $ create a new plot
set scratch=$curplot $ store its name to 'scratch'
setplot $scratch $ make 'scratch' the active plot
let bwh=unitvec(mc_runs) $ create a vector in plot 'scratch' to store bandwidth data
* define distributions for random numbers:
* unif: uniform distribution, deviation relativ to nominal value
* aunif: uniform distribution, deviation absolut
* gauss: Gaussian distribution, deviation relativ to nominal value
* agauss: Gaussian distribution, deviation absolut
* limit: if unif. distributed value >=0 then add +avar to nom, else -avar
define unif(nom, rvar) (nom + (nom*rvar) * sunif(0))
define aunif(nom, avar) (nom + avar * sunif(0))
define gauss(nom, rvar, sig) (nom + (nom*rvar)/sig * sgauss(0))
define agauss(nom, avar, sig) (nom + avar/sig * sgauss(0))
* define limit(nom, avar) (nom + ((sgauss(0) ge 0) ? avar : -avar))
define limit(nom, avar) (nom + ((sgauss(0) >= 0) ? avar : -avar))
*
*
dowhile run < mc_runs $ loop starts here
*
* alter c1 = unif(1e-09, 0.1)
* alter c1 = aunif(1e-09, 100e-12)
* alter c1 = gauss(1e-09, 0.1, 3)
* alter c1 = agauss(1e-09, 100e-12, 3)
*
alter c1 = unif(1e-09, 0.1)
alter l1 = unif(10e-06, 0.1)
alter c2 = unif(1e-09, 0.1)
alter l2 = unif(10e-06, 0.1)
alter l3 = unif(40e-06, 0.1)
alter c3 = limit(250e-12, 25e-12)
*
ac oct 100 250K 10Meg
*
* measure bandwidth at -10 dB
meas ac bw trig vdb(out) val=-10 rise=1 targ vdb(out) val=-10 fall=1
*
set run ="$&run" $ create a variable from the vector
set dt = $curplot $ store the current plot to dt
setplot $scratch $ make 'scratch' the active plot
let vout{$run}={$dt}.v(out) $ store the output vector to plot 'scratch'
let bwh[run]={$dt}.bw $ store bw to vector bwh in plot 'scratch'
setplot $dt $ go back to the previous plot
let run = run + 1
end $ loop ends here
*
plot db({$scratch}.allv)
echo
print {$scratch}.bwh
.endc
.end
R1 N002 N001 141
R2 0 OUT 141
0 < Rx < Rmax (some MOhm, perhaps)
its DC level could also be a free parameter that you optimize
feedback in one of the branches (asymmetric)
.PARAM TMEAS_START = '(NO_PERIODS-1)*INP_PERIOD'
.PARAM TMEAS_STOP = '(NO_PERIODS)*INP_PERIOD'
.PARAM TMEAS_1 = 'TMEAS_STOP -3*INP_PERIOD/4'
.PARAM TMEAS_2 = 'TMEAS_STOP -1*INP_PERIOD/4'
*Digital inverter
.PARAM V_SUPPLY = '#V_SUPPLY#'
.PARAM INP_FREQ = '#INP_FREQ#'
.PARAM INP_PERIOD = '1/INP_FREQ'
.PARAM NO_PERIODS = '4'
.PARAM TMEAS_START = '(NO_PERIODS-1)*INP_PERIOD'
.PARAM TMEAS_STOP = '(NO_PERIODS)*INP_PERIOD'
.PARAM TMEAS_1 = 'TMEAS_STOP -3*INP_PERIOD/4'
.PARAM TMEAS_2 = 'TMEAS_STOP -1*INP_PERIOD/4'
*** *** SUPPLY VOLTAGES *** ***
VDD VDD 0 {V_SUPPLY}
VSS VSS 0 0
*** *** INPUT SIGNAL *** ***
VSIG IN VSS PULSE {V_SUPPLY} 0 'INP_PERIOD/2' 'INP_PERIOD/1000'
+ 'INP_PERIOD/1000' 'INP_PERIOD/2' 'INP_PERIOD'
*** *** ROUT TEST CIRCUIT *** ***
MP OUT IN VDD VDD P1 W='#WP#' L=#LMIN#
MN OUT IN VSS VSS N1 W='#WP#/2' L=#LMIN#
CL OUT VSS 3p
*** *** ANALYSIS *** ***
.TRAN 'INP_PERIOD/1000' 'NO_PERIODS*INP_PERIOD'
*
*.PROBE TRAN V(IN)
*.PROBE TRAN V(OUT)
.OPTION POST PROBE ACCURATE
.include modelcard.nmos
.include modelcard.pmos
.END
*CMOS inverter
.PARAM V_SUPPLY = '#V_SUPPLY#'
.PARAM V_OUT = '#V_OUT#'
.PARAM INP_FREQ = '#INP_FREQ#'
.PARAM INP_PERIOD = '1/INP_FREQ'
.PARAM AC_POINTS = 10000
.PARAM AC_START = 10
.PARAM AC_STOP = 1000000
*** *** SUPPLY VOLTAGES *** ***
VDD VDD 0 {V_SUPPLY}
VSS VSS 0 0
*** *** INPUT SIGNAL *** ***
VSIG IN VSS VSS
*** *** CIRCUIT UNDER TEST *** ***
MP OUT IN VDD VDD P1 W='#WP#' L=#LMIN#
MN OUT IN VSS VSS N1 W='#WP#/2' L=#LMIN#
CL OUT VSS 3p
*** *** ROUT TEST SIGNAL *** ***
VOUT VOUT '#V_OUT#' VSS
IOUT OUT VOUT 1A
*** *** ANALYSIS *** ***
.AC dec 'AC_POINTS' 'AC_START' 'AC_STOP'
*
*.PROBE TRAN V(IN)
*.PROBE TRAN V(OUT)
.OPTION POST PROBE ACCURATE
.include modelcard.nmos
.include modelcard.pmos
.END
#Optimization Flow#
Alter:yes $do we want to do corner analysis?
MonteCarlo:no $do we want to do MonteCarlo analysis?
AlterMC cost:3.00 $point at which we want to start ALTER and/or MONTECARLO
ExecuteRF:no $execute or not the RF module to add RF parasitics?
SomethingElse: $
#
#DE#
choice of method:3
maximum no. of iterations:50
Output refresh cycle:2
No. of parents NP:10
Constant F:0.5
Crossover factor CR:1
Seed for pseudo random number generator:3
Minimum Cost Variance:1e-6
Cost objectives:10
Cost constraints:10000
#
# ALTER #
.control
alter vdd=[2.0 2.1 2.2]
run
.endc
*.protect
*.inc [../models/cmos035_slow.mod ../models/cmos035_typ.mod ../models/cmos035_fast.mod]
*.unprotect
*.temp [-40 +25 +85]
*.param
*+ V_SUPPLY=[2.0 2.1 2.2]
*.protect $ As much as 6 variables can be swept at the same time.
*.lib hl49ciat57k5r200.mod [mos_wcs mos_nom mos_bcs] $ Format is [a] or [a b] or ... [a b c d e f] =>1 space
*.unprotect $ and not :[ a], [a ], [ a ] => space is not really necessary
*.temp [-40 +25 +85] $ and not :[a b] => only 1 ' ' between 'a' and 'b'
*.param $ Add '*' to skip a line
*+ vddd=[2.25 2.50 3.30] $
*+ kc=[0.95 1.05]:LIN:10 $ LIN not yet implemented
*+ kr=[0.87 1.13]:LOG:10 $ LOG not yet implemented
*+ Ierror=[0.7 1.3]
*+ k00=[0 1]
*+ k01=[0 1]
*+ k02=[0 1]
*+ k03=[0 1]
*+ k04=[0 1]
*+ k05=[0 1]
*+ k06=[0 1]
*+ k07=[0 1]
*+ k08=[0 1]
*+ k09=[0 1]
#
#Monte Carlo#
NMOS_AVT:12.4mV $ This values will be divided by sqrt(2) by the program
NMOS_ABETA:7.3% $ 'm' parameter is taken into account
PMOS_AVT:10.9mV $
PMOS_ABETA:3.7% $
SMALL_LENGTH:0.0u $ Small transistors if l<= SMALL_LENGTH
SMALL_NMOS_AVT:20mV $ Small transistors parameters
SMALL_NMOS_ABETA:10% $
SMALL_PMOS_AVT:10mV $
SMALL_PMOS_ABETA:5% $
R_DELTA:0.333% $ Resistors matching at 1 sigma between two resistors
L_DELTA:0.333% $ Inductors matching at 1 sigma between two inductors
C_DELTA:0.333% $ Capacitors matching at 1 sigma between two capacitors
#
# Parameters #
Supply voltage:#V_SUPPLY#:2.0:0:0:LIN_DOUBLE:---
Temperature:#TEMP#:25:0:0:LIN_DOUBLE:---
Minimal gate length:#LMIN#:0.35u:0:0:LIN_DOUBLE:---
Input frequency:#INP_FREQ#:850E6:0:0:LIN_DOUBLE:---
PMOS width:#WP#:10000u:1m:10m:LIN_DOUBLE:OPT
Output voltage:#V_OUT#:1:1:5:LIN_DOUBLE:OPT
#
# Measurements #
#P_SUPPLY:---:MIN:0
#VHIGH:OUT:GE:1.95
#VLOW:OUT:LE:0.05
ROUT:OUT:GE:1000
#
# Post Processing #
#
#this is the last line
*CMOS inverter
.PARAM V_SUPPLY = '#V_SUPPLY#'
.PARAM V_OUT = '#V_OUT#'
.PARAM INP_FREQ = '#INP_FREQ#'
.PARAM INP_PERIOD = '1/INP_FREQ'
.PARAM NO_PERIODS = '4'
.PARAM TMEAS_START = '(NO_PERIODS-1)*INP_PERIOD'
.PARAM TMEAS_STOP = '(NO_PERIODS)*INP_PERIOD'
.PARAM AC_POINTS = 10000
.PARAM AC_START = 10
.PARAM AC_STOP = 1000000
*** *** SUPPLY VOLTAGES *** ***
VDD VDD 0 {V_SUPPLY}
VSS VSS 0 0
*** *** INPUT SIGNAL *** ***
VSIG IN VSS VSS
*** *** CIRCUIT UNDER TEST *** ***
MP OUT IN VDD VDD P1 W='#WP#' L=#LMIN#
MN OUT IN VSS VSS N1 W='#WP#/2' L=#LMIN#
Lf OUT IN 0.01
** The input can be either biased with a DC source, or a DC feedback circuit. Using a DC feedback circuit (RC, inductor, whatsoever) makes only sense if there's no DC voltage source, see https://www.edaboard.com/showthread.php?377214-Noise-in-CMOS-Inverter&p=1617292&viewfull=1#post1617292
*** *** ROUT TEST SIGNAL WITH FIXED 1A CURRENT AND VARIABLE TEST VOLTAGE (VOUT) *** ***
VOUT OUT '#V_OUT#' VSS
IOUT OUT VOUT 1
*** *** ANALYSIS *** ***
.AC dec 'AC_POINTS' 'AC_START' 'AC_STOP'
*
*.PROBE TRAN V(IN)
*.PROBE TRAN V(OUT)
.OPTION POST PROBE ACCURATE
.include modelcard.nmos
.include modelcard.pmos
.END
# Info #
Name:ROUT
Symbol:Z_ROUT
Unit:Ω
Analysis type:AC
Definition:Output Impedance
Note:
#
# Commands #
.measure ac #SYMBOL# par('VOUT/1')
#
[phung@archlinux inv]$ ls -al
total 112
drwxr-xr-x 3 phung phung 4096 Jun 23 15:33 .
drwxr-xr-x 4 phung phung 4096 Jun 15 00:41 ..
-rw-r--r-- 1 phung phung 56287 Jun 23 15:34 archlinux.log
-rw-r--r-- 1 phung phung 269 Jun 23 15:34 archlinux.out
-rw-r--r-- 1 phung phung 796 Jun 23 15:34 archlinux.sp
-rw-r--r-- 1 phung phung 861 Jun 23 15:34 archlinux.tmp
-rw-r--r-- 1 phung phung 285 Jun 23 15:34 asco.log
drwxr-xr-x 2 phung phung 4096 Jun 23 15:30 extract
-rw-r--r-- 1 phung phung 2822 Jun 23 15:32 inv.cfg
-rw-r--r-- 1 phung phung 292 May 2 00:21 inv.net
-rw-r--r-- 1 phung phung 1185 Jun 23 15:33 inv.sp
-rw-r--r-- 1 phung phung 6528 Feb 16 2017 modelcard.nmos
-rw-r--r-- 1 phung phung 6530 Feb 16 2017 modelcard.pmos
[phung@archlinux inv]$
[phung@archlinux inv]$ asco -ngspice inv.sp
ASCO-0.4.10 - Copyright (c) 1999-2016 Joao Ramos
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
INFO: ngspice initialization on 'archlinux'
INFO: Initialization has finished without errors on 'archlinux'
INFO: Current directory on 'archlinux': /home/phung/Documents/Grive/Personal/Analog/Active_Inductor/frequency_trap/optimization/inv
PRESS CTRL-C TO ABORT
INFO: Starting global optimizer on 'archlinux'...
INFO: errfunc.c - CostFunction -- Cost is very close to zero. This can either be (a) due to an error or because (b) there is not an objective in category # Measurements # in the *.cfg file.
INFO: errfunc.c - Step7 -- altermc=2
INFO: errfunc.c - CostFunction -- Cost is very close to zero. This can either be (a) due to an error or because (b) there is not an objective in category # Measurements # in the *.cfg file.
INFO: de36.c - Ctrl-C key pressed.
INFO: Ending optimization
INFO: Starting local optimizer on 'archlinux'...
INFO: ASCO has ended on 'archlinux'.
[phung@archlinux inv]$
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?