Model Wanted: CD4013 D Flip Flop w/ accurate S&R Functions

In my initial foray into digial simulations, I’ve tried several approaches to adding a CD4013 model to an existing symbol, modifying an existing symbol, creating a lib file etc. etc. I’ve wrangled with code and settings. I’ve put the time in and failed repeatedly. So I think I need to start over, and learn how it should be done.

I’m a relatively new user (Hi everyone) so there is that. I’ve been successful at simulating a variety circuits with opamps and comparators, including factory models etc. But transitioning to digital, even simple components has me stymied. I’ve been at it for a few days and I’m near my wits end.

The ask is a ready resource for a CD4013 flip flop, either multi-unit or a stand-alone single, from a source that has made it work. Simple clear instructions would help. I’m fine with “look here” or “try this” but please know my circumstances are unusual. Ordinary tasks take me longer that most and my stamina is also limited. I’ve little patience left to pioneer or engineer a solution.

I will eventually figure this out. I usually do. But all will have my gratitude that can help shorten the path. Plus I like to engage with communities and I hope I can contribute after a point.

Have you seen this thread:

First link is to the ngSpice website, but I guess you’ve already seen that.

A bit lower there is a link to XSPICE code models. I don’t do much with simulations myself, but I guess that would be a good place for you to look into.

Go to Spice models and model parameters for ngspice circuit simulator
Download MicroCap-LIBRARY.7z.

Extract and copy cmos.lib into the folder containing your device models. cmos.lib contains models for the 4000 series of CMOS gates. A model for the CD4013 is included. The model (lines 419-466 in CMOS.lib)

.SUBCKT CD4013B SA RA CA DA QA QABAR
...
.ends

covers a single flipflop only.

Attach this model to your symbol. To run this model, the compatibility mode in
Inspect–>Simulator–>New Analysis Tab–>Compatibility Mode
has to be set to PSpice and LTSpice.

If the symbol contains two flipflops, you have to generate an intermediate subcircuit (see KiCad Eeschema as GUI for ngspice, tutorial for setting up the simulation for an example doing this with a TL072 dual opamp).

I did not test this model, so please report your results here.

As paulvdh has said, an alternative may be using the ngspice code models, as presented in Simulation with XSPICE code models, where you find symbols with models alraedy attached. These are not models corresponding to specific ICs, but represent general functions. The ‘installation’ of these models is described in the link.