* SPICE netlist
B9 iv0 0 V=V(iv1)+V(D)*V(mc)*Tsw - V(Dp)*V(md)*Tsw
B10 iv1 0 V=delay(V(iv0), Tsw)
B11 mc 0 V=V(Vcg+,Vcg-)/Lm
B12 md 0 V=V(Vdg+,Vdg-)/Lm
B15 acg 0 V=(1/(2*tcg))*V(mc)
B16 bcg 0 V=-(1/(2*tcg))*(V(mc) + 2*V(md))
B17 N006 0 V=(V(mc)+V(md))**2
B18 ccg 0 V=(1/(tcg))*V(md)
B19 dcg 0 V=V(mc)*V(md)
B20 ecg 0 V=V(md)*V(md)
B21 fcg 0 V=(Tsw/2)*V(mc)*V(md)*V(md)
B22 adg 0 V=-(1/(2*tdg))*(2*V(mc)+V(md))
B23 bdg 0 V=(1/(2*tdg))*V(md)
B24 cdg 0 V=(1/(tdg))*V(mc)
B25 ddg 0 V=V(mc)*V(mc)
B26 edg 0 V=V(mc)*V(md)
B27 fdg 0 V=(Tsw/2)*V(mc)*V(mc)*V(md)
BIdg Vdg- Vdg+ I=(V(adg)*V(iv0)*V(iv0) + V(bdg)*V(iv0)*V(iv0) + V(cdg)*V(iv0)*V(iv0) + V(ddg)*V(iv0) + V(edg)*V(iv0) + V(fdg))/V(den)
BIcg Vcg+ Vcg- I=(V(acg)*V(iv0)*V(iv0) + V(bcg)*V(iv0)*V(iv0) + V(ccg)*V(iv0)*V(iv0) + V(dcg)*V(iv0) + V(ecg)*V(iv0) + V(fcg))/V(den)
R12 den N006 1
D6 N005 den DI
B28 N005 0 V=2u
C1 den 0 100p
R1 D+ D- 10Meg
B1 N001 0 V=V(D+,D-)
R2 D N001 1K
B2 N002 0 V=1-V(D)
R3 Dp N002 1K
D1 D N003 DI
D2 N004 D DI
V1 N003 0 {DMAX-1u}
V2 N004 0 {1u}
B3 Icharge 0 V=I(BIcg)
B4 Idischarge 0 V=I(BIdg)
B5 Ipeak 0 V=V(iv0)+V(D)*Tsw*V(mc)
B6 Ivalley 0 V=V(iv0)
B7 iv1cg 0 V=delay(V(iv0), tcg)
B8 iv1dg 0 V=delay(V(iv0), tdg)
.param Tsw {1/fsw}
.param tcg {Tsw*Dnom/OS}
.param tdg {Tsw*(1-Dnom)/OS}

* LTspice schematic (.asc)
Version 4
SHEET 1 2736 4784
WIRE -1176 -2376 -1256 -2376
WIRE -744 -2376 -824 -2376
WIRE -200 -2376 -296 -2376
WIRE -24 -2376 -120 -2376
WIRE 184 -2376 88 -2376
WIRE 360 -2376 264 -2376
WIRE -1256 -2312 -1256 -2376
WIRE -824 -2312 -824 -2376
WIRE -296 -2312 -296 -2376
WIRE 88 -2312 88 -2376
WIRE 1368 -2264 1240 -2264
WIRE 1240 -2184 1240 -2264
WIRE -1256 -2168 -1256 -2232
WIRE -824 -2168 -824 -2232
WIRE -296 -2168 -296 -2232
WIRE 88 -2168 88 -2232
WIRE 1368 -2136 1368 -2264
WIRE 1240 -2088 1240 -2120
WIRE 1240 -2088 1144 -2088
WIRE 1240 -2056 1240 -2088
WIRE -1176 -1992 -1256 -1992
WIRE -344 -1992 -424 -1992
WIRE 40 -1992 -40 -1992
WIRE 376 -1992 296 -1992
WIRE 1240 -1944 1240 -1992
WIRE -1256 -1928 -1256 -1992
WIRE -424 -1928 -424 -1992
WIRE -40 -1928 -40 -1992
WIRE 296 -1928 296 -1992
WIRE 1240 -1832 1240 -1864
WIRE 1368 -1832 1368 -2056
WIRE 1368 -1832 1240 -1832
WIRE 1240 -1800 1240 -1832
WIRE -1256 -1784 -1256 -1848
WIRE -424 -1784 -424 -1848
WIRE -40 -1784 -40 -1848
WIRE 296 -1784 296 -1848
WIRE -1048 -1256 -1128 -1256
WIRE -952 -1256 -984 -1256
WIRE -872 -1256 -952 -1256
WIRE -792 -1256 -872 -1256
WIRE -872 -1176 -872 -1256
WIRE -952 -1144 -952 -1256
WIRE -1128 -1096 -1128 -1256
WIRE -872 -1080 -872 -1096
WIRE -1128 -952 -1128 -1016
WIRE -952 -952 -952 -1080
WIRE -952 -952 -1128 -952
WIRE -872 -952 -872 -1000
WIRE -872 -952 -952 -952
WIRE -872 -936 -872 -952
WIRE -1240 -712 -1320 -712
WIRE -552 -712 -632 -712
WIRE -1320 -648 -1320 -712
WIRE -632 -648 -632 -712
WIRE -1320 -504 -1320 -568
WIRE -632 -504 -632 -568
WIRE -1256 -440 -1336 -440
WIRE -568 -440 -648 -440
WIRE -1336 -376 -1336 -440
WIRE -648 -376 -648 -440
WIRE -1336 -232 -1336 -296
WIRE -648 -232 -648 -296
WIRE -1256 -136 -1336 -136
WIRE -568 -136 -648 -136
WIRE -1336 -72 -1336 -136
WIRE -648 -72 -648 -136
WIRE -1336 72 -1336 8
WIRE -648 72 -648 8
WIRE -1272 344 -1352 344
WIRE -584 344 -664 344
WIRE -1352 408 -1352 344
WIRE -664 408 -664 344
WIRE -1352 552 -1352 488
WIRE -664 552 -664 488
WIRE -1288 616 -1368 616
WIRE -600 616 -680 616
WIRE -1368 680 -1368 616
WIRE -680 680 -680 616
WIRE -1368 824 -1368 760
WIRE -680 824 -680 760
WIRE -1288 920 -1368 920
WIRE -600 920 -680 920
WIRE -1368 984 -1368 920
WIRE -680 984 -680 920
WIRE -1368 1128 -1368 1064
WIRE -680 1128 -680 1064
WIRE 1080 1560 1000 1560
WIRE 1352 1560 1272 1560
WIRE -1192 1592 -1304 1592
WIRE -1192 1624 -1192 1592
WIRE 1000 1624 1000 1560
WIRE 1272 1624 1272 1560
WIRE -1192 1752 -1192 1704
WIRE -1192 1752 -1304 1752
WIRE 1000 1768 1000 1704
WIRE 1272 1768 1272 1704
WIRE -1256 1848 -1304 1848
WIRE -1256 1896 -1256 1848
WIRE 1080 1896 1000 1896
WIRE 1320 1896 1240 1896
WIRE 1000 1960 1000 1896
WIRE 1240 1960 1240 1896
WIRE -1256 2024 -1256 1976
WIRE -1256 2024 -1304 2024
WIRE 1000 2104 1000 2040
WIRE 1240 2104 1240 2040
WIRE -1256 2216 -1304 2216
WIRE -1256 2264 -1256 2216
WIRE -1256 2392 -1256 2344
WIRE -1256 2392 -1304 2392
FLAG -1256 -1784 0
FLAG -1176 -1992 iv0
FLAG -424 -1784 0
FLAG -344 -1992 iv1
FLAG -1256 -2168 0
FLAG -1176 -2376 mc
FLAG -824 -2168 0
FLAG -744 -2376 md
FLAG -1320 -504 0
FLAG -1240 -712 acg
FLAG -632 -504 0
FLAG -552 -712 bcg
FLAG -872 -936 0
FLAG -792 -1256 den
FLAG -1336 -232 0
FLAG -1256 -440 ccg
FLAG -648 -232 0
FLAG -568 -440 dcg
FLAG -1336 72 0
FLAG -1256 -136 ecg
FLAG -648 72 0
FLAG -568 -136 fcg
FLAG -1352 552 0
FLAG -1272 344 adg
FLAG -664 552 0
FLAG -584 344 bdg
FLAG -1368 824 0
FLAG -1288 616 cdg
FLAG -680 824 0
FLAG -600 616 ddg
FLAG -1368 1128 0
FLAG -1288 920 edg
FLAG -680 1128 0
FLAG -600 920 fdg
FLAG -1304 1848 Vcg+
IOPIN -1008 6896 In
FLAG -1304 2024 Vcg-
IOPIN -1008 7072 In
FLAG -1304 2216 Vdg+
IOPIN -1008 7264 In
FLAG -1304 2392 Vdg-
IOPIN -1008 7440 In
FLAG -1304 1592 D+
IOPIN -1008 6640 In
FLAG -1304 1752 D-
IOPIN -1008 6800 In
FLAG -296 -2168 0
FLAG -24 -2376 D
FLAG 88 -2168 0
FLAG 360 -2376 Dp
FLAG 1240 -1800 0
FLAG 1144 -2088 D
FLAG 1000 2104 0
FLAG 1080 1896 Icharge
IOPIN 1376 6944 Out
FLAG 1240 2104 0
FLAG 1320 1896 Idischarge
IOPIN 1616 6944 Out
FLAG 1272 1768 0
FLAG 1352 1560 Ipeak
IOPIN 1648 6608 Out
FLAG 1000 1768 0
FLAG 1080 1560 Ivalley
IOPIN 1376 6608 Out
FLAG -40 -1784 0
FLAG 40 -1992 iv1cg
FLAG 296 -1784 0
FLAG 376 -1992 iv1dg
SYMBOL bv -1256 -1944 R0
SYMATTR InstName B9
SYMATTR Value V=V(iv1)+V(D)*V(mc)*Tsw  - V(Dp)*V(md)*Tsw
SYMBOL bv -424 -1944 R0
SYMATTR InstName B10
SYMATTR Value V=delay(V(iv0), Tsw)
SYMBOL bv -1256 -2328 R0
SYMATTR InstName B11
SYMATTR Value V=V(Vcg+,Vcg-)/Lm
SYMBOL bv -824 -2328 R0
SYMATTR InstName B12
SYMATTR Value V=V(Vdg+,Vdg-)/Lm
SYMBOL bv -1320 -664 R0
SYMATTR InstName B15
SYMATTR Value V=(1/(2*tcg))*V(mc)
SYMBOL bv -632 -664 R0
SYMATTR InstName B16
SYMATTR Value V=-(1/(2*tcg))*(V(mc) + 2*V(md))
SYMBOL bv -872 -1096 R0
SYMATTR InstName B17
SYMATTR Value V=(V(mc)+V(md))**2
SYMBOL bv -1336 -392 R0
SYMATTR InstName B18
SYMATTR Value V=(1/(tcg))*V(md)
SYMBOL bv -648 -392 R0
SYMATTR InstName B19
SYMATTR Value V=V(mc)*V(md)
SYMBOL bv -1336 -88 R0
SYMATTR InstName B20
SYMATTR Value V=V(md)*V(md)
SYMBOL bv -648 -88 R0
SYMATTR InstName B21
SYMATTR Value V=(Tsw/2)*V(mc)*V(md)*V(md)
SYMBOL bv -1352 392 R0
SYMATTR InstName B22
SYMATTR Value V=-(1/(2*tdg))*(2*V(mc)+V(md))
SYMBOL bv -664 392 R0
SYMATTR InstName B23
SYMATTR Value V=(1/(2*tdg))*V(md)
SYMBOL bv -1368 664 R0
SYMATTR InstName B24
SYMATTR Value V=(1/(tdg))*V(mc)
SYMBOL bv -680 664 R0
SYMATTR InstName B25
SYMATTR Value V=V(mc)*V(mc)
SYMBOL bv -1368 968 R0
SYMATTR InstName B26
SYMATTR Value V=V(mc)*V(md)
SYMBOL bv -680 968 R0
SYMATTR InstName B27
SYMATTR Value V=(Tsw/2)*V(mc)*V(mc)*V(md)
SYMBOL bi -1256 2344 R180
SYMATTR InstName BIdg
SYMATTR Value I=(V(adg)*V(iv0)*V(iv0) + V(bdg)*V(iv0)*V(iv0) + V(cdg)*V(iv0)*V(iv0) + V(ddg)*V(iv0) + V(edg)*V(iv0) + V(fdg))/V(den)
SYMBOL bi -1256 1896 R0
SYMATTR InstName BIcg
SYMATTR Value I=(V(acg)*V(iv0)*V(iv0) + V(bcg)*V(iv0)*V(iv0) + V(ccg)*V(iv0)*V(iv0) + V(dcg)*V(iv0) + V(ecg)*V(iv0) + V(fcg))/V(den)
SYMBOL res -888 -1192 R0
SYMATTR InstName R12
SYMATTR Value 1
SYMBOL diode -1048 -1240 R270
SYMATTR InstName D6
SYMATTR Value DI
SYMBOL bv -1128 -1112 R0
SYMATTR InstName B28
SYMATTR Value V=2u
SYMBOL cap -968 -1144 R0
SYMATTR InstName C1
SYMATTR Value 100p
SYMBOL res -1208 1608 R0
SYMATTR InstName R1
SYMATTR Value 10Meg
SYMBOL bv -296 -2328 R0
SYMATTR InstName B1
SYMATTR Value V=V(D+,D-)
SYMBOL res -104 -2392 R90
SYMATTR InstName R2
SYMATTR Value 1K
SYMBOL bv 88 -2328 R0
SYMATTR InstName B2
SYMATTR Value V=1-V(D)
SYMBOL res 280 -2392 R90
SYMATTR InstName R3
SYMATTR Value 1K
SYMBOL diode 1256 -2120 R180
SYMATTR InstName D1
SYMATTR Value DI
SYMBOL diode 1256 -1992 R180
SYMATTR InstName D2
SYMATTR Value DI
SYMBOL voltage 1368 -2152 R0
SYMATTR InstName V1
SYMATTR Value {DMAX-1u}
SYMBOL voltage 1240 -1960 M0
SYMATTR InstName V2
SYMATTR Value {1u}
SYMBOL bv 1000 1944 R0
SYMATTR InstName B3
SYMATTR Value V=I(BIcg)
SYMBOL bv 1240 1944 R0
SYMATTR InstName B4
SYMATTR Value V=I(BIdg)
SYMBOL bv 1272 1608 R0
SYMATTR InstName B5
SYMATTR Value V=V(iv0)+V(D)*Tsw*V(mc)
SYMBOL bv 1000 1608 R0
SYMATTR InstName B6
SYMATTR Value V=V(iv0)
SYMBOL bv -40 -1944 R0
SYMATTR InstName B7
SYMATTR Value V=delay(V(iv0), tcg)
SYMBOL bv 296 -1944 R0
SYMATTR InstName B8
SYMATTR Value V=delay(V(iv0), tdg)