* SPICE netlist
XU1 N001 0 N002 opamp Aol=100K GBW=10Meg ;pnba invin)noninvin)out
V1 IN1 0 SINE(0.2 0.2 20 0 0 0 10)
R1 N001 IN1 500k
D1 N001 N002 1N4148
XU3 N004 0 N005 opamp Aol=100K GBW=10Meg ;pnba invin)noninvin)out
R4 N004 IN2 500k
R2 N003 N002 5k
R3 N003 N005 5k
R5 0 N010 1k
XU2 N003 N010 N006 opamp Aol=100K GBW=10Meg ;pnba invin)noninvin)out
R6 N006 N003 5k
XU4 N007 0 N008 opamp Aol=100K GBW=10Meg ;pnba invin)noninvin)out
R7 N008 N007 500
R8 N009 N008 1k
XU5 N009 0 out opamp Aol=100K GBW=10Meg ;pnba invin)noninvin)out
R10 out N009 1k
D2 N004 N005 1N4148
D3 N006 N007 1N4148
V2 IN2 0 SINE(0.3 0.3 1k 0 0 0)
V3 vref 0 1
.tran .2

* LTspice schematic (.asc)
Version 4.1
SHEET 1 1856 624
WIRE -576 -312 -640 -312
WIRE -480 -312 -512 -312
WIRE -768 -184 -928 -184
WIRE -640 -184 -640 -312
WIRE -640 -184 -688 -184
WIRE -592 -184 -640 -184
WIRE -928 -168 -928 -184
WIRE -480 -168 -480 -312
WIRE -480 -168 -528 -168
WIRE -416 -168 -480 -168
WIRE -208 -168 -336 -168
WIRE -592 -152 -624 -152
WIRE -624 -104 -624 -152
WIRE -576 24 -640 24
WIRE -480 24 -512 24
WIRE -128 40 -160 40
WIRE -16 40 -48 40
WIRE 144 56 112 56
WIRE 256 56 224 56
WIRE 736 72 704 72
WIRE 848 72 816 72
WIRE -752 152 -848 152
WIRE -640 152 -640 24
WIRE -640 152 -672 152
WIRE -592 152 -640 152
WIRE -480 168 -480 24
WIRE -480 168 -528 168
WIRE -416 168 -480 168
WIRE -208 168 -208 -168
WIRE -208 168 -336 168
WIRE -160 168 -160 40
WIRE -160 168 -208 168
WIRE -128 168 -160 168
WIRE -592 184 -624 184
WIRE -16 184 -16 40
WIRE -16 184 -64 184
WIRE 16 184 -16 184
WIRE 112 184 112 56
WIRE 112 184 80 184
WIRE 144 184 112 184
WIRE -848 200 -848 152
WIRE -128 200 -208 200
WIRE 256 200 256 56
WIRE 256 200 208 200
WIRE 544 200 256 200
WIRE 704 200 704 72
WIRE 704 200 624 200
WIRE 736 200 704 200
WIRE -208 216 -208 200
WIRE 144 216 112 216
WIRE 848 216 848 72
WIRE 848 216 800 216
WIRE 928 216 848 216
WIRE -624 232 -624 184
WIRE 736 232 656 232
WIRE 112 264 112 216
WIRE 656 280 656 232
FLAG -928 -88 0
FLAG -624 -104 0
FLAG -624 232 0
FLAG -208 296 0
FLAG 112 264 0
FLAG -928 -184 IN1
FLAG -848 280 0
FLAG -848 152 IN2
FLAG 656 280 0
FLAG 928 216 out
IOPIN 1664 512 Out
FLAG -16 -40 0
FLAG -16 -120 vref
SYMBOL Opamps\\opamp -560 -232 R0
SYMATTR InstName U1
SYMBOL voltage -928 -184 R0
SYMATTR InstName V1
SYMATTR Value SINE(0.2 0.2 20 0 0 0 10)
SYMBOL res -672 -200 R90
SYMATTR InstName R1
SYMATTR Value 500k
SYMBOL diode -576 -296 R270
SYMATTR InstName D1
SYMATTR Value 1N4148
SYMBOL Opamps\\opamp -560 104 R0
SYMATTR InstName U3
SYMBOL res -656 136 R90
SYMATTR InstName R4
SYMATTR Value 500k
SYMBOL res -320 -184 R90
SYMATTR InstName R2
SYMATTR Value 5k
SYMBOL res -320 152 R90
SYMATTR InstName R3
SYMATTR Value 5k
SYMBOL res -192 312 R180
SYMATTR InstName R5
SYMATTR Value 1k
SYMBOL Opamps\\opamp -96 120 R0
SYMATTR InstName U2
SYMBOL res -32 24 R90
SYMATTR InstName R6
SYMATTR Value 5k
SYMBOL Opamps\\opamp 176 136 R0
SYMATTR InstName U4
SYMBOL res 240 40 R90
SYMATTR InstName R7
SYMATTR Value 500
SYMBOL res 640 184 R90
SYMATTR InstName R8
SYMATTR Value 1k
SYMBOL Opamps\\opamp 768 152 R0
SYMATTR InstName U5
SYMBOL res 832 56 R90
SYMATTR InstName R10
SYMATTR Value 1k
SYMBOL diode -576 40 R270
SYMATTR InstName D2
SYMATTR Value 1N4148
SYMBOL diode 16 200 R270
SYMATTR InstName D3
SYMATTR Value 1N4148
SYMBOL voltage -848 184 R0
SYMATTR InstName V2
SYMATTR Value SINE(0.3 0.3 1k 0 0 0)
SYMBOL voltage -16 -136 R0
SYMATTR InstName V3
SYMATTR Value 1