(MouseTest.JaM
) .print

(MouseTest) 512 .dict .def

MouseTest .begin

(MouseTestUtil) .run

(zero) 0 .def
(one) 1 .def
(x) 2 .def

(reda) 0 .def
(redb) 1 .def
(yellowa) 2 .def
(yellowb) 3 .def
(bluea) 4 .def
(blueb) 5 .def
(testenable) 6 .def
(gnd) 7 .def
(ya) 8 .def
(yb) 9 .def
(xa) 10 .def
(xb) 11 .def
(testdata) 12 .def
(testclock) 13 .def
(gatetest) 14 .def
(vdd) 15 .def
(anygood) 16 .def
(jump) 17 .def

(philong) testdata .def
(phishort) testclock .def

(MouseTest) .loadbcd

(pon) (97 0 setchan).cvx .def
(poff) (97 1 setchan).cvx .def

(g) (testamouse) .cvx .def

(t) (pon testamouse poff) .cvx .def

(m) (pon testamouse poff .pop) .cvx .def

(WaferProbe) .loadbcd

(WaferMap)
[
[(127.0) (127.0)] [(128.0) (127.0)] [(129.0) (127.0)] [(130.0) (127.0)] [(131.0) (127.0)] [(132.0) (127.0)] [(133.0) (127.0)]
[(127.0) (127.5) (8.130) (8.300) (127.0) (127.0)]
[(127.0) (127.5)] [(128.0) (127.5)] [(129.0) (127.5)] [(130.0) (127.5)] [(131.0) (127.5)] [(132.0) (127.5)] [(133.0) (127.5)]
[(127.0) (128.0) (8.130) (9.145) (127.0) (127.0)]
[(127.0) (128.0)] [(128.0) (128.0)] [(129.0) (128.0)] [(130.0) (128.0)] [(131.0) (128.0)] [(132.0) (128.0)] [(133.0) (128.0)]
[(127.0) (128.5) (8.130) (8.850) (127.0) (128.0)]
[(127.0) (128.5)] [(128.0) (128.5)] [(129.0) (128.5)] [(130.0) (128.5)] [(131.0) (128.5)] [(132.0) (128.5)] [(133.0) (128.5)]
[(128.0) (129.0) (8.130) (9.145) (127.0) (128.0)]
[(128.0) (129.0)] [(129.0) (129.0)] [(130.0) (129.0)] [(131.0) (129.0)] [(132.0) (129.0)]
[(128.0) (129.5) (8.130) (8.970) (128.0) (129.0)]
[(128.0) (129.5)] [(129.0) (129.5)] [(130.0) (129.5)] [(131.0) (129.5)] [(132.0) (129.5)]
[(130.0) (130.0) (8.130) (9.145) (128.0) (129.0)]
[(130.0) (130.0)]
] .def

(p) () .cvx .def

(waferDataRows) 8 .def
(waferDataColumns) 7 .def
(waferData) waferDataRows .array .def

(initwaferdata)
(
waferDataRows
	(
	-1
	waferDataColumns
		(.dup).cvx .rept
	waferDataColumns .array .astore
	.exch .pop
	).cvx .rept
waferDataRows .array .astore (waferData) .exch .def
).cvx .def

(printwaferdatahead)
(
np nl nl nl
(Data for Run: ) .print runID .cvs .print (  Wafer: ) .print waferID .cvs .print nl
nl
(Wafer Map:) .print nl
(    ) .print (	) .print
0 1 waferDataColumns 1 .sub
	(
	dfix .print
	(	) .print
	).cvx .for
nl
).cvx .def

(mpixd)
[ (127.0) (128.0) (129.0) (130.0) (131.0) (132.0) (133.0)] .def

(dfix)
(
mpixd .exch .aget
).cvx .def

(ixfd)
(
.cvr 127.0 .sub .cvi
).cvx .def

(mpiyd)
[ (127.0) (127.5) (128.0) (128.5) (129.0) (129.5) (130.0) (130.5) ] .def

(dfiy)
(
mpiyd .exch .aget
).cvx .def

(iyfd)
(
.cvr 127.0 .sub .dup .add .cvi
).cvx .def

(printwaferdata)
(
printwaferdatahead
0 1 waferDataRows 1 .sub
	(
	nl
	.dup dfiy .print
	(	) .print
	waferData .exch .aget
	.dup
		(
		.dup 0 .eq
			((Good) .print).cvx .if
		.dup -1 .eq ((    ) .print).cvx
			(
			.dup 2 .bitand 0 .eq .not
				((Step) .print).cvx .if
			.dup 4 .bitand 0 .eq .not
				((Init) .print).cvx .if
			) .cvx .ifelse
		.pop
		(	) .print
		).cvx .arrayforall
	nl
	(	) .print
		(
		.dup -1 .eq
			(
			(    ) .print
			.pop
			).cvx

			(
			1 .bitand 0 .eq 
			((    ) .print).cvx
			((DB  ) .print).cvx .ifelse
			).cvx .ifelse
		(	) .print
		).cvx .arrayforall
	nl
	).cvx .for

summarizerecord
).cvx .def

(recordinwaferdata)
(
(y) .exch iyfd .def
(x) .exch ixfd .def
(d) .exch .def
waferData y .aget
x d .aput
).cvx .def

(runID) -1 .def
(waferID) -1 .def

(testone) (
sk (togglez t .dup (tr) .exch .def 0 .eq .not
(t  .dup (tr) .exch .def 0 .eq .not (t (tr) .exch .def).cvx .if).cvx .if togglez
tr record
).cvx .if
).cvx .def

(record)
(
(total) total 1 .add .def
.dup 0 .eq ((good) good 1 .add .def).cvx .if
.dup 1 .bitand 0 .eq .not ((db) db 1 .add .def).cvx .if
.dup 2 .bitand 0 .eq .not ((sf) sf 1 .add .def).cvx .if
.dup 4 .bitand 0 .eq .not ((ui) ui 1 .add .def).cvx .if
currentX currentY recordinwaferdata
).cvx .def

(initlotdata)
(
waferDataRows
	(
	waferDataColumns
		(0 0 0 0 4 .array .astore).cvx .rept
	waferDataColumns .array .astore
	).cvx .rept
waferDataRows .array .astore (lotData) .exch .def
).cvx .def

(initlot)
(
(runID) .exch .def
initlotdata
(nWafers) 0 .def
(nTotal) 0 .def
(nGood) 0 .def
(nDB) 0 .def
(nSF) 0 .def
(nUI) 0 .def
).cvx .def

(recordlotdata)
(
(nWafers) nWafers 1 .add .def
(nTotal) nTotal total .add .def
(nGood) nGood good .add .def
(nDB) nDB db .add .def
(nSF) nSF sf .add .def
(nUI) nUI ui .add .def

0 1 waferDataRows 1 .sub
	(
	(row) .exch .def
	(rowData) waferData row .aget .def
	(rowLotData) lotData row .aget .def
	0 1 waferDataColumns 1 .sub
		(
		(column) .exch .def
		(r) rowData column .aget .def
		(d) rowLotData column .aget .def
		r 0 .eq
			(d 0 d 0 .aget 1 .add .aput).cvx .if
		r -1 .eq .not
			(
			r 1 .bitand 0 .eq .not
				(d 1 d 1 .aget 1 .add .aput).cvx .if
			r 2 .bitand 0 .eq .not
				(d 2 d 2 .aget 1 .add .aput).cvx .if
			r 4 .bitand 0 .eq .not
				(d 3 d 3 .aget 1 .add .aput).cvx .if
			) .cvx .if
		).cvx .for
	).cvx .for
).cvx .def

(np)
(
() .print
).cvx .def


(printlotdatahead)
(
np nl nl nl
(Data for Run: ) .print runID .cvs .print (  Wafer: ) .print waferID .cvs .print nl
nl
(Wafer Map:) .print nl
(    ) .print (	) .print
0 1 waferDataColumns 1 .sub
	(
	dfix .print
	(	) .print
	).cvx .for
nl
).cvx .def

(printlotdata)
(
printlotdatahead
0 1 waferDataRows 1 .sub
	(
	nl
	.dup dfiy .print
	(	) .print
	lotData .exch .aget
	nl
	.dup
	(Good:) .print
	(	) .print
		(
		0 .aget .cvs .print
		(	) .print
		).cvx .arrayforall
	nl
	.dup
	(Deb:	) .print
		(
		1 .aget .cvs .print
		(	) .print
		).cvx .arrayforall
	nl
	.dup
	(Step:	) .print
		(
		2 .aget .cvs .print
		(	) .print
		).cvx .arrayforall
	nl
	.dup
	(UI:	) .print
		(
		3 .aget .cvs .print
		(	) .print
		).cvx .arrayforall
	nl
	nl
	.dup
	(Yield:	) .print
		(
		0 .aget .cvr nWafers .cvr .div 100 .mul .cvi .cvs .print
		(%	) .print
		).cvx .arrayforall
	nl
	nl
	.pop
	).cvx .for

summarizelot
np
).cvx .def

(summarizelot)
(
nl nl
(Total Die Probed: ) .print nTotal .cvs .print nl
(Good Die: ) .print nGood .cvs .print nl
(Debouncer Failed: ) .print nDB .cvs .print nl
(Step Failed: ) .print nSF .cvs .print nl
(Unable to initialize: ) .print nUI .cvs .print nl
nl
(Lot Yield: ) nGood .cvr nTotal .cvr .div 100.0 .mul .cvi .cvs .print ( percent) .print nl
nl nl nl nl
).cvx .def

(initrecord)
(
initwaferdata
(total) 0 .def
(good) 0 .def
(db) 0 .def
(sf) 0 .def
(ui) 0 .def
).cvx .def

(summarizerecord)
(
nl nl
(Total Die Probed: ) .print total .cvs .print nl
(Good Die: ) .print good .cvs .print nl
(Debouncer Failed: ) .print db .cvs .print nl
(Step Failed: ) .print sf .cvs .print nl
(Unable to initialize: ) .print ui .cvs .print nl
nl
(Wafer Yield: ) good .cvr total .cvr .div 100.0 .mul .cvi .cvs .print ( percent) .print nl
nl nl np nl
).cvx .def

(loadnextwafer)
(
load
).cvx .def

(testawafer) (
(waferID) .exch .def
initrecord
(8.130) (9.145) setdiesize
(127.0) (127.0) seek
initializez
WaferMap (testone).cvx .arrayforall
recordlotdata
printwaferdata
).cvx .def

(testalot)
(
(FuGlas) open
(waferlist) .exch .def
initlot

0 1 waferlist .length 2 .sub (waferlist .exch .aget testawafer loadnextwafer).cvx .for
waferlist waferlist .length 1 .sub .aget testawafer

printlotdata
close
).cvx .def

(tps)
(
sk togglez p togglez
).cvx .def

(testprobesequence)
(
(FuGlas) open
(2.000) (2.000) setdiesize
(8.130) (9.145) setdiesize
(127.0) (127.0) seek
initializez
WaferMap (tps) .cvx .arrayforall
close
).cvx .def

(sk) (
.dup .length 2 .eq
	(
	.dup .aload .pop seek .aload .pop .exch
	nl nl
	(Die X: ) .print .dup (currentX) .exch .def .print
	(   Die Y: ) .print .dup (currentY) .exch .def .print nl
	.true
	) .cvx

	(
	.aload .pop seek setdiesize seek
	.false
	) .cvx .ifelse
).cvx .def

(nl) ((
) .print).cvx .def