SPICE Behavioural Bv and Bi sources example .param Rvalue = 2k .param Vswing = 0.5 .param Avol = 1k V1 in 0 SIN(0 1 10k) R1 in A 1k * Fixed behavioural resistor B1 A B I=V(a,b)/Rvalue R2 B 0 1k V2 Rvariable 0 SIN(1 1 1k 0 0 -90) R3 in C 1k * Voltage controlled behavioural resistor (minimum resistance = 1u) B2 C D I=V(c,d)/max(Rvalue * v(Rvariable), 1u) R4 D 0 1k * Difference 1 B3 DIFF1 0 V=V(a,b) * Difference 2 B4 DIFF2 0 V=V(c,d) * Simple behavioural comparator B5 COMPARATOR_OUT 0 V={Vswing * tanh(V(diff1)* Avol)} * Squaring an input B6 SQUARE_OUT 0 V=V(diff2)^2 .tran 2u 2m .options savecurrents .control run listing param plot in diff1 rvariable diff2 plot @b1[i] @b2[i] plot diff1 comparator_out plot diff2 square_out .endc .end