1 package edu.berkeley.slipway;
3 import edu.berkeley.slipway.*;
4 import com.atmel.fpslic.*;
5 import static com.atmel.fpslic.FpslicConstants.*;
6 import static com.atmel.fpslic.FpslicUtil.*;
7 import edu.berkeley.slipway.gui.*;
9 import java.awt.event.*;
10 import java.awt.color.*;
11 import org.ibex.util.*;
18 public static boolean mullers = true;
19 public static int masterx = 1;
21 public static int PIPELEN=20;
23 public static void main(String[] s) throws Exception {
24 new AsyncPaperDemo().main(s);
27 public static void mainw(String[] s) throws Exception {
28 FtdiBoard device = new FtdiBoard();
29 Fpslic at40k = device;
31 long begin = System.currentTimeMillis();
32 //FpslicUtil.readMode4(new ProgressInputStream("configuring fabric", System.in, 111740), device);
33 long end = System.currentTimeMillis();
34 Log.info(Demo.class, "finished in " + ((end-begin)/1000) + "s");
36 Log.info(Demo.class, "issuing command");
38 //at40k.iob_top(2, true).oe(false);
39 //at40k.iob_top(2, false).oe(false);
40 //at40k.iob_top(1, true).oe(false);
42 // this command confirmed to turn *on* led0
43 //at40k.iob_top(1, false).output(0);
45 for(int i=0; i<20; i++) {
46 at40k.iob_bot(i, false).output(0);
47 at40k.iob_bot(i, true).output(0);
51 //System.out.println("tick");
53 //System.out.println("tick");
54 //at40k.cell(0x01, 0x17).xlut((byte)0x);
57 System.out.println(Integer.toString(0xff & at40k.cell(0x01, 0x17).xlut(), 16));
58 System.out.println(Integer.toString(0xff & at40k.cell(0x01, 0x17).ylut(), 16));
59 at40k.cell(0x01, 0x17).ylut((byte)0xff);
62 //at40k.cell(0x01, 0x17).wi(L1);
64 System.out.println("a: " + at40k.new SectorWire(true, 0, 4, 0x17).driverRight());
65 System.out.println("b: " + at40k.new SectorWire(true, 1, 4, 0x17).driverRight());
66 Fpslic.SectorWire h0p0 = at40k.new SectorWire(true, 0, 0, 0x17);
67 Fpslic.SectorWire h0p1 = at40k.new SectorWire(true, 1, 0, 0x17);
68 Fpslic.SectorWire h0p2 = at40k.new SectorWire(true, 2, 0, 0x17);
69 Fpslic.SectorWire h4p0 = at40k.new SectorWire(true, 0, 4, 0x17);
70 Fpslic.SectorWire h4p1 = at40k.new SectorWire(true, 1, 4, 0x17);
71 Fpslic.SectorWire h4p2 = at40k.new SectorWire(true, 2, 4, 0x17);
73 //h4p1.drives(h0p1, false);
74 //at40k.cell(0x04, 0x17).out(L1, false);
75 //at40k.cell(0x04, 0x17).h(L0, false);
77 for(int plane=0; plane<5; plane++) {
78 at40k.new SectorWire(true, plane, 4, 0x17).drives(at40k.new SectorWire(true, plane, 0, 0x17), false);
79 at40k.cell(0x04, 0x17).out(plane, false);
80 at40k.cell(0x04, 0x17).h(plane, false);
81 at40k.cell(0x01, 0x17).h(plane, false);
83 try { Thread.sleep(2000); } catch (Exception e) { }
86 at40k.new SectorWire(true, plane, 4, 0x17).drives(at40k.new SectorWire(true, plane, 0, 0x17), true);
87 at40k.cell(0x04, 0x17).out(plane, true);
88 at40k.cell(0x04, 0x17).h(plane, true);
89 at40k.cell(0x01, 0x17).h(plane, true);
90 at40k.cell(0x01, 0x17).wi(plane);
95 System.out.println("xlut is " + hex(at40k.cell(0x04, 0x17).xlut()));
96 System.out.println("ylut is " + hex(at40k.cell(0x04, 0x17).ylut()));
97 Fpslic.Cell cell = at40k.cell(0x04, 0x17);
100 System.out.println(cell.c());
107 //cell.t(false, false, true);
108 cell.t(false, true, false);
119 for(int i=3; i>=1; i--) {
120 at40k.cell(i, 0x17).yi(EAST);
121 at40k.cell(i, 0x17).ylut(0x55);
122 at40k.cell(i, 0x17).yo(false);
126 //System.out.println("reading port status: " + Integer.toString(device.readBus() & 0xff, 16));
131 at40k.cell(23, 8).ylut(0xff);
132 at40k.cell(23, 11).ylut(0xff);
133 at40k.iob_right(8, true).enableOutput();
134 at40k.iob_right(11, true).enableOutput();
136 //for(int x=4; x<=22; x++) swap(at40k.cell(x, 22), NW, NORTH);
139 // entry cell: just copy X->X Y->Y
140 //at40k.cell(4,23).b(false);
141 //at40k.cell(4,23).yo(false);
142 //at40k.cell(4,23).ylut(at40k.cell(4,23).xlut());
143 //at40k.cell(4,23).xo(false);
145 at40k.cell(4,23).xlut(0x55);
146 at40k.cell(4,23).ylut(0x55);
149 at40k.cell(4,23).xlut(0x71);
150 at40k.cell(4,23).ylut(0x44);
151 at40k.cell(4,23).c(YLUT);
152 at40k.cell(4,23).f(false);
153 at40k.cell(4,23).t(false, false, true);
156 //for(int x=6; x<=23; x++) copy(at40k.cell(x, 23), NW, WEST); // top row copies to the right
158 copy(at40k.cell(5, 22), NW, NORTH);
159 for(int x=6; x<=22; x++) copy(at40k.cell(x, 22), NW, WEST); // second top row copies to the right
160 //for(int y=22; y>=10; y--) copy(at40k.cell(23, y), NW, NORTH); // right edge copies down
161 for(int y=21; y>=9; y--) copy(at40k.cell(22, y), NW, NORTH); // second right edge copies down
162 copy(at40k.cell(23, 9), NW, WEST); // second output
165 handshaker(at40k.cell(4,23));
166 at40k.cell(4,23).xi(NW);
167 at40k.cell(4,23).yi(SOUTH);
169 //handshaker(at40k.cell(5,23));
170 //at40k.cell(5,23).yi(NORTH);
172 at40k.cell(5,23).yi(NORTH);
173 at40k.cell(5,23).xlut(0x55);
174 at40k.cell(5,23).xi(SW);
175 at40k.cell(5,23).ylut(0x55);
176 at40k.cell(5,22).yi(NORTH);
177 at40k.cell(5,22).xlut(0x55);
179 bounce(at40k.cell(4,22));
181 // cell southeast of entry cell
182 at40k.cell(3,22).xi(NE); // NW->xin
183 at40k.cell(3,22).ylut(0x33); // xin->y
184 at40k.cell(3,22).yo(false); // y->yout
185 copy(at40k.cell(3, 21), NW, NORTH); // second top row copies to the right
186 copy(at40k.cell(4, 21), NW, EAST); // second top row copies to the right
187 copy(at40k.cell(5, 21), NW, EAST); // second top row copies to the right
188 copy(at40k.cell(6, 21), NW, EAST); // second top row copies to the right
189 copy(at40k.cell(6, 22), NW, SOUTH); // second top row copies to the right
192 at40k.cell(05,22).xlut(0xff);
193 at40k.cell(05,22).ylut(0xff);
194 at40k.cell(05,22).c(XLUT);
195 at40k.cell(05,22).f(false);
196 at40k.cell(05,22).b(false);
197 at40k.cell(05,22).oe(NONE);
198 at40k.cell(05,22).v(L3, true);
199 at40k.cell(05,22).out(L3, true);
202 at40k.cell(4,23).ylut(~0xCC);
203 at40k.cell(4,23).xlut(~0xAA);
204 at40k.cell(5,23).ylut(~0xAA);
205 at40k.cell(5,23).xlut(~0xAA);
206 for(int i=6; i<PIPELEN+2; i++) {
207 at40k.cell(i, 23).ylut(0xAA);
208 at40k.cell(i, 23).xlut(0xCC);
209 at40k.cell(i, 23).yi(WEST);
214 System.out.println("doit");
215 if (mullers) doitx(at40k, device);
216 //System.out.println("counter");
217 //counter(at40k, device);
219 at40k.cell(21,15).yi(WEST);
220 at40k.cell(21,15).ylut(0xAA);
222 at40k.cell(22,15).yi(WEST);
223 at40k.cell(22,15).ylut(0xAA);
226 Fpslic.Cell root = at40k.cell(10,20);
228 root.yo(root.north());
229 root.ylut(~LUT_SELF);
233 root.yo(root.east());
234 root.ylut(~LUT_SELF);
238 root.yo(root.south());
239 root.ylut(~LUT_SELF);
243 root.yo(root.west());
247 //////////////////////////////////////////////////////////////////////////////
249 at40k.cell(23,15).h(3, true);
250 at40k.cell(23,15).yi(L3);
251 at40k.cell(23,15).ylut(0xAA);
252 at40k.iob_right(15, true).enableOutput(WEST);
255 Fpslic.Cell c = at40k.cell(10,10);
262 copy(c.west(), EAST, NW);
263 copy(c.west().north().west(), SE, SE);
272 copy(c.east(), WEST, SE);
273 copy(c.east().south().east(), NW, NW);
276 copy(c.north(), SOUTH, SOUTH);
277 c.xlut((LUT_SELF & ~LUT_OTHER) | LUT_Z);
291 copy(c.north(), SOUTH, SOUTH);
292 c.xlut((LUT_SELF & ~LUT_OTHER) | LUT_Z);
313 c.hwire(L4).west().drives(c.hwire(L4), false);
314 c.hwire(L4).east().drives(c.hwire(L4), false);
325 c.hwire(L4).west().drives(c.hwire(L4), false);
326 c.hwire(L4).east().drives(c.hwire(L4), false);
330 copy(c.south(), NORTH, NORTH);
331 c.xlut(((~LUT_SELF) & (~LUT_OTHER)) | LUT_Z);
345 copy(c.south(), NORTH, NORTH);
346 c.xlut((LUT_SELF & LUT_OTHER) | LUT_Z);
360 // catch a rising transition
371 c.hwire(L2).west().drives(c.hwire(L2), false);
372 c.hwire(L2).east().drives(c.hwire(L2), false);
378 c = at40k.cell(20,20);
388 c = at40k.cell(21,20);
419 at40k.cell(9,10).xo(true);
420 at40k.cell(9,10).yo(true);
421 at40k.cell(9,10).c(YLUT);
422 at40k.cell(9,10).b(false);
424 //for(int x=5; x<PIPELEN; x++) {
425 //at40k.cell(x,23).hwire(L0).drives(at40k.cell(x,23).hwire(L0).east());
429 at40k.cell(22,11).ylut(0xff);
430 at40k.cell(23,11).yi(L3);
431 //at40k.cell(23,11).yi(WEST);
432 //at40k.cell(23,11).xi(L1);
433 at40k.cell(23,11).ylut(0xAA);
434 at40k.iob_right(11, true).enableOutput(WEST);
435 at40k.cell(23,11).v(L3, true);
436 at40k.cell(23,11).yo(false);
442 System.out.println("correct: " + at40k.cell(19,15).hwire(L3) + " drives " + at40k.cell(20,15).hwire(L3));
443 System.out.println("correct: " + at40k.cell(15,15).hwire(L3) + " drives " + at40k.cell(19,15).hwire(L3));
444 System.out.println("correct: " + at40k.cell(11,15).hwire(L3) + " drives " + at40k.cell(15,15).hwire(L3));
445 System.out.println("correct: " + at40k.cell(07,15).hwire(L3) + " drives " + at40k.cell(11,15).hwire(L3));
447 at40k.cell(19,15).hwire(L3).drives(at40k.cell(20,15).hwire(L3), true);
448 at40k.cell(15,15).hwire(L3).drives(at40k.cell(19,15).hwire(L3), true);
449 at40k.cell(11,15).hwire(L3).drives(at40k.cell(15,15).hwire(L3), true);
450 at40k.cell(07,15).hwire(L3).drives(at40k.cell(11,15).hwire(L3), true);
452 //at40k.cell(05,vv).xlut(0xff);
453 //at40k.cell(05,vv).ylut(0xff);
455 at40k.cell(vx,vv).c(YLUT);
456 at40k.cell(vx,vv).f(false);
457 at40k.cell(vx,vv).b(false);
458 at40k.cell(vx,vv).oe(NONE);
459 at40k.cell(vx,vv).v(L3, true);
460 at40k.cell(vx,vv).out(L3, true);
463 at40k.cell(vx,15).v(L3, true);
464 at40k.cell(vx,15).h(L3, true);
465 at40k.cell(vx,19).vwire(L3).drives(at40k.cell(vx,15).vwire(L3), true);
466 at40k.cell(vx,23).vwire(L3).drives(at40k.cell(vx,19).vwire(L3), true);
469 //at40k.cell(5,23).ylut(0x00);
470 //at40k.cell(6,22).ylut(0xff);
471 //at40k.cell(22,11).ylut(0xff);
473 Fpslic.Cell cell = at40k.cell(4, 16);
484 //scan(at40k, cell, YLUT, true);
485 //scan(at40k, cell, YLUT, false);
487 //device.scanFPGA(true);
489 at40k.cell(10,10).f(true);
490 at40k.cell(10,10).c(ZMUX);
492 at40k.cell(8,7).xlut(LUT_SELF);
493 at40k.cell(8,7).xi(NW);
495 at40k.cell(7,8).xlut(LUT_SELF & LUT_Z);
496 at40k.cell(7,8).xi(SE);
497 at40k.cell(7,8).c(XLUT);
498 at40k.cell(7,8).f(false);
499 at40k.cell(7,8).b(false);
500 at40k.cell(7,8).t(TMUX_FB);
501 at40k.cell(7,8).xo(false);
502 System.out.println(at40k.cell(7,8).fb_relevant());
504 at40k.cell(6,13).xi(SE);
505 at40k.cell(6,13).c(ZMUX);
506 at40k.cell(6,13).xlut(LUT_SELF);
507 at40k.cell(6,13).ylut(LUT_OTHER);
508 at40k.cell(6,13).xo(false);
509 at40k.cell(6,13).yo(false);
510 at40k.cell(7,12).xi(SE);
512 for(int i=0; i<24; i++) {
513 at40k.iob_bot(i, true).enableOutput(NORTH);
514 at40k.iob_bot(i, false).enableOutput(NW);
515 at40k.cell(i, 0).xlut(0xff);
516 at40k.cell(i, 0).ylut(0xff);
521 Gui vis = new Gui(at40k, device);
522 Frame fr = new Frame();
523 fr.addKeyListener(vis);
524 fr.setLayout(new BorderLayout());
525 fr.add(vis, BorderLayout.CENTER);
527 fr.setSize(900, 900);
531 synchronized(Demo.class) { Demo.class.wait(); }
536 Visualizer v = new Visualizer(at40k, device);
538 v.setSize(1380, 1080);
539 Fpslic.Cell cell = at40k.cell(4, 23);
541 //Image img = v.createImage(v.getWidth(), v.getHeight());
545 cell = at40k.cell(x,y);
546 scan(at40k, cell, YLUT, true);
556 //selfTest(device, at40k, v);
557 //System.out.println("save: " + FtdiBoard.save + " of " + (FtdiBoard.saveof*5));
559 at40k.iob_top(0, true).enableInput();
560 copy(at40k.cell(0, 23), NORTH, NORTH);
561 at40k.iob_bot(0, true).enableOutput(NORTH);
563 for(int i=0; i<10000; i++) {
565 try { Thread.sleep(100); } catch (Exception e) { }
569 //at40k.cell(0x01, 0x17).h(0, false);
570 //at40k.cell(0x01, 0x17).xi(NE);
571 //at40k.cell(0x01, 0x17).ylut((byte)0x55);
573 //at40k.cell(0x04, 0x17).xlut((byte)0x10);
574 //at40k.cell(0x04, 0x17).ylut((byte)0x10);
575 //at40k.cell(0x04, 0x17).yo(false);
576 //at40k.cell(0x04, 0x17).xo();
579 at40k.cell(0x01, 0x17).xi(L0);
580 at40k.cell(0x01, 0x17).h(L0, true);
583 at40k.cell(0x03, 0x17).xlut((byte)0x55);
584 at40k.cell(0x03, 0x17).ylut((byte)0x55);
585 at40k.cell(0x03, 0x17).yi(EAST);
586 at40k.cell(0x03, 0x17).ylut((byte)0x55);
587 at40k.cell(0x03, 0x17).yo(true);
589 at40k.cell(0x03, 0x17).f(false);
590 at40k.cell(0x03, 0x17).c(XLUT);
591 at40k.cell(0x03, 0x17).oe(NONE);
592 at40k.cell(0x03, 0x17).out(L0, true);
594 at40k.cell(0x02, 0x17).yi(EAST);
595 at40k.cell(0x02, 0x17).ylut((byte)0x55);
596 at40k.cell(0x02, 0x17).yo(false);
598 at40k.cell(0x01, 0x17).yi(EAST);
599 at40k.cell(0x01, 0x17).ylut((byte)0x55);
600 at40k.cell(0x01, 0x17).yo(false);
602 at40k.cell(0x01, 0x17).h(L0, true);
603 at40k.cell(0x01, 0x17).v(L0, false);
605 //at40k.cell(0x01, 0x17).yi(L0);
606 //at40k.cell(0x01, 0x17).xi(L0);
607 //at40k.cell(0x01, 0x17).ylut((byte)0x33);
610 at40k.cell(0x03, 0x17).h(L0, true);
611 at40k.cell(0x03, 0x17).out(L0, true);
612 at40k.cell(0x03, 0x17).c(XLUT);
613 at40k.cell(0x03, 0x17).f(false);
616 at40k.cell(0x01, 0x17).xin(4);
617 at40k.cell(0x01, 0x17).yin(4);
618 at40k.cell(0x01, 0x16).ylut((byte)0x00);
619 device.mode4(2, 0x17, 0x01, 0);
621 for(int i=0; i<10; i++) {
623 System.out.println("tick");
624 //at40k.cell(0x01, 0x17).xlut((byte)0xFF);
625 at40k.cell(0x00, 0x17).ylut((byte)0x00);
628 System.out.println("tick");
629 //at40k.cell(0x01, 0x17).xlut((byte)0x00);
630 at40k.cell(0x00, 0x17).ylut((byte)0xFF);
637 at40k.iob_top(0, true).output(0);
638 at40k.iob_top(0, true).oe(false);
639 at40k.iob_top(0, true).pullup();
643 Log.info(Demo.class, "issuing command");
644 at40k.iob_top(1, true).pulldown();
647 Log.info(Demo.class, "done");
649 } catch (Exception e) { e.printStackTrace(); }
653 public static void copy(Fpslic.Cell c, int xdir, int ydir) {
655 case NW: case NE: case SW: case SE: {
660 case NORTH: case SOUTH: case EAST: case WEST: {
666 default: throw new Error();
669 case NW: case NE: case SW: case SE: {
674 case NORTH: case SOUTH: case EAST: case WEST: {
680 default: throw new Error();
685 public static String hex(int x) {
686 return Long.toString(x & 0xffffffffL, 16);
689 public static void handshaker(Fpslic.Cell cell) {
694 cell.t(false, false, true);
698 private static String pad(int i, String s) { if (s.length()>i) return s; return "0"+pad((i-1),s); }
699 public static String bin8(byte b) {
702 for(int i=7; i>=0; i--)
703 ret += (n & (1<<i))==0 ? "0" : "1";
707 public static void bounce(Fpslic.Cell cell, int xi, int yi) {
708 cell.xlut((byte)0xCC);
709 cell.ylut((byte)0xCC);
715 public static void muller(Fpslic.Cell cell, int xi, int yi) {
719 cell.t(false, false, true);
726 /** watches for a rising/falling edge on Yin, emits a pulse on Xout */
727 public static void pulse_detect(Fpslic.Cell c, int in, boolean falling) {
731 case NW: case NE: case SW: case SE: {
734 if (!falling) c.ylut(FpslicUtil.lutSwap(0x0C)); /* x & !z */
735 else c.ylut(FpslicUtil.lutSwap(0x30)); /* !x & z */
739 case NORTH: case SOUTH: case EAST: case WEST: {
742 if (!falling) c.xlut(0x0C); /* y & !z */
743 else c.xlut(0x30); /* !y & z */
747 default: throw new Error();
751 /** watches for a pulse on Xin, copies value of Yin */
752 public static void pulse_copy(Fpslic.Cell cell, int xi, int yi, boolean invert) {
753 loopback(cell, YLUT);
754 if (!invert) cell.ylut(0xB8); /* yo = x ? yi : z => 1011 1000 */
755 else cell.ylut(0x74); /* yo = x ? !yi : z => 0111 0100 */
756 if (!invert) cell.xlut(FpslicUtil.lutSwap(0xB8)); /* yo = x ? yi : z => 1011 1000 */
757 else cell.xlut(FpslicUtil.lutSwap(0x74)); /* yo = x ? !yi : z => 0111 0100 */
762 public static void loopback(Fpslic.Cell cell, int cin) {
765 cell.t(false, false, true);
771 public static void doit(Fpslic at40k, FtdiBoard device) throws Exception {
773 Fpslic.Cell led = at40k.cell(1, 23);
781 Fpslic.Cell c = at40k.cell(1, 22);
789 c.v(L0, /*false*/true);
796 for(int i=0; i<4; i++) at40k.cell(i, 20).h(L0, false);
797 Fpslic.Cell z = at40k.cell(1, 20);
808 z.hwire(L0).east().drives(z.hwire(L0), false);
809 z.hwire(L1).east().drives(z.hwire(L1), false);
810 z.vwire(L0).south().drives(z.vwire(L0), false);
811 z.vwire(L1).south().drives(z.vwire(L1), false);
814 z = at40k.cell(0, 20);
832 for(int y=20; y<=22; y++)
833 for(int x=2; x<=5; x++) {
834 c = at40k.cell(x, y);
838 //c = at40k.cell(2, 22);
842 c = at40k.cell(1, 21);
856 c = at40k.cell(13, 22);
857 c.xlut(LUT_OTHER | 0xF0);
859 c.t(false, false, true);
866 // this gate detects a rising edge on its Xin (delayed copy on Yin); when viewed, it inverts its state
867 c = at40k.cell(14, 22);
872 c.t(false, false, true);
877 c.ylut(0xA6); // (x & !z) ? ~y : y
880 c = at40k.cell(14, 20);
883 c = at40k.cell(14, 21);
887 c = at40k.cell(13, 22);
889 c.xlut(LUT_OTHER);// | 0xF0);
891 //c = at40k.cell(13, 22);
898 c.t(false, false, true);
903 c.ylut(0x54); // (x || z) & !y
907 c = at40k.cell(2, 21);
912 c.t(false, false, true);
919 //at40k.cell(2, 21).xlut(0xF0);
921 at40k.cell(3, 22).ylut(LUT_OTHER);
922 at40k.cell(3, 22).xi(SW);
924 //at40k.iob_top(5, true).enableOutput(SOUTH);
925 //at40k.iob_top(5, false).enableOutput(SE);
928 public static int yofs = mullers ? 19 : 22;
929 public static void counter(Fpslic at40k, FtdiBoard device) throws Exception {
930 // watch for rising edge from south, emit pulse on Xout (to NE)
931 //copy(at40k.cell(16,23), SW, WEST);
933 for(int x=22; x>=1; x-=2) {
934 pulse_detect(at40k.cell(x, yofs), SE, false);
935 pulse_detect(at40k.cell(x, yofs-1), EAST, true);
936 pulse_copy(at40k.cell(x-1, yofs), SE, SOUTH, false);
937 pulse_copy(at40k.cell(x-1, yofs-1), NE, NORTH, true);
939 //pulse_detect(at40k.cell(15, 22), NORTH, false);
940 //pulse_detect(at40k.cell(16, 22), NW, true);
941 //pulse_copy(at40k.cell(16, 21), NW, WEST, false);
942 //pulse_copy(at40k.cell(15, 21), NE, EAST, true);
944 for(int x=23; x>1; x-=2) {
945 pulse_detect(at40k.cell(x-1, yofs-2), SW, false);
946 pulse_detect(at40k.cell(x-1, yofs-3), WEST, true);
947 pulse_copy(at40k.cell(x, yofs-2), SW, SOUTH, false);
948 pulse_copy(at40k.cell(x, yofs-3), NW, NORTH, true);
950 //pulse_detect(at40k.cell(15, 22), NORTH, false);
951 //pulse_detect(at40k.cell(16, 22), NW, true);
952 //pulse_copy(at40k.cell(16, 21), NW, WEST, false);
953 //pulse_copy(at40k.cell(15, 21), NE, EAST, true);
955 copy(at40k.cell(1, yofs-2), SOUTH, SOUTH);
956 copy(at40k.cell(1, yofs-3), NORTH, NORTH);
957 at40k.cell(1, yofs-3).ylut(~at40k.cell(1, yofs-3).ylut());
958 at40k.cell(1, yofs-3).xlut(~at40k.cell(1, yofs-3).xlut());
960 copy(at40k.cell(23, yofs), SOUTH, SOUTH);
961 copy(at40k.cell(23, yofs-1), SOUTH, SOUTH);
963 for(int i=23; i>yofs; i--) copy(at40k.cell(1, i), SOUTH, SOUTH);
965 //at40k.iob_top(1, true).slew(SLOW);
966 //at40k.iob_top(1, false).slew(SLOW);
970 public static void fill(Fpslic at40k, FtdiBoard device, int num) throws Exception {
971 //muller(at40k.cell(PIPELEN,22), NE, WEST);
972 Fpslic.Cell a = at40k.cell(10,22);
973 Fpslic.Cell b = at40k.cell(11,22);
975 for(int i=0; i<num; i++) {
976 //System.out.println(i);
979 try { Thread.sleep(1); } catch (Exception e) { }
982 try { Thread.sleep(1); } catch (Exception e) { }
988 public static void drain(Fpslic at40k, FtdiBoard device) throws Exception {
989 Fpslic.Cell a = at40k.cell(10,22);
990 Fpslic.Cell b = at40k.cell(11,22);
993 for(int i=0; i<30; i++) {
994 //System.out.println(i);
997 try { Thread.sleep(1); } catch (Exception e) { }
1000 try { Thread.sleep(1); } catch (Exception e) { }
1006 public static void doitx(Fpslic at40k, FtdiBoard device) throws Exception {
1007 for(int i=5; i<PIPELEN+1; i++) bounce(at40k.cell(i, 23), SE, SOUTH);
1008 for(int x=5; x<PIPELEN; x++) muller(at40k.cell(x, 22), x==PIPELEN-1 ? SE : NE, WEST);
1010 bounce(at40k.cell(PIPELEN, 21), NW, WEST);
1012 for(int x=5; x<PIPELEN; x++) muller(at40k.cell(x, 21), SW, x==PIPELEN-1 ? NORTH : EAST);
1013 for(int x=4; x<PIPELEN+1; x++) bounce(at40k.cell(x, 20), NW, NORTH);
1015 bounce(at40k.cell(4, 22), SE, EAST);
1016 //muller(at40k.cell(4PIPELEN-1,21), SW, NORTH);
1018 //muller(at40k.cell(4,22), NE, WEST);
1019 //at40k.cell(4,22).ylut(0xEE);
1020 muller(at40k.cell(5, 22), NE, SOUTH);
1021 muller(at40k.cell(5, 21), NW, EAST);
1023 for(int x=4; x>=0; x--) {
1024 at40k.cell(x, 21).ylut(0xAA);
1025 at40k.cell(x, 21).yi(EAST);
1026 at40k.cell(x, 21).yo(false);
1029 at40k.cell(0, 22).ylut(0xAA);
1030 at40k.cell(0, 22).yi(SOUTH);
1031 at40k.cell(0, 22).yo(false);
1033 at40k.cell(0, 23).ylut(~0xAA);
1034 at40k.cell(0, 23).xlut(~0xcc);
1035 at40k.cell(0, 23).yi(SOUTH);
1036 at40k.cell(0, 23).yo(false);
1038 for(int x=3; x<=23; x+=2) {
1039 pulse_detect(at40k.cell(x-1, 19), SW, false);
1040 pulse_detect(at40k.cell(x-1, 18), WEST, true);
1041 pulse_copy(at40k.cell(x, 19), SW, SOUTH, false);
1042 pulse_copy(at40k.cell(x, 18), NW, NORTH, true);
1045 pulse_detect(at40k.cell(x-1, 16), SW, false);
1046 pulse_detect(at40k.cell(x-1, 15), WEST, true);
1047 pulse_copy(at40k.cell(x, 16), SW, SOUTH, false);
1048 pulse_copy(at40k.cell(x, 15), NW, NORTH, true);
1050 //pulse_detect(at40k.cell(15, 22), NORTH, false);
1051 //pulse_detect(at40k.cell(16, 22), NW, true);
1052 //pulse_copy(at40k.cell(16, 21), NW, WEST, false);
1053 //pulse_copy(at40k.cell(15, 21), NE, EAST, true);
1055 for(int x=14; x>=1; x--)
1056 copy(at40k.cell(x, 17), EAST, EAST);
1057 for(int x=4; x>=0; x--)
1058 copy(at40k.cell(x, 21), EAST, EAST);
1059 copy(at40k.cell(13, 17), SOUTH, SOUTH);
1061 copy(at40k.cell(0, 20), NORTH, NORTH);
1062 copy(at40k.cell(0, 19), NORTH, NORTH);
1063 copy(at40k.cell(0, 18), NORTH, NORTH);
1064 copy(at40k.cell(0, 17), NORTH, NORTH);
1065 copy(at40k.cell(0, 16), NORTH, NORTH);
1066 copy(at40k.cell(1, 16), WEST, WEST);
1067 copy(at40k.cell(1, 15), NORTH, NORTH);
1069 copy(at40k.cell(1, 20), SOUTH, SOUTH);
1070 copy(at40k.cell(1, 19), SOUTH, SOUTH);
1071 copy(at40k.cell(1, 18), SOUTH, SOUTH);
1073 for(int y=20; y<=23; y++)
1074 copy(at40k.cell(23, y), SOUTH, SOUTH);
1077 //for(int x=19; x<=23; x++)
1078 //copy(at40k.cell(x, 0), WEST, WEST);
1079 //copy(at40k.cell(18, 19), NW, NW);
1080 //at40k.iob_top(5, true).enableOutput(SOUTH);
1081 //at40k.iob_top(5, false).enableOutput(SOUTH);