I am confused about source types

Following advice from Holger, I attempted a simple model for a dual push-pull comparator as follows:

****************************************************************************
****
****  Dual push pull comparator  Spice macromodel subckt
***
***  VP=+in, VM = -in, VCCP = positive power, VCCN = negative power, VS = output
.SUBCKT DUAL_PUSH_PULL_COMP VP1 VP2 VM1 VM2 VCCP VCCN VS1 VS2
    XICOMP1 VP1 VM1 VCCP VCCN VS1 COMPARATOR
    XICOMP2 VP2 VM2 VCCP VCCN VS2 COMPARATOR
.ENDS

.SUBCKT COMPARATOR INP INN VHIGH VLOW OUT
    ECOMP OUT 0 V = PWL(V(INP, INN), -10mV, VLOW, -1mV, VLOW, 1mV, VHIGH, 10mV, VHIGH)
.ENDS

running the simulation in Kicad 9.0.0 results in:

Note: Codel model file loading path is C:\Users\jjmcu\OneDrive\Activator_Kicad\Project7
Background thread stopped with timeout = 0
Note: Compatibility modes selected: ps lt a
Circuit: KiCad schematic
Netlist line no. 12:
Undefined parameter [pwl]
Netlist line no. 12:
Expression err: pwl(v(inp, inn), -10mv, vlow, -1mv, vlow, 1mv, vhigh, 10mv, vhigh)}
Netlist line no. 12:
Cannot compute substitute
Netlist line no. 12:
Undefined parameter [pwl]
Netlist line no. 12:
Expression err: pwl(v(inp, inn), -10mv, vlow, -1mv, vlow, 1mv, vhigh, 10mv, vhigh)}
Netlist line no. 12:
Cannot compute substitute
Please check your input netlist.
Error: ngspice.dll cannot recover and awaits to be reset or detached
Warning: can’t find the initialization file spinit.


** ngspice-44 shared library

Does this mean that PWL is not recognised? Or did I make another mistake?
Thanks a lot,
Jan

May I suggest that you consult the ngspice manual, chapter 5?

What you find the manual, is available. What is not there, is not available.

That manual says in 5.1.4:

The same is possible for voltage sources:
Example: pwl_voltage
Blimit b 0 V = pwl(v(1), -4,0, -2,2, 2,4, 4,5, 6,5)

So it is described in the manual, is it not?

The manual example:

Blimit b 0 V = pwl(v(1), -4,0, -2,2, 2,4, 4,5, 6,5)

Your trial

ECOMP OUT 0 V = PWL(V(INP, INN), -10mV, VLOW, -1mV, VLOW, 1mV, VHIGH, 10mV, VHIGH)

You see the difference?

Sorry, I do not understand what is different

Element lines in a spice netlist, sometimes called instance lines, describe the device used. The first letter in such an instance line detemines the device, see chapter 2.3 of the manual for available instances.

The PWL is available in the B source, as the manual example states, not in an E source.

So you may write

BECOMP OUT 0 V = PWL(V(INP, INN), -10mV, 'VLOW', -1mV, 'VLOW', 1mV, 'VHIGH', 10mV, 'VHIGH')

Parameters should be encapsulated withinn braces {} or equivalent apostrophes ’ '.

Thank you very much indeed.