* SPICE netlist
B1 N001 0 V=idt(V(I_in), 0, V(sa))/{6*Ts}
B2 N009 0 V=idt(V(Q_in), 0, V(sb))/{6*Ts}
V1 sa 0 PULSE(0 1 {Tdx+Ts/10} {Ts/10} {Ts/10} 0 {2/rc})
V2 sb 0 PULSE(0 1 {Tdx+1/rc+Ts/10} {Ts/10} {Ts/10} 0 {2/rc})
B3 N002 0 V=(V(I_s)>={r})
B4 N010 0 V=(V(Q_s)>={r})
A1 N001 0 0 N005 0 0 I_s 0 SAMPLEHOLD
V3 N005 0 PULSE(0 1 {Tdx} {Ts/10} {Ts/10} 0 {2/rc})
A2 N009 0 0 N012 0 0 Q_s 0 SAMPLEHOLD
V4 N012 0 PULSE(0 1 {1/rc+Tdx} {Ts/10} {Ts/10} 0 {2/rc})
V5 N013 0 PULSE(0 1 {Tg+0.5/rc} {Ts/10} {Ts/10} {1/(rc)-Ts/10} {2/rc})
A7 N013 0 0 0 0 N011 N004 0 BUF
A3 N006 0 N008 0 0 0 out 0 DFLOP
A4 0 N003 0 N007 0 0 N006 0 OR
A6 0 N002 0 N004 0 0 N003 0 AND
A5 0 N010 0 N011 0 0 N007 0 AND
V6 N008 0 PULSE(0.1 0.9 {Tdx+1/rc+Ts/5} {Ts/10} {Ts/10} 0 {1/rc})
.params
+ Tdx={Td}
+ r={ref}

* LTspice schematic (.asc)
Version 4
SHEET 1 1744 912
WIRE -776 -456 -872 -456
WIRE -776 -88 -856 -88
WIRE -712 328 -712 280
WIRE -712 440 -712 408
WIRE -664 -408 -664 -456
WIRE -664 -280 -664 -328
WIRE -664 -40 -664 -88
WIRE -664 88 -664 40
WIRE -648 280 -712 280
WIRE -392 -280 -392 -360
WIRE -392 -168 -392 -200
WIRE -392 88 -392 8
WIRE -392 200 -392 168
WIRE -312 -456 -664 -456
WIRE -312 -360 -392 -360
WIRE -312 -88 -664 -88
WIRE -312 8 -392 8
WIRE -312 328 -312 280
WIRE -312 440 -312 408
WIRE -248 280 -312 280
WIRE -72 -408 -136 -408
WIRE -72 -40 -136 -40
WIRE 72 -360 72 -408
WIRE 72 -232 72 -280
WIRE 72 8 72 -40
WIRE 72 136 72 88
WIRE 264 312 264 -376
WIRE 296 280 296 -8
WIRE 328 -408 72 -408
WIRE 328 -376 264 -376
WIRE 328 -40 72 -40
WIRE 328 -8 296 -8
WIRE 328 280 296 280
WIRE 328 312 264 312
WIRE 440 -408 392 -408
WIRE 440 -232 440 -408
WIRE 440 -40 392 -40
WIRE 440 -40 440 -200
WIRE 456 296 392 296
WIRE 456 344 456 296
WIRE 456 456 456 424
WIRE 472 -232 440 -232
WIRE 472 -200 440 -200
WIRE 552 -120 552 -184
WIRE 552 8 552 -40
WIRE 616 -232 536 -232
WIRE 616 -184 552 -184
WIRE 872 -232 776 -232
FLAG -872 -456 I_in
IOPIN -64 16 In
FLAG -856 -88 Q_in
IOPIN -48 384 In
FLAG -664 -280 0
FLAG -664 88 0
FLAG -72 -40 Q_s
IOPIN 736 432 Out
FLAG -712 440 0
FLAG -648 280 sa
IOPIN 160 752 Out
FLAG -312 440 0
FLAG -248 280 sb
IOPIN 560 752 Out
FLAG 72 -232 0
FLAG 72 136 0
FLAG -72 -408 I_s
IOPIN 736 64 Out
FLAG -392 -168 0
FLAG -392 200 0
FLAG 456 456 0
FLAG 872 -232 out
IOPIN 1680 240 Out
FLAG 552 8 0
SYMBOL bv -664 -424 R0
SYMATTR InstName B1
SYMATTR Value V=idt(V(I_in), 0, V(sa))/{6*Ts}
SYMBOL bv -664 -56 R0
SYMATTR InstName B2
SYMATTR Value V=idt(V(Q_in), 0, V(sb))/{6*Ts}
SYMBOL voltage -712 312 R0
SYMATTR Value PULSE(0 1 {Tdx+Ts/10} {Ts/10} {Ts/10} 0 {2/rc})
SYMATTR InstName V1
SYMBOL voltage -312 312 R0
SYMATTR Value PULSE(0 1 {Tdx+1/rc+Ts/10} {Ts/10} {Ts/10} 0 {2/rc})
SYMATTR InstName V2
SYMBOL bv 72 -376 R0
SYMATTR InstName B3
SYMATTR Value V=(V(I_s)>={r})
SYMBOL bv 72 -8 R0
SYMATTR InstName B4
SYMATTR Value V=(V(Q_s)>={r})
SYMBOL SpecialFunctions\\sample -232 -424 R0
SYMATTR InstName A1
SYMBOL voltage -392 -296 R0
SYMATTR InstName V3
SYMATTR Value PULSE(0 1 {Tdx} {Ts/10} {Ts/10} 0 {2/rc})
SYMBOL SpecialFunctions\\sample -232 -56 R0
SYMATTR InstName A2
SYMBOL voltage -392 72 R0
SYMATTR InstName V4
SYMATTR Value PULSE(0 1 {1/rc+Tdx} {Ts/10} {Ts/10} 0 {2/rc})
SYMBOL voltage 456 328 M0
SYMATTR Value PULSE(0 1 {Tg+0.5/rc} {Ts/10} {Ts/10} {1/(rc)-Ts/10} {2/rc})
SYMATTR InstName V5
SYMBOL Digital\\buf 392 360 R180
SYMATTR InstName A7
SYMBOL Digital\\dflop 696 -280 R0
SYMATTR InstName A3
SYMBOL Digital\\or 504 -280 R0
SYMATTR InstName A4
SYMBOL Digital\\and 360 -456 R0
SYMATTR InstName A6
SYMBOL Digital\\and 360 -88 R0
SYMATTR InstName A5
SYMBOL voltage 552 -136 R0
SYMATTR Value PULSE(0.1 0.9 {Tdx+1/rc+Ts/5} {Ts/10} {Ts/10} 0 {1/rc})
SYMATTR InstName V6