Tutorial: ngspice simulation

I have written a short tutorial on how to set up ngspice simulation in Eeschema. It is available from the ngspice web pages at http://ngspice.sourceforge.net/ngspice-eeschema.html.

Comments and enhancements are welcome!

5 Likes

Very nice, I’m getting pumped for V5 release! On that note, you should explicitly state that it is using KiCad 5 to avoid any future confusion.

Sourceforge project sites are currently under maintenance. Please check 10 Minutes! We thank you for your patience!

Over an hour now… Sourceforge seems to be “under maintenance” quite a lot. Consider moving to a more reliable server?

ETA, now I can access it, a very nice intro! A few minor typos, nothing to worry about.

QUOTING the page…

So digital simulation still will need some effort 
to become really useful in KiCad/ngspice.

TRUE. But with some minor tweaks disregarding the
total lack of proper delay and features you may have
a fairly usable set of gates…

With a MINIMALIST STANDARD CMOS (pmos/nmos) gates
you CAN do very simple derived combined logic …

This absolute minimalist gates CAN PRODUCE
digital logic results…

Paul

1 Like

To make the point all clear.

  • ONCE YOU ASSEMBLE YOUR GATES …
  • in a proper KiCAD LIB set…
  • YOU CAN DO LOGIC like FLOPS, MUXs and BCD counters…

Symbols are fairly easy to capture and combine
like this simple DERIVED XOR and clock MULTIPLEXER

They DO WORK as expected
LOGIC

XORing and MUXing a clock as example is quite simple
LOGIC_SET

Paul

Don’t underestimate the combinations.

With a proper set of defined FLOPS you can do a lot

This simple definition (with a matching symbol ) of a D-FLOP
already produce usable results.

FLOPS

LIKE

or the more “refined” CONSOLE view allow you to
confirm the logic results of the proper trigger
FLOP_LOGIC

Have fun.
Paul

I’m by no means an expert in any flavor of spice (I’m aware it exists for circuit simulation, but I use spice for cooking :stuck_out_tongue_winking_eye:). Would one be able to simulate rise times with either a cap to ground or an inline inductor as part of the output of the gates? Maybe simulate a delay within the gate with carefully placed caps and resistors?

With this CMOS gates you are almost ANALOG .

You can and must define your pulses with proper delay/rise /fall times
or weird things will happen.

REAL LOGIC devices are FAR TOO MUCH COMPLICATED
They have built-in triggers and complex stages that
only a proper model will account.

Nevertheless you can see and confirm the results above by yourself

YOU CAN MIX ANALOG DEVICES AT WILL WITH THIS SIMPLE GATES

Paul

Thanks, it seems nicely written, but I am getting stuck in the early stages, i.e. installation.

It seems that a package called libngspice-kicad “Library (shared) for ngspice. Used by kicad” is available from my distribution (Linux MINT 19), but after installation I don’t have a .spiceinit in my home directory or in .config/kicad, or just in .config, or indeed anywhere on my system. It would seem, as might be expected, a default .spiceinit file may not be supplied with the distribution. Your tutorial states “Put the text file named .spiceinit into your home/username directory…” so I was looking for this file in the sources only to eventually realize that it, along with the two lines that need to be added, are already referred to in the Windows section above which I had until this point ignored… Anyway, since I have not compiled from source, I’m still not sure whether I need that file or not.

When I run a simulation on my schematic, errors are returned relating to line numbers that do not correlate to the netlist, but which I’m told relate to the ‘internal’ listing being sent to the spice engine. I have started separate a post on this issue as I’m not sure how to go about troubleshooting this. On the other hand, your example worked just fine which would seem to indicate the simulator is running, despite the .spiceinit file not being present.

A post was split to a new topic: Ngspice simulation question