How to wire-up multiple gates in a single digital package?

Hi, noob to simulation but I’m covering ground fast (ex: made my first SPICE model for SN74LS161A).

Given a common chip, like the 7404 inverters, I noticed the available spice model (in KiCad 7400.lib) only have one pair of in/out ports. If I wanted to use all the gates in the package, how do I assign the pins in the other gates in the schematic, to the spice ports?

I’m running KiCad 9.0.4, and this is the model I’m referencing:

**********************
*SRC=74LS04;74LS04;TTL;74LSxx;inverter
*SYM=INV
*74LS04 HEX INVERTERS
***
.subckt 74LS04 in out
*FAMILY TTLin TTLout
*pinout N 1 2;3 4;5 6;9 8;11 10;13 12:VCC=14 GND=7
*pinout J 1 2;3 4;5 6;9 8;11 10;13 12:VCC=14 GND=7
*pinout D 1 2;3 4;5 6;9 8;11 10;13 12:VCC=14 GND=7
*pinout FN 2 3;4 6;8 9;13 12;16 14;19 18:VCC=20 GND=10
ainv in out ls_inv 
.model ls_inv d_inverter(rise_delay=9n fall_delay=10n)
.ends

Please let the answer not be clone and modify the standard model? :folded_hands:

-John

No, not cloning. You create a line starting with an X and then you map the pinout to an already existing model. In the thread below there is an example for a TL074 quad opamp.

X indicates the start of a subcircuit (call) (See ngSpice manual Chapter 2.5.3), and with a “subcircuit call” you make a list of pins for the schematic symbol and link it with a defined subcircuit.

Thank you Paul!

By way of the point of your reply my takeaway is that I have to make my own model, using the supplied model as a starting point. That is what I referred to as “cloning”, sorry you got thrown by the semantics.

This is the part where I’m new to SPICE, but not new to software engineering. Typically we’d shy away from modifying/hacking “libraries” and it was frowned upon to make unique copies of routines because that decouples it from the original and it can no longer be tracked and versioned. (not that updating a SPICE model would be very common)

I’m disappointed that the manufacturer (or NGSPICE library author) would create an incomplete model, but I’m seeing this is common and need to reset my expectations.

The syntax I’m not worried about, but thank you again for the example.

-John

You might want to have a look at Spice models and model parameters for ngspice circuit simulator, especially at https://ngspice.sourceforge.io/model-parameters/74HCxxxM.zip .

Thanks holger, yes I’ve seen that page as well.

With any new (to me) technology, it’s easy to learn the ‘syntax’, but more difficult to acclimate to the ‘culture’.

You guys are helping me to learn that it’s rare to get turn-key models and I’ll have to expect to write most of my own. It would be nice if someone put those words at the beginning of pages or videos!

Even the HC model you pointed me to won’t be the same timings as the stock 7404 chips I’m using. Probably won’t matter in the end but I’m still idealistic at this stage. :wink:

-John

Sort of, but not really.
The only thing you add is a single line with the new pin mapping and a reference to the already existing model.

But I do agree that the way ngSpice works is a bit “primitive”. As an open source project, there is no budget to pay for licenses to include “commercial models”. The leaders of the ngSpice project are very conservative in including any model that may have any sort of copyright, and there are lots of simulators that use proprietary (undocumented) extensions, or encrypted models, and ngSpice can use none of those either. Those are all perfectly understandable reasons, but it does make ngSpice a lot less user friendly.

And there are some other things too. It seems like ngSpice has more trouble to converge towards a solution then “other Spice simulators”. ngSpice also tries to be correct. For example, it complains, or fails to converge when a node is left open, while other simulators ignore open nodes (no current is flowing) or, secretly add a resistor of a few Giga Ohm to it so the simulator can continue without bothering the user with such details.

But everything put together, ngSpice is a quite capable and mature simulator. For me it’s simple. I do not use a simulator a lot, and it’s either ngSpice (or possibly another FOSS simulator) that works directly in KiCad, or none at all. I have no interest in commercial (especially subscription based) software, or even freeware with some vague license.

Thank you, Paul, that really helps me incorporate KiCad (and ngSpice) into my workbench. I have no problem with software that’s a little rough around the edges, I just have to know what those edges are. You’re reply went along way to speaking to that ‘culture’ I mentioned, thanks for taking the time. Being new to KiCad I wasn’t sure what I could do or what my experience would be.

I’ll press forward and just write (extend) models for each of my chips and store them in my project directory. Now that I’ve written 74161 from scratch, I’m passed that learning curve.

-John