How should I write a simple *.cir file in LTspice
What you need is a B-source, you can set the voltage equal to an if-then statement or other math statments. You can find a complete reference here. This one compares the voltage value of Vin and if its greater than the current of Vg it sets Vref to 1 otherwise Vref is 1



Here is the netlist output of the b-source (view->netlist):

B2 Vref 0 V=IF( V(Vin)&gt;I(Vq),1,V(Vin))