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.*;
8 import java.awt.event.*;
9 import java.awt.color.*;
10 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;
27 Log.info(Demo.class, "issuing command");
29 //at40k.iob_top(2, true).oe(false);
30 //at40k.iob_top(2, false).oe(false);
31 //at40k.iob_top(1, true).oe(false);
33 // this command confirmed to turn *on* led0
34 //at40k.iob_top(1, false).output(0);
36 for(int i=0; i<20; i++) {
37 at40k.iob_bot(i, false).output(0);
38 at40k.iob_bot(i, true).output(0);
42 //System.out.println("tick");
44 //System.out.println("tick");
45 //at40k.cell(0x01, 0x17).xlut((byte)0x);
48 System.out.println(Integer.toString(0xff & at40k.cell(0x01, 0x17).xlut(), 16));
49 System.out.println(Integer.toString(0xff & at40k.cell(0x01, 0x17).ylut(), 16));
50 at40k.cell(0x01, 0x17).ylut((byte)0xff);
53 //at40k.cell(0x01, 0x17).wi(L1);
55 System.out.println("a: " + at40k.new SectorWire(true, 0, 4, 0x17).driverRight());
56 System.out.println("b: " + at40k.new SectorWire(true, 1, 4, 0x17).driverRight());
57 FpslicDevice.SectorWire h0p0 = at40k.new SectorWire(true, 0, 0, 0x17);
58 FpslicDevice.SectorWire h0p1 = at40k.new SectorWire(true, 1, 0, 0x17);
59 FpslicDevice.SectorWire h0p2 = at40k.new SectorWire(true, 2, 0, 0x17);
60 FpslicDevice.SectorWire h4p0 = at40k.new SectorWire(true, 0, 4, 0x17);
61 FpslicDevice.SectorWire h4p1 = at40k.new SectorWire(true, 1, 4, 0x17);
62 FpslicDevice.SectorWire h4p2 = at40k.new SectorWire(true, 2, 4, 0x17);
64 //h4p1.drives(h0p1, false);
65 //at40k.cell(0x04, 0x17).out(L1, false);
66 //at40k.cell(0x04, 0x17).h(L0, false);
68 for(int plane=0; plane<5; plane++) {
69 at40k.new SectorWire(true, plane, 4, 0x17).drives(at40k.new SectorWire(true, plane, 0, 0x17), false);
70 at40k.cell(0x04, 0x17).out(plane, false);
71 at40k.cell(0x04, 0x17).h(plane, false);
72 at40k.cell(0x01, 0x17).h(plane, false);
74 try { Thread.sleep(2000); } catch (Exception e) { }
77 at40k.new SectorWire(true, plane, 4, 0x17).drives(at40k.new SectorWire(true, plane, 0, 0x17), true);
78 at40k.cell(0x04, 0x17).out(plane, true);
79 at40k.cell(0x04, 0x17).h(plane, true);
80 at40k.cell(0x01, 0x17).h(plane, true);
81 at40k.cell(0x01, 0x17).wi(plane);
86 System.out.println("xlut is " + hex(at40k.cell(0x04, 0x17).xlut()));
87 System.out.println("ylut is " + hex(at40k.cell(0x04, 0x17).ylut()));
88 FpslicDevice.Cell cell = at40k.cell(0x04, 0x17);
91 System.out.println(cell.c());
98 //cell.t(false, false, true);
99 cell.t(false, true, false);
110 for(int i=3; i>=1; i--) {
111 at40k.cell(i, 0x17).yi(EAST);
112 at40k.cell(i, 0x17).ylut(0x55);
113 at40k.cell(i, 0x17).yo(false);
117 //System.out.println("reading port status: " + Integer.toString(device.readFpgaData() & 0xff, 16));
122 at40k.cell(23, 8).ylut(0xff);
123 at40k.cell(23, 11).ylut(0xff);
124 at40k.iob_right(8, true).enableOutput();
125 at40k.iob_right(11, true).enableOutput();
127 //for(int x=4; x<=22; x++) swap(at40k.cell(x, 22), NW, NORTH);
130 // entry cell: just copy X->X Y->Y
131 //at40k.cell(4,23).b(false);
132 //at40k.cell(4,23).yo(false);
133 //at40k.cell(4,23).ylut(at40k.cell(4,23).xlut());
134 //at40k.cell(4,23).xo(false);
136 at40k.cell(4,23).xlut(0x55);
137 at40k.cell(4,23).ylut(0x55);
140 at40k.cell(4,23).xlut(0x71);
141 at40k.cell(4,23).ylut(0x44);
142 at40k.cell(4,23).c(YLUT);
143 at40k.cell(4,23).f(false);
144 at40k.cell(4,23).t(false, false, true);
147 //for(int x=6; x<=23; x++) copy(at40k.cell(x, 23), NW, WEST); // top row copies to the right
149 copy(at40k.cell(5, 22), NW, NORTH);
150 for(int x=6; x<=22; x++) copy(at40k.cell(x, 22), NW, WEST); // second top row copies to the right
151 //for(int y=22; y>=10; y--) copy(at40k.cell(23, y), NW, NORTH); // right edge copies down
152 for(int y=21; y>=9; y--) copy(at40k.cell(22, y), NW, NORTH); // second right edge copies down
153 copy(at40k.cell(23, 9), NW, WEST); // second output
156 handshaker(at40k.cell(4,23));
157 at40k.cell(4,23).xi(NW);
158 at40k.cell(4,23).yi(SOUTH);
160 //handshaker(at40k.cell(5,23));
161 //at40k.cell(5,23).yi(NORTH);
163 at40k.cell(5,23).yi(NORTH);
164 at40k.cell(5,23).xlut(0x55);
165 at40k.cell(5,23).xi(SW);
166 at40k.cell(5,23).ylut(0x55);
167 at40k.cell(5,22).yi(NORTH);
168 at40k.cell(5,22).xlut(0x55);
170 bounce(at40k.cell(4,22));
172 // cell southeast of entry cell
173 at40k.cell(3,22).xi(NE); // NW->xin
174 at40k.cell(3,22).ylut(0x33); // xin->y
175 at40k.cell(3,22).yo(false); // y->yout
176 copy(at40k.cell(3, 21), NW, NORTH); // second top row copies to the right
177 copy(at40k.cell(4, 21), NW, EAST); // second top row copies to the right
178 copy(at40k.cell(5, 21), NW, EAST); // second top row copies to the right
179 copy(at40k.cell(6, 21), NW, EAST); // second top row copies to the right
180 copy(at40k.cell(6, 22), NW, SOUTH); // second top row copies to the right
183 at40k.cell(05,22).xlut(0xff);
184 at40k.cell(05,22).ylut(0xff);
185 at40k.cell(05,22).c(XLUT);
186 at40k.cell(05,22).f(false);
187 at40k.cell(05,22).b(false);
188 at40k.cell(05,22).oe(NONE);
189 at40k.cell(05,22).v(L3, true);
190 at40k.cell(05,22).out(L3, true);
193 at40k.cell(4,23).ylut(~0xCC);
194 at40k.cell(4,23).xlut(~0xAA);
195 at40k.cell(5,23).ylut(~0xAA);
196 at40k.cell(5,23).xlut(~0xAA);
197 for(int i=6; i<PIPELEN+2; i++) {
198 at40k.cell(i, 23).ylut(0xAA);
199 at40k.cell(i, 23).xlut(0xCC);
200 at40k.cell(i, 23).yi(WEST);
204 doitx(at40k, slipway);
205 Gui vis = new Gui(device, slipway);
206 Frame fr = new Frame();
207 fr.addKeyListener(vis);
208 fr.setLayout(new BorderLayout());
209 fr.add(vis, BorderLayout.CENTER);
211 fr.setSize(900, 900);
215 synchronized(Demo.class) { Demo.class.wait(); }
217 System.out.println("doit");
218 if (mullers) doitx(at40k, device);
219 //System.out.println("counter");
220 //counter(at40k, device);
222 at40k.cell(21,15).yi(WEST);
223 at40k.cell(21,15).ylut(0xAA);
225 at40k.cell(22,15).yi(WEST);
226 at40k.cell(22,15).ylut(0xAA);
229 FpslicDevice.Cell root = at40k.cell(10,20);
231 root.yo(root.north());
232 root.ylut(~LUT_SELF);
236 root.yo(root.east());
237 root.ylut(~LUT_SELF);
241 root.yo(root.south());
242 root.ylut(~LUT_SELF);
246 root.yo(root.west());
250 //////////////////////////////////////////////////////////////////////////////
252 at40k.cell(23,15).h(3, true);
253 at40k.cell(23,15).yi(L3);
254 at40k.cell(23,15).ylut(0xAA);
255 at40k.iob_right(15, true).enableOutput(WEST);
258 FpslicDevice.Cell c = at40k.cell(10,10);
265 copy(c.west(), EAST, NW);
266 copy(c.west().north().west(), SE, SE);
275 copy(c.east(), WEST, SE);
276 copy(c.east().south().east(), NW, NW);
279 copy(c.north(), SOUTH, SOUTH);
280 c.xlut((LUT_SELF & ~LUT_OTHER) | LUT_Z);
294 copy(c.north(), SOUTH, SOUTH);
295 c.xlut((LUT_SELF & ~LUT_OTHER) | LUT_Z);
316 c.hwire(L4).west().drives(c.hwire(L4), false);
317 c.hwire(L4).east().drives(c.hwire(L4), false);
328 c.hwire(L4).west().drives(c.hwire(L4), false);
329 c.hwire(L4).east().drives(c.hwire(L4), false);
333 copy(c.south(), NORTH, NORTH);
334 c.xlut(((~LUT_SELF) & (~LUT_OTHER)) | LUT_Z);
348 copy(c.south(), NORTH, NORTH);
349 c.xlut((LUT_SELF & LUT_OTHER) | LUT_Z);
363 // catch a rising transition
374 c.hwire(L2).west().drives(c.hwire(L2), false);
375 c.hwire(L2).east().drives(c.hwire(L2), false);
381 c = at40k.cell(20,20);
391 c = at40k.cell(21,20);
422 at40k.cell(9,10).xo(true);
423 at40k.cell(9,10).yo(true);
424 at40k.cell(9,10).c(YLUT);
425 at40k.cell(9,10).b(false);
427 //for(int x=5; x<PIPELEN; x++) {
428 //at40k.cell(x,23).hwire(L0).drives(at40k.cell(x,23).hwire(L0).east());
432 at40k.cell(22,11).ylut(0xff);
433 at40k.cell(23,11).yi(L3);
434 //at40k.cell(23,11).yi(WEST);
435 //at40k.cell(23,11).xi(L1);
436 at40k.cell(23,11).ylut(0xAA);
437 at40k.iob_right(11, true).enableOutput(WEST);
438 at40k.cell(23,11).v(L3, true);
439 at40k.cell(23,11).yo(false);
445 System.out.println("correct: " + at40k.cell(19,15).hwire(L3) + " drives " + at40k.cell(20,15).hwire(L3));
446 System.out.println("correct: " + at40k.cell(15,15).hwire(L3) + " drives " + at40k.cell(19,15).hwire(L3));
447 System.out.println("correct: " + at40k.cell(11,15).hwire(L3) + " drives " + at40k.cell(15,15).hwire(L3));
448 System.out.println("correct: " + at40k.cell(07,15).hwire(L3) + " drives " + at40k.cell(11,15).hwire(L3));
450 at40k.cell(19,15).hwire(L3).drives(at40k.cell(20,15).hwire(L3), true);
451 at40k.cell(15,15).hwire(L3).drives(at40k.cell(19,15).hwire(L3), true);
452 at40k.cell(11,15).hwire(L3).drives(at40k.cell(15,15).hwire(L3), true);
453 at40k.cell(07,15).hwire(L3).drives(at40k.cell(11,15).hwire(L3), true);
455 //at40k.cell(05,vv).xlut(0xff);
456 //at40k.cell(05,vv).ylut(0xff);
458 at40k.cell(vx,vv).c(YLUT);
459 at40k.cell(vx,vv).f(false);
460 at40k.cell(vx,vv).b(false);
461 at40k.cell(vx,vv).oe(NONE);
462 at40k.cell(vx,vv).v(L3, true);
463 at40k.cell(vx,vv).out(L3, true);
466 at40k.cell(vx,15).v(L3, true);
467 at40k.cell(vx,15).h(L3, true);
468 at40k.cell(vx,19).vwire(L3).drives(at40k.cell(vx,15).vwire(L3), true);
469 at40k.cell(vx,23).vwire(L3).drives(at40k.cell(vx,19).vwire(L3), true);
472 //at40k.cell(5,23).ylut(0x00);
473 //at40k.cell(6,22).ylut(0xff);
474 //at40k.cell(22,11).ylut(0xff);
476 FpslicDevice.Cell cell = at40k.cell(4, 16);
487 //scan(at40k, cell, YLUT, true);
488 //scan(at40k, cell, YLUT, false);
490 //device.scanFPGA(true);
492 at40k.cell(10,10).f(true);
493 at40k.cell(10,10).c(ZMUX);
495 at40k.cell(8,7).xlut(LUT_SELF);
496 at40k.cell(8,7).xi(NW);
498 at40k.cell(7,8).xlut(LUT_SELF & LUT_Z);
499 at40k.cell(7,8).xi(SE);
500 at40k.cell(7,8).c(XLUT);
501 at40k.cell(7,8).f(false);
502 at40k.cell(7,8).b(false);
503 at40k.cell(7,8).t(TMUX_FB);
504 at40k.cell(7,8).xo(false);
505 System.out.println(at40k.cell(7,8).fb_relevant());
507 at40k.cell(6,13).xi(SE);
508 at40k.cell(6,13).c(ZMUX);
509 at40k.cell(6,13).xlut(LUT_SELF);
510 at40k.cell(6,13).ylut(LUT_OTHER);
511 at40k.cell(6,13).xo(false);
512 at40k.cell(6,13).yo(false);
513 at40k.cell(7,12).xi(SE);
515 for(int i=0; i<24; i++) {
516 at40k.iob_bot(i, true).enableOutput(NORTH);
517 at40k.iob_bot(i, false).enableOutput(NW);
518 at40k.cell(i, 0).xlut(0xff);
519 at40k.cell(i, 0).ylut(0xff);
524 fr.addKeyListener(vis);
525 fr.setLayout(new BorderLayout());
526 fr.add(vis, BorderLayout.CENTER);
528 fr.setSize(900, 900);
532 synchronized(Demo.class) { Demo.class.wait(); }
537 Visualizer v = new Visualizer(at40k, device);
539 v.setSize(1380, 1080);
540 FpslicDevice.Cell cell = at40k.cell(4, 23);
542 //Image img = v.createImage(v.getWidth(), v.getHeight());
546 cell = at40k.cell(x,y);
547 scan(at40k, cell, YLUT, true);
557 //selfTest(device, at40k, v);
558 //System.out.println("save: " + SlipwayBoard.save + " of " + (SlipwayBoard.saveof*5));
560 at40k.iob_top(0, true).enableInput();
561 copy(at40k.cell(0, 23), NORTH, NORTH);
562 at40k.iob_bot(0, true).enableOutput(NORTH);
564 for(int i=0; i<10000; i++) {
566 try { Thread.sleep(100); } catch (Exception e) { }
570 //at40k.cell(0x01, 0x17).h(0, false);
571 //at40k.cell(0x01, 0x17).xi(NE);
572 //at40k.cell(0x01, 0x17).ylut((byte)0x55);
574 //at40k.cell(0x04, 0x17).xlut((byte)0x10);
575 //at40k.cell(0x04, 0x17).ylut((byte)0x10);
576 //at40k.cell(0x04, 0x17).yo(false);
577 //at40k.cell(0x04, 0x17).xo();
580 at40k.cell(0x01, 0x17).xi(L0);
581 at40k.cell(0x01, 0x17).h(L0, true);
584 at40k.cell(0x03, 0x17).xlut((byte)0x55);
585 at40k.cell(0x03, 0x17).ylut((byte)0x55);
586 at40k.cell(0x03, 0x17).yi(EAST);
587 at40k.cell(0x03, 0x17).ylut((byte)0x55);
588 at40k.cell(0x03, 0x17).yo(true);
590 at40k.cell(0x03, 0x17).f(false);
591 at40k.cell(0x03, 0x17).c(XLUT);
592 at40k.cell(0x03, 0x17).oe(NONE);
593 at40k.cell(0x03, 0x17).out(L0, true);
595 at40k.cell(0x02, 0x17).yi(EAST);
596 at40k.cell(0x02, 0x17).ylut((byte)0x55);
597 at40k.cell(0x02, 0x17).yo(false);
599 at40k.cell(0x01, 0x17).yi(EAST);
600 at40k.cell(0x01, 0x17).ylut((byte)0x55);
601 at40k.cell(0x01, 0x17).yo(false);
603 at40k.cell(0x01, 0x17).h(L0, true);
604 at40k.cell(0x01, 0x17).v(L0, false);
606 //at40k.cell(0x01, 0x17).yi(L0);
607 //at40k.cell(0x01, 0x17).xi(L0);
608 //at40k.cell(0x01, 0x17).ylut((byte)0x33);
611 at40k.cell(0x03, 0x17).h(L0, true);
612 at40k.cell(0x03, 0x17).out(L0, true);
613 at40k.cell(0x03, 0x17).c(XLUT);
614 at40k.cell(0x03, 0x17).f(false);
617 at40k.cell(0x01, 0x17).xin(4);
618 at40k.cell(0x01, 0x17).yin(4);
619 at40k.cell(0x01, 0x16).ylut((byte)0x00);
620 device.mode4(2, 0x17, 0x01, 0);
622 for(int i=0; i<10; i++) {
624 System.out.println("tick");
625 //at40k.cell(0x01, 0x17).xlut((byte)0xFF);
626 at40k.cell(0x00, 0x17).ylut((byte)0x00);
627 device.getFpslicDevice().flush();
629 System.out.println("tick");
630 //at40k.cell(0x01, 0x17).xlut((byte)0x00);
631 at40k.cell(0x00, 0x17).ylut((byte)0xFF);
632 device.getFpslicDevice().flush();
638 at40k.iob_top(0, true).output(0);
639 at40k.iob_top(0, true).oe(false);
640 at40k.iob_top(0, true).pullup();
641 device.getFpslicDevice().flush();
644 Log.info(Demo.class, "issuing command");
645 at40k.iob_top(1, true).pulldown();
646 device.getFpslicDevice().flush();
648 Log.info(Demo.class, "done");
650 } catch (Exception e) { e.printStackTrace(); }
654 public static void copy(FpslicDevice.Cell c, int xdir, int ydir) {
656 case NW: case NE: case SW: case SE: {
661 case NORTH: case SOUTH: case EAST: case WEST: {
667 default: throw new Error();
670 case NW: case NE: case SW: case SE: {
675 case NORTH: case SOUTH: case EAST: case WEST: {
681 default: throw new Error();
686 public static String hex(int x) {
687 return Long.toString(x & 0xffffffffL, 16);
690 public static void handshaker(FpslicDevice.Cell cell) {
695 cell.t(false, false, true);
699 private static String pad(int i, String s) { if (s.length()>i) return s; return "0"+pad((i-1),s); }
700 public static String bin8(byte b) {
703 for(int i=7; i>=0; i--)
704 ret += (n & (1<<i))==0 ? "0" : "1";
708 public static void bounce(FpslicDevice.Cell cell, int xi, int yi) {
709 cell.xlut((byte)0xCC);
710 cell.ylut((byte)0xCC);
716 public static void muller(FpslicDevice.Cell cell, int xi, int yi) {
720 cell.t(false, false, true);
727 public static int lutSwap(int x) {
739 /** watches for a rising/falling edge on Yin, emits a pulse on Xout */
740 public static void pulse_detect(FpslicDevice.Cell c, int in, boolean falling) {
744 case NW: case NE: case SW: case SE: {
747 if (!falling) c.ylut(lutSwap(0x0C)); /* x & !z */
748 else c.ylut(lutSwap(0x30)); /* !x & z */
752 case NORTH: case SOUTH: case EAST: case WEST: {
755 if (!falling) c.xlut(0x0C); /* y & !z */
756 else c.xlut(0x30); /* !y & z */
760 default: throw new Error();
764 /** watches for a pulse on Xin, copies value of Yin */
765 public static void pulse_copy(FpslicDevice.Cell cell, int xi, int yi, boolean invert) {
766 loopback(cell, YLUT);
767 if (!invert) cell.ylut(0xB8); /* yo = x ? yi : z => 1011 1000 */
768 else cell.ylut(0x74); /* yo = x ? !yi : z => 0111 0100 */
769 if (!invert) cell.xlut(lutSwap(0xB8)); /* yo = x ? yi : z => 1011 1000 */
770 else cell.xlut(lutSwap(0x74)); /* yo = x ? !yi : z => 0111 0100 */
775 public static void loopback(FpslicDevice.Cell cell, int cin) {
778 cell.t(false, false, true);
784 public static void doit(FpslicDevice at40k, SlipwayBoard device) throws Exception {
786 FpslicDevice.Cell led = at40k.cell(1, 23);
794 FpslicDevice.Cell c = at40k.cell(1, 22);
802 c.v(L0, /*false*/true);
809 for(int i=0; i<4; i++) at40k.cell(i, 20).h(L0, false);
810 FpslicDevice.Cell z = at40k.cell(1, 20);
821 z.hwire(L0).east().drives(z.hwire(L0), false);
822 z.hwire(L1).east().drives(z.hwire(L1), false);
823 z.vwire(L0).south().drives(z.vwire(L0), false);
824 z.vwire(L1).south().drives(z.vwire(L1), false);
827 z = at40k.cell(0, 20);
845 for(int y=20; y<=22; y++)
846 for(int x=2; x<=5; x++) {
847 c = at40k.cell(x, y);
851 //c = at40k.cell(2, 22);
855 c = at40k.cell(1, 21);
869 c = at40k.cell(13, 22);
870 c.xlut(LUT_OTHER | 0xF0);
872 c.t(false, false, true);
879 // this gate detects a rising edge on its Xin (delayed copy on Yin); when viewed, it inverts its state
880 c = at40k.cell(14, 22);
885 c.t(false, false, true);
890 c.ylut(0xA6); // (x & !z) ? ~y : y
893 c = at40k.cell(14, 20);
896 c = at40k.cell(14, 21);
900 c = at40k.cell(13, 22);
902 c.xlut(LUT_OTHER);// | 0xF0);
904 //c = at40k.cell(13, 22);
911 c.t(false, false, true);
916 c.ylut(0x54); // (x || z) & !y
920 c = at40k.cell(2, 21);
925 c.t(false, false, true);
932 //at40k.cell(2, 21).xlut(0xF0);
934 at40k.cell(3, 22).ylut(LUT_OTHER);
935 at40k.cell(3, 22).xi(SW);
937 //at40k.iob_top(5, true).enableOutput(SOUTH);
938 //at40k.iob_top(5, false).enableOutput(SE);
941 public static int yofs = mullers ? 19 : 22;
942 public static void counter(FpslicDevice at40k, SlipwayBoard device) throws Exception {
943 // watch for rising edge from south, emit pulse on Xout (to NE)
944 //copy(at40k.cell(16,23), SW, WEST);
946 for(int x=22; x>=1; x-=2) {
947 pulse_detect(at40k.cell(x, yofs), SE, false);
948 pulse_detect(at40k.cell(x, yofs-1), EAST, true);
949 pulse_copy(at40k.cell(x-1, yofs), SE, SOUTH, false);
950 pulse_copy(at40k.cell(x-1, yofs-1), NE, NORTH, true);
952 //pulse_detect(at40k.cell(15, 22), NORTH, false);
953 //pulse_detect(at40k.cell(16, 22), NW, true);
954 //pulse_copy(at40k.cell(16, 21), NW, WEST, false);
955 //pulse_copy(at40k.cell(15, 21), NE, EAST, true);
957 for(int x=23; x>1; x-=2) {
958 pulse_detect(at40k.cell(x-1, yofs-2), SW, false);
959 pulse_detect(at40k.cell(x-1, yofs-3), WEST, true);
960 pulse_copy(at40k.cell(x, yofs-2), SW, SOUTH, false);
961 pulse_copy(at40k.cell(x, yofs-3), NW, NORTH, true);
963 //pulse_detect(at40k.cell(15, 22), NORTH, false);
964 //pulse_detect(at40k.cell(16, 22), NW, true);
965 //pulse_copy(at40k.cell(16, 21), NW, WEST, false);
966 //pulse_copy(at40k.cell(15, 21), NE, EAST, true);
968 copy(at40k.cell(1, yofs-2), SOUTH, SOUTH);
969 copy(at40k.cell(1, yofs-3), NORTH, NORTH);
970 at40k.cell(1, yofs-3).ylut(~at40k.cell(1, yofs-3).ylut());
971 at40k.cell(1, yofs-3).xlut(~at40k.cell(1, yofs-3).xlut());
973 copy(at40k.cell(23, yofs), SOUTH, SOUTH);
974 copy(at40k.cell(23, yofs-1), SOUTH, SOUTH);
976 for(int i=23; i>yofs; i--) copy(at40k.cell(1, i), SOUTH, SOUTH);
978 //at40k.iob_top(1, true).slew(SLOW);
979 //at40k.iob_top(1, false).slew(SLOW);
983 public static void fill(FpslicDevice at40k, SlipwayBoard device, int num) throws Exception {
984 //muller(at40k.cell(PIPELEN,22), NE, WEST);
985 FpslicDevice.Cell a = at40k.cell(10,22);
986 FpslicDevice.Cell b = at40k.cell(11,22);
988 for(int i=0; i<num; i++) {
989 //System.out.println(i);
991 device.getFpslicDevice().flush();
992 try { Thread.sleep(1); } catch (Exception e) { }
994 device.getFpslicDevice().flush();
995 try { Thread.sleep(1); } catch (Exception e) { }
1001 public static void drain(FpslicDevice at40k, SlipwayBoard device) throws Exception {
1002 FpslicDevice.Cell a = at40k.cell(10,22);
1003 FpslicDevice.Cell b = at40k.cell(11,22);
1006 for(int i=0; i<30; i++) {
1007 //System.out.println(i);
1009 device.getFpslicDevice().flush();
1010 try { Thread.sleep(1); } catch (Exception e) { }
1012 device.getFpslicDevice().flush();
1013 try { Thread.sleep(1); } catch (Exception e) { }
1019 public static void doitx(FpslicDevice at40k, SlipwayBoard device) throws Exception {
1020 for(int i=5; i<PIPELEN+1; i++) bounce(at40k.cell(i, 23), SE, SOUTH);
1021 for(int x=5; x<PIPELEN; x++) muller(at40k.cell(x, 22), x==PIPELEN-1 ? SE : NE, WEST);
1023 bounce(at40k.cell(PIPELEN, 21), NW, WEST);
1025 for(int x=5; x<PIPELEN; x++) muller(at40k.cell(x, 21), SW, x==PIPELEN-1 ? NORTH : EAST);
1026 for(int x=4; x<PIPELEN+1; x++) bounce(at40k.cell(x, 20), NW, NORTH);
1028 bounce(at40k.cell(4, 22), SE, EAST);
1029 //muller(at40k.cell(4PIPELEN-1,21), SW, NORTH);
1031 //muller(at40k.cell(4,22), NE, WEST);
1032 //at40k.cell(4,22).ylut(0xEE);
1033 muller(at40k.cell(5, 22), NE, SOUTH);
1034 muller(at40k.cell(5, 21), NW, EAST);
1036 for(int x=4; x>=0; x--) {
1037 at40k.cell(x, 21).ylut(0xAA);
1038 at40k.cell(x, 21).yi(EAST);
1039 at40k.cell(x, 21).yo(false);
1042 at40k.cell(0, 22).ylut(0xAA);
1043 at40k.cell(0, 22).yi(SOUTH);
1044 at40k.cell(0, 22).yo(false);
1046 at40k.cell(0, 23).ylut(~0xAA);
1047 at40k.cell(0, 23).xlut(~0xcc);
1048 at40k.cell(0, 23).yi(SOUTH);
1049 at40k.cell(0, 23).yo(false);
1051 for(int x=3; x<=23; x+=2) {
1052 pulse_detect(at40k.cell(x-1, 19), SW, false);
1053 pulse_detect(at40k.cell(x-1, 18), WEST, true);
1054 pulse_copy(at40k.cell(x, 19), SW, SOUTH, false);
1055 pulse_copy(at40k.cell(x, 18), NW, NORTH, true);
1058 pulse_detect(at40k.cell(x-1, 16), SW, false);
1059 pulse_detect(at40k.cell(x-1, 15), WEST, true);
1060 pulse_copy(at40k.cell(x, 16), SW, SOUTH, false);
1061 pulse_copy(at40k.cell(x, 15), NW, NORTH, true);
1063 //pulse_detect(at40k.cell(15, 22), NORTH, false);
1064 //pulse_detect(at40k.cell(16, 22), NW, true);
1065 //pulse_copy(at40k.cell(16, 21), NW, WEST, false);
1066 //pulse_copy(at40k.cell(15, 21), NE, EAST, true);
1068 for(int x=14; x>=1; x--)
1069 copy(at40k.cell(x, 17), EAST, EAST);
1070 for(int x=4; x>=0; x--)
1071 copy(at40k.cell(x, 21), EAST, EAST);
1072 copy(at40k.cell(13, 17), SOUTH, SOUTH);
1074 copy(at40k.cell(0, 20), NORTH, NORTH);
1075 copy(at40k.cell(0, 19), NORTH, NORTH);
1076 copy(at40k.cell(0, 18), NORTH, NORTH);
1077 copy(at40k.cell(0, 17), NORTH, NORTH);
1078 copy(at40k.cell(0, 16), NORTH, NORTH);
1079 copy(at40k.cell(1, 16), WEST, WEST);
1080 copy(at40k.cell(1, 15), NORTH, NORTH);
1082 copy(at40k.cell(1, 20), SOUTH, SOUTH);
1083 copy(at40k.cell(1, 19), SOUTH, SOUTH);
1084 copy(at40k.cell(1, 18), SOUTH, SOUTH);
1086 for(int y=20; y<=23; y++)
1087 copy(at40k.cell(23, y), SOUTH, SOUTH);
1090 //for(int x=19; x<=23; x++)
1091 //copy(at40k.cell(x, 0), WEST, WEST);
1092 //copy(at40k.cell(18, 19), NW, NW);
1093 //at40k.iob_top(5, true).enableOutput(SOUTH);
1094 //at40k.iob_top(5, false).enableOutput(SOUTH);