Skip to content

Commit

Permalink
Initial version.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ken Kundert authored and Ken Kundert committed Jan 27, 2020
0 parents commit 522e4c8
Show file tree
Hide file tree
Showing 12 changed files with 2,672 additions and 0 deletions.
108 changes: 108 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
.*.swp
doc/.build

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

TODO
53 changes: 53 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
Flicker Noise Formulations in Compact Models
============================================

Includes a resistor model that demonstrates how to properly model flicker noise
in Verilog-A as described in "Flicker Noise Formulations in Compact Models", to
be published in Transactions on Computer-Aided Design of Integrated Circuits and
Systems some time in 2020.

Also included are two circuits. The first is a simple test circuit for the
resistor model. The second is a circuit that tests the implementation of flicker
noise in the built-in BSIM4 model.

If you have a recent version of Spectre, you can simulate the circuits directly
and view the results in your favorite waveform viewer.

If you have Python 3.6 or later, you can also run the simulation scripts, which
re-generate the netlists, run the simulation (in Spectre), and plot the results.

To install the script dependencies, from the directory that contains setup.py,
run::

pip3 install --user .

This installs all dependencies into ~/.local/lib. Then simply run::

./runPnoise

or::

./runBSIM

These run a simulation and plot the results. You have the -v option and the
logfile (.runPnoise.log or .runBSIM.log) to help you out if you run into any
problems.

You can also run a simulation of the broken resistor model::

./runPnoise --broken

You can view the signal and waveforms with::

> list-psf -f pnoise.raw/pnoise.pnoise -l
> plot-psf out

My rather old version of Spectre (15.1.0) generated the following results:

Resistor:

.. image:: results/resistor.svg

BSIM:

.. image:: results/bsim.svg
33 changes: 33 additions & 0 deletions broken.va
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Resistor model with both thermal and flicker noise
//
// This model demonstrates the wrong way to model flicker noise. It gives
// correct results in noise analyses but the wrong results in pnoise analyses.
// The issue is described in "Flicker Noise Formulations in Compact Models", to
// be published in Transactions on Computer-Aided Design of Integrated Circuits
// and Systems some time in 2020.
//
// DO NOT USE THIS MODEL.
//
// It is provided only to demonstrate the wrong way to write a flicker noise
// model.

`include "disciplines.vams"
`include "constants.vams"

module res_va(a,b);
inout a, b;
electrical a, b;
parameter real R = 100.0 from (0.0:inf);
parameter real KF = 1.0e-6 from [0.0:inf);
parameter real AF = 2.0 from (0.1:inf);
parameter real EF = 1.0 from (-inf:inf);

analog begin : vaResistor
real Ir, Pn;
Ir = V(a,b)/R;
Pn = KF*pow(abs(Ir), AF);
I(a,b) <+ Ir;
I(a,b) <+ white_noise(4.0*`P_K*$temperature/R, "thermal");
I(a,b) <+ flicker_noise(Pn, EF, "flicker");
end
endmodule
6 changes: 6 additions & 0 deletions clean
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

rm -rf {pnoise,pnbsim}.{ahdlSimDB,raw,log}
rm -rf .{runPnoise,runBSIM}.log
rm -rf .*.Linux-64.dep *.ahdlcmi
rm -rf build dist flicker_noise.egg-info
24 changes: 24 additions & 0 deletions pnbsim.scs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// BSIM flicker noise simulations

simulator lang=spectre

model nchbsim4_f0 bsim4 fnoimod=0 kf=1e-23 af=2
model nchbsim4_f1 bsim4 fnoimod=1

VX (x 0) vsource type=sine dc=1.0 sinedc=0.0 ampl=100mV freq=131.072kHz
ED (d 0 x 0) vcvs gain=1
ES (s 0 x 0) vcvs gain=-1
VG (g 0) vsource dc=3
VB (b 0) vsource dc=-0.2

MBSIM4f0 (d_f0 g s b) nchbsim4_f0 l=1um w=10um
MBSIM4f1 (d_f1 g s b) nchbsim4_f1 l=1um w=10um

iRESf0 (d d_f0) vsource dc=0.0
iRESf1 (d d_f1) vsource dc=0.0
Rout (noise 0) resistor isnoisy=no r=100kOhm
Hnoise (noise 0) pccvs coeffs=[0 1 1] probes=[iRESf0 iRESf1]

noise (noise 0) noise start=4_Hz stop=4.194304MHz dec=2k
pop pss fund=131.072kHz
pnoise (noise 0) pnoise start=4_Hz stop=4.194304MHz dec=2k maxsideband=10
15 changes: 15 additions & 0 deletions pnoise.scs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Resistor flicker noise simulations

simulator lang=spectre

ahdl_include "resistor.va"

model rref resistor kf=1.0e-6 af=2 // to match res_va

Vin (n 0) vsource type=sine dc=1.0 sinedc=0.0 ampl=100mV freq=131.072kHz
R1 (n 0) res_va
R2 (n 0) rref r=100.0

noise noise start=4_Hz stop=4.194304MHz dec=2k oprobe=Vin
pss pss fund=131.072kHz
pnoise pnoise start=4_Hz stop=4.194304MHz dec=2k maxsideband=10 oprobe=Vin
33 changes: 33 additions & 0 deletions resistor.va
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Resistor model with both thermal and flicker noise
//
// This model demonstrates the correct way to model flicker noise. It gives
// correct results in both noise and pnoise analyses as described in "Flicker
// Noise Formulations in Compact Models", to be published in Transactions on
// Computer-Aided Design of Integrated Circuits and Systems some time in 2020.

`include "disciplines.vams"
`include "constants.vams"

module res_va(a,b);
inout a, b;
electrical a, b;
parameter real R = 100.0 from (0.0:inf);
parameter real KF = 1.0e-6 from [0.0:inf);
parameter real AF = 2.0 from (0.1:inf);
parameter real EF = 1.0 from (-inf:inf);

analog function integer sign;
input arg;
real arg;
sign = arg >= 0 ? +1 : -1;
endfunction

analog begin : vaResistor
real Ir, Pn;
Ir = V(a,b)/R;
Pn = KF*pow(abs(Ir), AF);
I(a,b) <+ Ir;
I(a,b) <+ white_noise(4.0*`P_K*$temperature/R, "thermal");
I(a,b) <+ flicker_noise(sign(Ir)*Pn, EF, "flicker");
end
endmodule
Loading

0 comments on commit 522e4c8

Please sign in to comment.