1 package edu.berkeley.slipway.demos;
3 import edu.berkeley.slipway.*;
4 import com.atmel.fpslic.*;
5 import static com.atmel.fpslic.FpslicConstants.*;
6 import edu.berkeley.slipway.gui.*;
7 import static edu.berkeley.slipway.demos.ExperimentUtils.*;
9 import java.awt.event.*;
10 import java.awt.color.*;
11 import org.ibex.util.*;
17 public static boolean mullers = true;
18 public static int masterx = 1;
20 public static int PIPELEN=20;
22 public static void main(String[] s) throws Exception {
23 SlipwayBoard slipway = new SlipwayBoard();
24 FpslicDevice device = slipway.getFpslicDevice();
25 FpslicDevice at40k = device;
26 FpslicDevice fpslic = device;
28 Log.info(Demo.class, "issuing command");
30 //at40k.iob_top(2, true).oe(false);
31 //at40k.iob_top(2, false).oe(false);
35 for(int i=0; i<20; i++) {
36 at40k.iob_bot(i, false).output(0);
37 at40k.iob_bot(i, true).output(0);
41 //System.out.println("tick");
43 //System.out.println("tick");
44 //at40k.cell(0x01, 0x17).xlut((byte)0x);
47 System.out.println(Integer.toString(0xff & at40k.cell(0x01, 0x17).xlut(), 16));
48 System.out.println(Integer.toString(0xff & at40k.cell(0x01, 0x17).ylut(), 16));
49 at40k.cell(0x01, 0x17).ylut((byte)0xff);
52 //at40k.cell(0x01, 0x17).wi(L1);
54 System.out.println("a: " + at40k.new SectorWire(true, 0, 4, 0x17).driverRight());
55 System.out.println("b: " + at40k.new SectorWire(true, 1, 4, 0x17).driverRight());
56 FpslicDevice.SectorWire h0p0 = at40k.new SectorWire(true, 0, 0, 0x17);
57 FpslicDevice.SectorWire h0p1 = at40k.new SectorWire(true, 1, 0, 0x17);
58 FpslicDevice.SectorWire h0p2 = at40k.new SectorWire(true, 2, 0, 0x17);
59 FpslicDevice.SectorWire h4p0 = at40k.new SectorWire(true, 0, 4, 0x17);
60 FpslicDevice.SectorWire h4p1 = at40k.new SectorWire(true, 1, 4, 0x17);
61 FpslicDevice.SectorWire h4p2 = at40k.new SectorWire(true, 2, 4, 0x17);
63 //h4p1.drives(h0p1, false);
64 //at40k.cell(0x04, 0x17).out(L1, false);
65 //at40k.cell(0x04, 0x17).h(L0, false);
67 for(int plane=0; plane<5; plane++) {
68 at40k.new SectorWire(true, plane, 4, 0x17).drives(at40k.new SectorWire(true, plane, 0, 0x17), false);
69 at40k.cell(0x04, 0x17).out(plane, false);
70 at40k.cell(0x04, 0x17).h(plane, false);
71 at40k.cell(0x01, 0x17).h(plane, false);
73 try { Thread.sleep(2000); } catch (Exception e) { }
76 at40k.new SectorWire(true, plane, 4, 0x17).drives(at40k.new SectorWire(true, plane, 0, 0x17), true);
77 at40k.cell(0x04, 0x17).out(plane, true);
78 at40k.cell(0x04, 0x17).h(plane, true);
79 at40k.cell(0x01, 0x17).h(plane, true);
80 at40k.cell(0x01, 0x17).wi(plane);
85 System.out.println("xlut is " + hex(at40k.cell(0x04, 0x17).xlut()));
86 System.out.println("ylut is " + hex(at40k.cell(0x04, 0x17).ylut()));
87 FpslicDevice.Cell cell = at40k.cell(0x04, 0x17);
90 System.out.println(cell.c());
97 //cell.t(false, false, true);
98 cell.t(false, true, false);
109 for(int i=3; i>=1; i--) {
110 at40k.cell(i, 0x17).yi(EAST);
111 at40k.cell(i, 0x17).ylut(0x55);
112 at40k.cell(i, 0x17).yo(false);
116 //System.out.println("reading port status: " + Integer.toString(device.readFpgaData() & 0xff, 16));
121 at40k.cell(23, 8).ylut(0xff);
122 at40k.cell(23, 11).ylut(0xff);
123 at40k.iob_right(8, true).enableOutput();
124 at40k.iob_right(11, true).enableOutput();
126 //for(int x=4; x<=22; x++) swap(at40k.cell(x, 22), NW, NORTH);
129 // entry cell: just copy X->X Y->Y
130 //at40k.cell(4,23).b(false);
131 //at40k.cell(4,23).yo(false);
132 //at40k.cell(4,23).ylut(at40k.cell(4,23).xlut());
133 //at40k.cell(4,23).xo(false);
135 at40k.cell(4,23).xlut(0x55);
136 at40k.cell(4,23).ylut(0x55);
139 at40k.cell(4,23).xlut(0x71);
140 at40k.cell(4,23).ylut(0x44);
141 at40k.cell(4,23).c(YLUT);
142 at40k.cell(4,23).f(false);
143 at40k.cell(4,23).t(false, false, true);
146 //for(int x=6; x<=23; x++) copy(at40k.cell(x, 23), NW, WEST); // top row copies to the right
148 copy(at40k.cell(5, 22), NW, NORTH);
149 for(int x=6; x<=22; x++) copy(at40k.cell(x, 22), NW, WEST); // second top row copies to the right
150 //for(int y=22; y>=10; y--) copy(at40k.cell(23, y), NW, NORTH); // right edge copies down
151 for(int y=21; y>=9; y--) copy(at40k.cell(22, y), NW, NORTH); // second right edge copies down
152 copy(at40k.cell(23, 9), NW, WEST); // second output
155 handshaker(at40k.cell(4,23));
156 at40k.cell(4,23).xi(NW);
157 at40k.cell(4,23).yi(SOUTH);
159 //handshaker(at40k.cell(5,23));
160 //at40k.cell(5,23).yi(NORTH);
162 at40k.cell(5,23).yi(NORTH);
163 at40k.cell(5,23).xlut(0x55);
164 at40k.cell(5,23).xi(SW);
165 at40k.cell(5,23).ylut(0x55);
166 at40k.cell(5,22).yi(NORTH);
167 at40k.cell(5,22).xlut(0x55);
169 bounce(at40k.cell(4,22));
171 // cell southeast of entry cell
172 at40k.cell(3,22).xi(NE); // NW->xin
173 at40k.cell(3,22).ylut(0x33); // xin->y
174 at40k.cell(3,22).yo(false); // y->yout
175 copy(at40k.cell(3, 21), NW, NORTH); // second top row copies to the right
176 copy(at40k.cell(4, 21), NW, EAST); // second top row copies to the right
177 copy(at40k.cell(5, 21), NW, EAST); // second top row copies to the right
178 copy(at40k.cell(6, 21), NW, EAST); // second top row copies to the right
179 copy(at40k.cell(6, 22), NW, SOUTH); // second top row copies to the right
182 at40k.cell(05,22).xlut(0xff);
183 at40k.cell(05,22).ylut(0xff);
184 at40k.cell(05,22).c(XLUT);
185 at40k.cell(05,22).f(false);
186 at40k.cell(05,22).b(false);
187 at40k.cell(05,22).oe(NONE);
188 at40k.cell(05,22).v(L3, true);
189 at40k.cell(05,22).out(L3, true);
192 at40k.cell(4,23).ylut(~0xCC);
193 at40k.cell(4,23).xlut(~0xAA);
194 at40k.cell(5,23).ylut(~0xAA);
195 at40k.cell(5,23).xlut(~0xAA);
196 for(int i=6; i<PIPELEN+2; i++) {
197 at40k.cell(i, 23).ylut(0xAA);
198 at40k.cell(i, 23).xlut(0xCC);
199 at40k.cell(i, 23).yi(WEST);
203 doitx(at40k, slipway);
204 ExperimentUtils.setupScanCell(at40k);
206 //Gui vis = new Gui(device, slipway);
208 for(int i=0; i<24; i++) {
209 fpslic.iob_bot(i, true).enableOutput(NORTH);
210 fpslic.iob_bot(i, false).enableOutput(NW);
211 fpslic.cell(i, 0).xlut(0xff);
212 fpslic.cell(i, 0).ylut(0xff);
214 copy(fpslic.cell(i, 19), NW, NW);
215 for(int y=18; y>=0; y--) {
216 copy(fpslic.cell(i, y), NORTH, NORTH);
221 DemoVisualizer vis = new DemoVisualizer(device, slipway);
222 Frame fr = new Frame();
223 fr.addKeyListener(vis);
224 fr.setLayout(new BorderLayout());
225 fr.add(vis, BorderLayout.CENTER);
227 fr.setSize(900, 900);
231 synchronized(Demo.class) { Demo.class.wait(); }
233 System.out.println("doit");
234 if (mullers) doitx(at40k, device);
235 //System.out.println("counter");
236 //counter(at40k, device);
238 at40k.cell(21,15).yi(WEST);
239 at40k.cell(21,15).ylut(0xAA);
241 at40k.cell(22,15).yi(WEST);
242 at40k.cell(22,15).ylut(0xAA);
245 FpslicDevice.Cell root = at40k.cell(10,20);
247 root.yo(root.north());
248 root.ylut(~LUT_SELF);
252 root.yo(root.east());
253 root.ylut(~LUT_SELF);
257 root.yo(root.south());
258 root.ylut(~LUT_SELF);
262 root.yo(root.west());
266 //////////////////////////////////////////////////////////////////////////////
268 at40k.cell(23,15).h(3, true);
269 at40k.cell(23,15).yi(L3);
270 at40k.cell(23,15).ylut(0xAA);
271 at40k.iob_right(15, true).enableOutput(WEST);
274 FpslicDevice.Cell c = at40k.cell(10,10);
281 copy(c.west(), EAST, NW);
282 copy(c.west().north().west(), SE, SE);
291 copy(c.east(), WEST, SE);
292 copy(c.east().south().east(), NW, NW);
295 copy(c.north(), SOUTH, SOUTH);
296 c.xlut((LUT_SELF & ~LUT_OTHER) | LUT_Z);
310 copy(c.north(), SOUTH, SOUTH);
311 c.xlut((LUT_SELF & ~LUT_OTHER) | LUT_Z);
332 c.hwire(L4).west().drives(c.hwire(L4), false);
333 c.hwire(L4).east().drives(c.hwire(L4), false);
344 c.hwire(L4).west().drives(c.hwire(L4), false);
345 c.hwire(L4).east().drives(c.hwire(L4), false);
349 copy(c.south(), NORTH, NORTH);
350 c.xlut(((~LUT_SELF) & (~LUT_OTHER)) | LUT_Z);
364 copy(c.south(), NORTH, NORTH);
365 c.xlut((LUT_SELF & LUT_OTHER) | LUT_Z);
379 // catch a rising transition
390 c.hwire(L2).west().drives(c.hwire(L2), false);
391 c.hwire(L2).east().drives(c.hwire(L2), false);
397 c = at40k.cell(20,20);
407 c = at40k.cell(21,20);
438 at40k.cell(9,10).xo(true);
439 at40k.cell(9,10).yo(true);
440 at40k.cell(9,10).c(YLUT);
441 at40k.cell(9,10).b(false);
443 //for(int x=5; x<PIPELEN; x++) {
444 //at40k.cell(x,23).hwire(L0).drives(at40k.cell(x,23).hwire(L0).east());
448 at40k.cell(22,11).ylut(0xff);
449 at40k.cell(23,11).yi(L3);
450 //at40k.cell(23,11).yi(WEST);
451 //at40k.cell(23,11).xi(L1);
452 at40k.cell(23,11).ylut(0xAA);
453 at40k.iob_right(11, true).enableOutput(WEST);
454 at40k.cell(23,11).v(L3, true);
455 at40k.cell(23,11).yo(false);
461 System.out.println("correct: " + at40k.cell(19,15).hwire(L3) + " drives " + at40k.cell(20,15).hwire(L3));
462 System.out.println("correct: " + at40k.cell(15,15).hwire(L3) + " drives " + at40k.cell(19,15).hwire(L3));
463 System.out.println("correct: " + at40k.cell(11,15).hwire(L3) + " drives " + at40k.cell(15,15).hwire(L3));
464 System.out.println("correct: " + at40k.cell(07,15).hwire(L3) + " drives " + at40k.cell(11,15).hwire(L3));
466 at40k.cell(19,15).hwire(L3).drives(at40k.cell(20,15).hwire(L3), true);
467 at40k.cell(15,15).hwire(L3).drives(at40k.cell(19,15).hwire(L3), true);
468 at40k.cell(11,15).hwire(L3).drives(at40k.cell(15,15).hwire(L3), true);
469 at40k.cell(07,15).hwire(L3).drives(at40k.cell(11,15).hwire(L3), true);
471 //at40k.cell(05,vv).xlut(0xff);
472 //at40k.cell(05,vv).ylut(0xff);
474 at40k.cell(vx,vv).c(YLUT);
475 at40k.cell(vx,vv).f(false);
476 at40k.cell(vx,vv).b(false);
477 at40k.cell(vx,vv).oe(NONE);
478 at40k.cell(vx,vv).v(L3, true);
479 at40k.cell(vx,vv).out(L3, true);
482 at40k.cell(vx,15).v(L3, true);
483 at40k.cell(vx,15).h(L3, true);
484 at40k.cell(vx,19).vwire(L3).drives(at40k.cell(vx,15).vwire(L3), true);
485 at40k.cell(vx,23).vwire(L3).drives(at40k.cell(vx,19).vwire(L3), true);
488 //at40k.cell(5,23).ylut(0x00);
489 //at40k.cell(6,22).ylut(0xff);
490 //at40k.cell(22,11).ylut(0xff);
492 FpslicDevice.Cell cell = at40k.cell(4, 16);
503 //scan(at40k, cell, YLUT, true);
504 //scan(at40k, cell, YLUT, false);
506 //device.scanFPGA(true);
508 at40k.cell(10,10).f(true);
509 at40k.cell(10,10).c(ZMUX);
511 at40k.cell(8,7).xlut(LUT_SELF);
512 at40k.cell(8,7).xi(NW);
514 at40k.cell(7,8).xlut(LUT_SELF & LUT_Z);
515 at40k.cell(7,8).xi(SE);
516 at40k.cell(7,8).c(XLUT);
517 at40k.cell(7,8).f(false);
518 at40k.cell(7,8).b(false);
519 at40k.cell(7,8).t(TMUX_FB);
520 at40k.cell(7,8).xo(false);
521 System.out.println(at40k.cell(7,8).fb_relevant());
523 at40k.cell(6,13).xi(SE);
524 at40k.cell(6,13).c(ZMUX);
525 at40k.cell(6,13).xlut(LUT_SELF);
526 at40k.cell(6,13).ylut(LUT_OTHER);
527 at40k.cell(6,13).xo(false);
528 at40k.cell(6,13).yo(false);
529 at40k.cell(7,12).xi(SE);
531 for(int i=0; i<24; i++) {
532 at40k.iob_bot(i, true).enableOutput(NORTH);
533 at40k.iob_bot(i, false).enableOutput(NW);
534 at40k.cell(i, 0).xlut(0xff);
535 at40k.cell(i, 0).ylut(0xff);
538 fr.addKeyListener(vis);
539 fr.setLayout(new BorderLayout());
540 fr.add(vis, BorderLayout.CENTER);
542 fr.setSize(900, 900);
549 synchronized(Demo.class) { Demo.class.wait(); }
554 Visualizer v = new Visualizer(at40k, device);
556 v.setSize(1380, 1080);
557 FpslicDevice.Cell cell = at40k.cell(4, 23);
559 //Image img = v.createImage(v.getWidth(), v.getHeight());
563 cell = at40k.cell(x,y);
564 scan(at40k, cell, YLUT, true);
574 //selfTest(device, at40k, v);
575 //System.out.println("save: " + SlipwayBoard.save + " of " + (SlipwayBoard.saveof*5));
577 at40k.iob_top(0, true).enableInput();
578 copy(at40k.cell(0, 23), NORTH, NORTH);
579 at40k.iob_bot(0, true).enableOutput(NORTH);
581 for(int i=0; i<10000; i++) {
583 try { Thread.sleep(100); } catch (Exception e) { }
587 //at40k.cell(0x01, 0x17).h(0, false);
588 //at40k.cell(0x01, 0x17).xi(NE);
589 //at40k.cell(0x01, 0x17).ylut((byte)0x55);
591 //at40k.cell(0x04, 0x17).xlut((byte)0x10);
592 //at40k.cell(0x04, 0x17).ylut((byte)0x10);
593 //at40k.cell(0x04, 0x17).yo(false);
594 //at40k.cell(0x04, 0x17).xo();
597 at40k.cell(0x01, 0x17).xi(L0);
598 at40k.cell(0x01, 0x17).h(L0, true);
601 at40k.cell(0x03, 0x17).xlut((byte)0x55);
602 at40k.cell(0x03, 0x17).ylut((byte)0x55);
603 at40k.cell(0x03, 0x17).yi(EAST);
604 at40k.cell(0x03, 0x17).ylut((byte)0x55);
605 at40k.cell(0x03, 0x17).yo(true);
607 at40k.cell(0x03, 0x17).f(false);
608 at40k.cell(0x03, 0x17).c(XLUT);
609 at40k.cell(0x03, 0x17).oe(NONE);
610 at40k.cell(0x03, 0x17).out(L0, true);
612 at40k.cell(0x02, 0x17).yi(EAST);
613 at40k.cell(0x02, 0x17).ylut((byte)0x55);
614 at40k.cell(0x02, 0x17).yo(false);
616 at40k.cell(0x01, 0x17).yi(EAST);
617 at40k.cell(0x01, 0x17).ylut((byte)0x55);
618 at40k.cell(0x01, 0x17).yo(false);
620 at40k.cell(0x01, 0x17).h(L0, true);
621 at40k.cell(0x01, 0x17).v(L0, false);
623 //at40k.cell(0x01, 0x17).yi(L0);
624 //at40k.cell(0x01, 0x17).xi(L0);
625 //at40k.cell(0x01, 0x17).ylut((byte)0x33);
628 at40k.cell(0x03, 0x17).h(L0, true);
629 at40k.cell(0x03, 0x17).out(L0, true);
630 at40k.cell(0x03, 0x17).c(XLUT);
631 at40k.cell(0x03, 0x17).f(false);
634 at40k.cell(0x01, 0x17).xin(4);
635 at40k.cell(0x01, 0x17).yin(4);
636 at40k.cell(0x01, 0x16).ylut((byte)0x00);
637 device.mode4(2, 0x17, 0x01, 0);
639 for(int i=0; i<10; i++) {
641 System.out.println("tick");
642 //at40k.cell(0x01, 0x17).xlut((byte)0xFF);
643 at40k.cell(0x00, 0x17).ylut((byte)0x00);
644 device.getFpslicDevice().flush();
646 System.out.println("tick");
647 //at40k.cell(0x01, 0x17).xlut((byte)0x00);
648 at40k.cell(0x00, 0x17).ylut((byte)0xFF);
649 device.getFpslicDevice().flush();
653 at40k.iob_top(0, true).output(0);
654 at40k.iob_top(0, true).oe(false);
655 at40k.iob_top(0, true).pullup();
656 device.getFpslicDevice().flush();
659 Log.info(Demo.class, "issuing command");
660 at40k.iob_top(1, true).pulldown();
661 device.getFpslicDevice().flush();
663 Log.info(Demo.class, "done");
665 } catch (Exception e) { e.printStackTrace(); }
668 public static String hex(int x) { return Long.toString(x & 0xffffffffL, 16); }
669 private static String pad(int i, String s) { if (s.length()>i) return s; return "0"+pad((i-1),s); }
670 public static String bin8(byte b) {
673 for(int i=7; i>=0; i--)
674 ret += (n & (1<<i))==0 ? "0" : "1";
678 public static void handshaker(FpslicDevice.Cell cell) {
683 cell.t(false, false, true);
685 public static void bounce(FpslicDevice.Cell cell, int xi, int yi) {
686 cell.xlut((byte)0xCC);
687 cell.ylut((byte)0xCC);
693 public static void muller(FpslicDevice.Cell cell, int xi, int yi) {
697 cell.t(false, false, true);
705 public static void doit(FpslicDevice at40k, SlipwayBoard device) throws Exception {
707 FpslicDevice.Cell led = at40k.cell(1, 23);
715 FpslicDevice.Cell c = at40k.cell(1, 22);
723 c.v(L0, /*false*/true);
730 for(int i=0; i<4; i++) at40k.cell(i, 20).h(L0, false);
731 FpslicDevice.Cell z = at40k.cell(1, 20);
742 z.hwire(L0).east().drives(z.hwire(L0), false);
743 z.hwire(L1).east().drives(z.hwire(L1), false);
744 z.vwire(L0).south().drives(z.vwire(L0), false);
745 z.vwire(L1).south().drives(z.vwire(L1), false);
748 z = at40k.cell(0, 20);
766 for(int y=20; y<=22; y++)
767 for(int x=2; x<=5; x++) {
768 c = at40k.cell(x, y);
772 //c = at40k.cell(2, 22);
776 c = at40k.cell(1, 21);
790 c = at40k.cell(13, 22);
791 c.xlut(LUT_OTHER | 0xF0);
793 c.t(false, false, true);
800 // this gate detects a rising edge on its Xin (delayed copy on Yin); when viewed, it inverts its state
801 c = at40k.cell(14, 22);
806 c.t(false, false, true);
811 c.ylut(0xA6); // (x & !z) ? ~y : y
814 c = at40k.cell(14, 20);
817 c = at40k.cell(14, 21);
821 c = at40k.cell(13, 22);
823 c.xlut(LUT_OTHER);// | 0xF0);
825 //c = at40k.cell(13, 22);
832 c.t(false, false, true);
837 c.ylut(0x54); // (x || z) & !y
841 c = at40k.cell(2, 21);
846 c.t(false, false, true);
853 //at40k.cell(2, 21).xlut(0xF0);
855 at40k.cell(3, 22).ylut(LUT_OTHER);
856 at40k.cell(3, 22).xi(SW);
858 //at40k.iob_top(5, true).enableOutput(SOUTH);
859 //at40k.iob_top(5, false).enableOutput(SE);
862 public static int yofs = mullers ? 19 : 22;
863 public static void counter(FpslicDevice at40k, SlipwayBoard device) throws Exception {
864 // watch for rising edge from south, emit pulse on Xout (to NE)
865 //copy(at40k.cell(16,23), SW, WEST);
867 for(int x=22; x>=1; x-=2) {
868 pulse_detect(at40k.cell(x, yofs), SE, false);
869 pulse_detect(at40k.cell(x, yofs-1), EAST, true);
870 pulse_copy(at40k.cell(x-1, yofs), SE, SOUTH, false);
871 pulse_copy(at40k.cell(x-1, yofs-1), NE, NORTH, true);
873 //pulse_detect(at40k.cell(15, 22), NORTH, false);
874 //pulse_detect(at40k.cell(16, 22), NW, true);
875 //pulse_copy(at40k.cell(16, 21), NW, WEST, false);
876 //pulse_copy(at40k.cell(15, 21), NE, EAST, true);
878 for(int x=23; x>1; x-=2) {
879 pulse_detect(at40k.cell(x-1, yofs-2), SW, false);
880 pulse_detect(at40k.cell(x-1, yofs-3), WEST, true);
881 pulse_copy(at40k.cell(x, yofs-2), SW, SOUTH, false);
882 pulse_copy(at40k.cell(x, yofs-3), NW, NORTH, true);
884 //pulse_detect(at40k.cell(15, 22), NORTH, false);
885 //pulse_detect(at40k.cell(16, 22), NW, true);
886 //pulse_copy(at40k.cell(16, 21), NW, WEST, false);
887 //pulse_copy(at40k.cell(15, 21), NE, EAST, true);
889 copy(at40k.cell(1, yofs-2), SOUTH, SOUTH);
890 copy(at40k.cell(1, yofs-3), NORTH, NORTH);
891 at40k.cell(1, yofs-3).ylut(~at40k.cell(1, yofs-3).ylut());
892 at40k.cell(1, yofs-3).xlut(~at40k.cell(1, yofs-3).xlut());
894 copy(at40k.cell(23, yofs), SOUTH, SOUTH);
895 copy(at40k.cell(23, yofs-1), SOUTH, SOUTH);
897 for(int i=23; i>yofs; i--) copy(at40k.cell(1, i), SOUTH, SOUTH);
899 //at40k.iob_top(1, true).slew(SLOW);
900 //at40k.iob_top(1, false).slew(SLOW);
904 public static void fill(FpslicDevice at40k, SlipwayBoard device, int num) throws Exception {
905 //muller(at40k.cell(PIPELEN,22), NE, WEST);
906 FpslicDevice.Cell a = at40k.cell(10,22);
907 FpslicDevice.Cell b = at40k.cell(11,22);
909 for(int i=0; i<num; i++) {
910 //System.out.println(i);
912 device.getFpslicDevice().flush();
913 try { Thread.sleep(1); } catch (Exception e) { }
915 device.getFpslicDevice().flush();
916 try { Thread.sleep(1); } catch (Exception e) { }
922 public static void drain(FpslicDevice at40k, SlipwayBoard device) throws Exception {
923 FpslicDevice.Cell a = at40k.cell(10,22);
924 FpslicDevice.Cell b = at40k.cell(11,22);
927 for(int i=0; i<30; i++) {
928 //System.out.println(i);
930 device.getFpslicDevice().flush();
931 try { Thread.sleep(1); } catch (Exception e) { }
933 device.getFpslicDevice().flush();
934 try { Thread.sleep(1); } catch (Exception e) { }
940 public static void doitx(FpslicDevice at40k, SlipwayBoard device) throws Exception {
941 for(int i=5; i<PIPELEN+1; i++) bounce(at40k.cell(i, 23), SE, SOUTH);
942 for(int x=5; x<PIPELEN; x++) muller(at40k.cell(x, 22), x==PIPELEN-1 ? SE : NE, WEST);
944 bounce(at40k.cell(PIPELEN, 21), NW, WEST);
946 for(int x=5; x<PIPELEN; x++) muller(at40k.cell(x, 21), SW, x==PIPELEN-1 ? NORTH : EAST);
947 for(int x=4; x<PIPELEN+1; x++) bounce(at40k.cell(x, 20), NW, NORTH);
949 bounce(at40k.cell(4, 22), SE, EAST);
950 //muller(at40k.cell(4PIPELEN-1,21), SW, NORTH);
952 //muller(at40k.cell(4,22), NE, WEST);
953 //at40k.cell(4,22).ylut(0xEE);
954 muller(at40k.cell(5, 22), NE, SOUTH);
955 muller(at40k.cell(5, 21), NW, EAST);
957 for(int x=4; x>=0; x--) {
958 at40k.cell(x, 21).ylut(0xAA);
959 at40k.cell(x, 21).yi(EAST);
960 at40k.cell(x, 21).yo(false);
963 at40k.cell(0, 22).ylut(0xAA);
964 at40k.cell(0, 22).yi(SOUTH);
965 at40k.cell(0, 22).yo(false);
967 at40k.cell(0, 23).ylut(~0xAA);
968 at40k.cell(0, 23).xlut(~0xcc);
969 at40k.cell(0, 23).yi(SOUTH);
970 at40k.cell(0, 23).yo(false);
972 for(int x=3; x<=23; x+=2) {
973 pulse_detect(at40k.cell(x-1, 19), SW, false);
974 pulse_detect(at40k.cell(x-1, 18), WEST, true);
975 pulse_copy(at40k.cell(x, 19), SW, SOUTH, false);
976 pulse_copy(at40k.cell(x, 18), NW, NORTH, true);
979 pulse_detect(at40k.cell(x-1, 16), SW, false);
980 pulse_detect(at40k.cell(x-1, 15), WEST, true);
981 pulse_copy(at40k.cell(x, 16), SW, SOUTH, false);
982 pulse_copy(at40k.cell(x, 15), NW, NORTH, true);
984 //pulse_detect(at40k.cell(15, 22), NORTH, false);
985 //pulse_detect(at40k.cell(16, 22), NW, true);
986 //pulse_copy(at40k.cell(16, 21), NW, WEST, false);
987 //pulse_copy(at40k.cell(15, 21), NE, EAST, true);
989 for(int x=14; x>=1; x--)
990 copy(at40k.cell(x, 17), EAST, EAST);
991 for(int x=4; x>=0; x--)
992 copy(at40k.cell(x, 21), EAST, EAST);
993 copy(at40k.cell(13, 17), SOUTH, SOUTH);
995 copy(at40k.cell(0, 20), NORTH, NORTH);
996 copy(at40k.cell(0, 19), NORTH, NORTH);
997 copy(at40k.cell(0, 18), NORTH, NORTH);
998 copy(at40k.cell(0, 17), NORTH, NORTH);
999 copy(at40k.cell(0, 16), NORTH, NORTH);
1000 copy(at40k.cell(1, 16), WEST, WEST);
1001 copy(at40k.cell(1, 15), NORTH, NORTH);
1003 copy(at40k.cell(1, 20), SOUTH, SOUTH);
1004 copy(at40k.cell(1, 19), SOUTH, SOUTH);
1005 copy(at40k.cell(1, 18), SOUTH, SOUTH);
1007 for(int y=20; y<=23; y++)
1008 copy(at40k.cell(23, y), SOUTH, SOUTH);
1011 //for(int x=19; x<=23; x++)
1012 //copy(at40k.cell(x, 0), WEST, WEST);
1013 //copy(at40k.cell(18, 19), NW, NW);
1014 //at40k.iob_top(5, true).enableOutput(SOUTH);
1015 //at40k.iob_top(5, false).enableOutput(SOUTH);