Difference between revisions of "Code Models"
(Imported from TWiki) |
m (Move page script moved page CodeModels to gEDA netlisting for NGspice Code Models: Rename from TWiki to MediaWiki style) |
Latest revision as of 23:07, 22 October 2018
I came up with a little patch against the current gEDA cvs that allows for a custom format string in the spice-sdb backend for the gEDA gnetlist util. This allows you to seamlessly use code models in your spice simulations. Code models can be useful if you want to quickly cobble together a test environment for your circuit. Here are some examples:
Oneshot
- Simple test schematic of a oneshot code model:
Media:CodeModels.oneshot.png - Oneshot Simulation:
Media:CodeModels.oneshot_gaw.png
V2 (red) is the clock input, when it goes high the oneshot starts a pulse the length of which is controlled by the CTL input which is from V1, the blue sloping line. As it goes higher the green output pulses get longer.
The new net-format attribute holds the custom format string. Net-format can be an unpromoted attribute in the symbol. When you make a new symbol you chose which I/O pins are single ended or differential, and set your format string appropriately. Since my version of the oneshot uses all differential IO its format string looks like this: %vd(~a ~a) %vd(~a ~a) %vd(~a ~a) %vd(~a ~a).
- oneshot.sch: Oneshot gschem file
- oneshot-1.sym: Oneshot Symbol
- oneshot.ckt: Oneshot NGspice netlist output
Integrator
- Integrator code model test circuit:
Media:CodeModels.inttest_1.png - Integrator code model simulation:
Media:CodeModels.inttest_gaw.png
The blue input sine wave and it's red integral. Notice how the integrator symbol has differential input and single ended output? It's format string looks like this: %vd(~a ~a) ~a .
- inttest_1.sch: Integrator gschem file
- integrator-1.sym: Integrator symbol
- inttest_1.ckt: Integrator NGspice netlist output
Differentiator
- Differentiator test circuit:
Media:CodeModels.difftest_1.png - Differentiator simulation:
Media:CodeModels.difftest_gaw.png
The blue input sine wave and its green derivative.
- difftest_1.sch: Differentiator gschem file
- differentiator-1.sym: Differentiator symbol file
- difftest_1.ckt: Differentiator NGspice netlist output
Links:
You can find documentation on NGspice code models here: http://ngspice.sourceforge.net/docs/ngspice-manual.pdf
-- Main.ClifCox - 2011-01-13