I want to create a SPICE subcircuit file for an electronic component. I have found the Verilog A code for the component, I want to know how to convert the Verilog A code to LTSPICE compatible subcircuit format. If code conversion is not possible, where to learn programming of subcircuits for LTSPICE?
-
Subcircuits in LTspice are nothing but generic SPICE netlists. Since it is unlikely that you'd be using specific elements of LTspice in Verilog, it's SPICE you need to know, in general, rather than "LTspice programming", there is no such thing. – a concerned citizen Dec 18 '18 at 07:56
2 Answers
Subcircuits in most Spice simulator are not "programmed". They are merely a description of a bunch of components and predefined models that are grouped and can be pasted in a circuit once or multiple times.
Verilog-A models can be imported in most commercial Spice simulators (Spectre, HSpice, SmartSpice). AFAIK there is only one free alternative:
ADMS allows converting Verilog-A models to C/C++-code, which can subsequently be compiled along with ngSpice. However, the ADMS project doesn't seem to have had any activity since 2016.
If only LTSpice is an option (for whatever reason), then your best bet is to recreate the model equations using Behavioral modeling. I expect this to be rather tedious.
One other alternative is the open-source project Spice# which is currently still being developed and maintained (of which I am the author). Rather than ngSpice it is:
- Completely object-oriented.
- A library instead of a standalong executable.
You can create custom models for it in separate C# projects, without the need to recompile the whole project (like ngSpice). There is also a parser available to help with the process of migrating from other simulators. Also, given the similarities between C# and C/C++ it may be feasible to use ADMS to first generate the C/C++ code, and work from there to make it compatible with Spice#. This is also how most original Spice models were implemented in the core library.

- 5,072
- 8
- 24
This is an old question, but consider (when it becomes generally available) trying Qorvo QSPICE rather than LTspice.
Here is a video by author Mike Engelhardt (who also created LTspice) showing the procedure of importing C++ or Verilog models.

- 376,485
- 21
- 320
- 842
-
1Thanks for mentioning that. I didn't realize Mike was out with his new project yet. Looks cool! – Ste Kulov Aug 24 '23 at 17:31