* SPICE netlist
B1 f 0 V={f2/f1}**((time-2/f1)/Ts-1)
A1 f 0 0 0 0 C S 0 MODULATOR space=0 mark={f2} Vhigh={sqrt(2)} Vlow={-sqrt(2)}
D1 P001 o 1N750
D2 P001 N002 1N750
V1 0 N002 {Vdc}
A2 S 0 0 0 0 0 clk 0 BUF tripdt=1n ref=0
R1 o N001 1k
E1 N001 0 s 0 {K}
A3 1 0 clk 0 0 0 To 0 SAMPLEHOLD tripdt=1n
A4 2 0 clk 0 0 0 So 0 SAMPLEHOLD tripdt=1n
A5 3 0 clk 0 0 0 Co 0 SAMPLEHOLD tripdt=1n
B2 1 0 V=sqrt(sdt(V(o)**2,0,V(R))/V(per))
B3 2 0 V=sdt(V(S)*V(o),0,V(R))/V(per)
B4 3 0 V=sdt(V(C)*V(o),0,V(R))/V(per)
B5 per 0 V=sdt(1,0,V(R))
B6 THD 0 V=100*abs(1-hypot(V(So),V(Co)))/V(To)
A6 clk 0 0 0 0 4 0 0 BUF tripdt=1n Td=4n
A7 clk 0 0 4 0 0 R 0 AND tripdt=0n3 Td=3n
.tran 0 {Ts+2/f1} {2/f1} {100u/f1} uic
.param f1=20 f2=20k Ts=2000m
.options plotwinsize=0 numdgt=8 reltol=10u
.param Vdc=0 K=1

* LTspice schematic (.asc)
Version 4
SHEET 1 880 720
WIRE -8 -360 -24 -360
WIRE 168 -360 72 -360
WIRE 232 -360 168 -360
WIRE -344 -328 -376 -328
WIRE -232 -328 -264 -328
WIRE -200 -328 -232 -328
WIRE -232 -312 -232 -328
WIRE 440 -312 408 -312
WIRE -376 -296 -376 -328
WIRE 232 -296 200 -296
WIRE -424 -232 -440 -232
WIRE -376 -168 -376 -216
WIRE -344 -168 -376 -168
WIRE -232 -168 -232 -184
WIRE -232 -168 -264 -168
WIRE -8 -168 -24 -168
WIRE 168 -168 72 -168
WIRE 232 -168 168 -168
WIRE -376 -152 -376 -168
WIRE 440 -120 408 -120
WIRE 200 -104 200 -296
WIRE 232 -104 200 -104
WIRE -8 24 -24 24
WIRE 168 24 72 24
WIRE 232 24 168 24
WIRE 440 72 408 72
WIRE -168 88 -200 88
WIRE 200 88 200 -104
WIRE 232 88 200 88
WIRE -408 152 -440 152
WIRE -376 152 -408 152
WIRE -216 152 -232 152
WIRE -200 152 -200 88
WIRE -200 152 -216 152
WIRE -168 152 -200 152
WIRE 168 152 -104 152
WIRE 200 152 200 88
WIRE 200 152 168 152
WIRE -440 184 -440 152
WIRE 200 184 200 152
WIRE 344 184 200 184
WIRE 440 200 408 200
WIRE -216 216 -232 216
WIRE -200 216 -216 216
WIRE -8 232 -24 232
WIRE 88 232 72 232
WIRE 200 232 200 184
WIRE 232 232 200 232
WIRE 312 232 296 232
WIRE 344 232 312 232
WIRE -440 296 -440 264
WIRE 328 360 312 360
WIRE 424 360 408 360
FLAG -424 -280 s
IOPIN 96 -256 In
FLAG -408 152 f
FLAG -440 296 0
FLAG -200 -328 o
IOPIN 320 -304 Out
FLAG -216 152 S
FLAG -24 -168 0
FLAG 168 -360 1
FLAG -216 216 C
FLAG -24 24 0
FLAG 168 -168 2
FLAG 440 200 R
FLAG 312 360 0
FLAG 424 360 THD
IOPIN 944 384 Out
FLAG 440 -120 So
FLAG 440 72 Co
FLAG -24 -360 0
FLAG 440 -312 To
FLAG -24 232 0
FLAG 88 232 per
FLAG -440 -232 0
FLAG -376 -152 0
FLAG 168 152 clk
FLAG 168 24 3
FLAG 312 232 4
FLAG -168 88 s
IOPIN 352 112 Out
SYMBOL bv -440 168 R0
SYMATTR Value V={f2/f1}**((time-2/f1)/Ts-1)
SYMATTR InstName B1
SYMBOL SpecialFunctions\\modulate2 -376 152 R0
SYMATTR Value space=0 mark={f2}
SYMATTR Value2 Vhigh={sqrt(2)}
SYMATTR SpiceLine Vlow={-sqrt(2)}
SYMATTR InstName A1
SYMBOL zener -248 -248 M180
SYMATTR InstName D1
SYMATTR Value 1N750
SYMATTR Description Diode
SYMATTR Type diode
SYMBOL zener -216 -248 M0
SYMATTR InstName D2
SYMATTR Value 1N750
SYMATTR Description Diode
SYMATTR Type diode
SYMBOL voltage -360 -168 R270
SYMATTR InstName V1
SYMATTR Value {Vdc}
SYMBOL Digital\\buf1 -168 88 R0
SYMATTR Value tripdt=1n
SYMATTR Value2 ref=0
SYMATTR InstName A2
SYMBOL res -248 -344 R90
SYMATTR InstName R1
SYMATTR Value 1k
SYMBOL e -376 -312 R0
SYMATTR InstName E1
SYMATTR Value {K}
SYMBOL SpecialFunctions\\sample 312 -328 R0
SYMATTR Value tripdt=1n
SYMATTR InstName A3
SYMBOL SpecialFunctions\\sample 312 -136 R0
SYMATTR Value tripdt=1n
SYMATTR InstName A4
SYMBOL SpecialFunctions\\sample 312 56 R0
SYMATTR Value tripdt=1n
SYMATTR InstName A5
SYMBOL bv 88 -360 M270
SYMATTR Value V=sqrt(sdt(V(o)**2,0,V(R))/V(per))
SYMATTR InstName B2
SYMBOL bv 88 -168 M270
SYMATTR Value V=sdt(V(S)*V(o),0,V(R))/V(per)
SYMATTR InstName B3
SYMBOL bv 88 24 M270
SYMATTR Value V=sdt(V(C)*V(o),0,V(R))/V(per)
SYMATTR InstName B4
SYMBOL bv 88 232 M270
SYMATTR Value V=sdt(1,0,V(R))
SYMATTR InstName B5
SYMBOL bv 424 360 M270
SYMATTR Value V=100*abs(1-hypot(V(So),V(Co)))/V(To)
SYMATTR InstName B6
SYMBOL Digital\\inv 232 168 R0
SYMATTR InstName A6
SYMATTR Value tripdt=1n
SYMATTR Value2 Td=4n
SYMBOL Digital\\and 376 152 R0
SYMATTR Value tripdt=0n3
SYMATTR InstName A7
SYMATTR Value2 Td=3n