# How to get NAND gate with external spice-model working for simulation in kicad

I am trying to get some logic gates working in kicad-simulation following this Tutorial.

I downloaded the 74HCng.lib as described in the above link, and set this library, and the appropriate model (74HC00) for my component in the spice-model-editor.

The spice-model consists of the following:

.param vcc=5 tripdt=6n
***********************************************************************************
* The 74HCXX gates
*
* 2-input NAND gate
* vcc 2 /4.5/5 /6
* tpd 25n/9n/7n/7n
* tr 19n/7n /  /6n
.SUBCKT 74HC00  in1 in2 out  NVCC NVGND  vcc1={vcc} tripdt1={tripdt}
.param td1={1e-9*(9-3-3)*4.0/(vcc1-0.5)}
.param Rout={60*4.0/(vcc1-0.5)} \$ standard output driver
*Cin1 in1 0 3.5p
*Cin2 in2 0 3.5p
abridge2 [in1 in2] [din1 din2] adc_buff
.model adc_buff adc_bridge(in_low = {vcc1/2.0} in_high = {vcc1/2.0})
a6 [din1 din2] dout nand1
.model nand1 d_nand(rise_delay = {td1} fall_delay = {td1}
+ input_load = 0.5e-12)
abridge1 [dout] [out20] dac1
.model dac1 dac_bridge(out_low = 0.0 out_high = {vcc1} out_undef = {vcc1/2.0}
+ input_load = 5.0e-12 t_rise = {tripdt1}
+ t_fall = {tripdt1})
Rout out20 out {Rout}
.ends



Note that I only understand very little about spice..

Anyway, I connect the gate in the following, very basic circuit: Note that the value "3" at the NAND-gate is just me trying to somehow get the right parameters for running a simulation (I don't really know what value is expected there - my first instinct is that a threshhold-voltage would make sense there - so i plugged in 3 for 3 Volts)

Then I annotate the schematic, open the simulator, plug in 10n time-step and 1u final time for the transient-settings, and try to run the simulation. Unfortunately, kicad tells me:

Circuit: KiCad schematic Too few parameters for subcircuit type "74hc00" (instance: xxu1) Background thread stopped with timeout = 0 Error: there aren't any circuits loaded.

Okay, so it seems I am not providing enough parameters. But I don't know what parameters I am missing to provide, or where I have to provide them... I hope that someone a bit more versed in spice and kicad might be able to point me into the right direction here.

• Not related to the immediate problem, but with one input of the gate grounded, the output will always be High - if you want to see the output switch, you have to have both inputs of a NAND gate High. Commented Aug 20, 2020 at 15:44
• @PeterBennett thanks, i know! This is just a dumb circuit, which will get replaced by a more reasonable one as soon as i got that spice-issue sorted out. Commented Aug 20, 2020 at 17:23

Please have a look at http://ngspice.sourceforge.net/ngspice-eeschema.html#digi

The power unit is missing here.

Or edit the subcircuit:

.SUBCKT 74HC00  in1 in2 out  NVCC NVGND  vcc1={vcc} tripdt1={tripdt}


should become

.SUBCKT 74HC00  in1 in2 out  vcc1={vcc} tripdt1={tripdt}