* SPICE netlist
V1 N001 0 5V
R1 N006 N001 1k
R2 N008 N006 1k
R3 N010 N008 1k
R4 0 N010 1k
R5 0 N006 1k
R6 0 N008 1k
R7 0 N010 1k
A1 N002 0 0 0 0 N003 0 0 BUF
A2 N002 0 0 0 0 N004 0 0 BUF
A3 N004 0 N002 N003 0 0 N005 0 AND
A4 N004 0 N002 N002 0 0 N007 0 AND
A5 N002 0 N002 N003 0 0 N009 0 AND
A6 N002 0 N002 N002 0 0 N011 0 AND
V2 N002 0 3V
XU1 NC_11 NC_12 NC_13 NC_14 PC817 Igain=1.5m ;pnba A)K)C)E
XU2 NC_15 NC_16 NC_17 NC_18 PC817 Igain=1.5m ;pnba A)K)C)E
XU3 NC_19 NC_20 NC_21 NC_22 PC817 Igain=1.5m ;pnba A)K)C)E
.tran 10ms

* LTspice schematic (.asc)
Version 4
SHEET 1 1968 768
WIRE -856 -384 -904 -384
WIRE -728 -384 -776 -384
WIRE -728 -320 -728 -384
WIRE -88 -304 -216 -304
WIRE 56 -304 -88 -304
WIRE 88 -304 56 -304
WIRE 344 -304 152 -304
WIRE -216 -272 -216 -304
WIRE 56 -272 56 -304
WIRE 296 -272 56 -272
WIRE -88 -224 -88 -304
WIRE 56 -224 -88 -224
WIRE 88 -224 56 -224
WIRE 232 -224 152 -224
WIRE 440 -224 232 -224
WIRE 632 -208 504 -208
WIRE -88 -192 -88 -224
WIRE 184 -192 -88 -192
WIRE 440 -192 184 -192
WIRE -728 -176 -728 -240
WIRE -728 -176 -792 -176
WIRE 344 -176 344 -304
WIRE 440 -176 344 -176
WIRE -216 -144 -216 -192
WIRE -792 -128 -792 -176
WIRE -728 -80 -728 -176
WIRE -280 -80 -728 -80
WIRE 232 -80 232 -224
WIRE 440 -80 232 -80
WIRE 632 -64 504 -64
WIRE 184 -48 184 -192
WIRE 440 -48 184 -48
WIRE 296 -32 296 -272
WIRE 440 -32 296 -32
WIRE -728 -16 -728 -80
WIRE -792 32 -792 -48
WIRE -792 32 -856 32
WIRE -856 48 -856 32
WIRE 56 48 56 -224
WIRE 232 48 56 48
WIRE 440 48 232 48
WIRE 632 64 504 64
WIRE 184 80 184 -48
WIRE 440 80 184 80
WIRE 344 96 344 -176
WIRE 440 96 344 96
WIRE -792 112 -792 32
WIRE -280 112 -792 112
WIRE -792 128 -792 112
WIRE -856 160 -856 128
WIRE -856 160 -920 160
WIRE 232 176 232 48
WIRE 440 176 232 176
WIRE 632 192 504 192
WIRE 184 208 184 80
WIRE 440 208 184 208
WIRE 296 224 296 -32
WIRE 440 224 296 224
WIRE -856 240 -856 160
WIRE -280 240 -856 240
WIRE -920 272 -920 160
WIRE -856 272 -856 240
WIRE -920 384 -920 352
WIRE -920 384 -984 384
WIRE -856 384 -856 352
WIRE -856 384 -920 384
WIRE -792 384 -792 208
WIRE -792 384 -856 384
WIRE -728 384 -728 64
WIRE -728 384 -792 384
FLAG -904 -384 0
FLAG -984 384 0
FLAG -216 -144 0
SYMBOL voltage -760 -384 R90
SYMATTR InstName V1
SYMATTR Value 5V
SYMBOL res -712 -224 R180
SYMATTR InstName R1
SYMATTR Value 1k
SYMBOL res -776 -32 R180
SYMATTR InstName R2
SYMATTR Value 1k
SYMBOL res -840 144 R180
SYMATTR InstName R3
SYMATTR Value 1k
SYMBOL res -904 368 R180
SYMATTR InstName R4
SYMATTR Value 1k
SYMBOL res -712 80 R180
SYMATTR InstName R5
SYMATTR Value 1k
SYMBOL res -776 224 R180
SYMATTR InstName R6
SYMATTR Value 1k
SYMBOL res -840 368 R180
SYMATTR InstName R7
SYMATTR Value 1k
SYMBOL Digital\\inv 88 -368 R0
SYMATTR InstName A1
SYMBOL Digital\\inv 88 -288 R0
SYMATTR InstName A2
SYMBOL Digital\\and 472 -256 R0
SYMATTR InstName A3
SYMBOL Digital\\and 472 -112 R0
SYMATTR InstName A4
SYMBOL Digital\\and 472 16 R0
SYMATTR InstName A5
SYMBOL Digital\\and 472 144 R0
SYMATTR InstName A6
SYMBOL voltage -216 -288 R0
SYMATTR InstName V2
SYMATTR Value 3V
SYMBOL Optos\\PC817B 984 -272 R0
SYMATTR InstName U1
SYMBOL Optos\\PC817B 984 -112 R0
SYMATTR InstName U2
SYMBOL Optos\\PC817B 984 32 R0
SYMATTR InstName U3