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;
22 public static void main(String[] s) throws Exception {
23 FtdiBoard device = new FtdiBoard();
24 Fpslic at40k = device;
26 long begin = System.currentTimeMillis();
27 FpslicUtil.readMode4(new ProgressInputStream("configuring fabric", System.in, 111740), device);
28 long end = System.currentTimeMillis();
29 Log.info(Demo.class, "finished in " + ((end-begin)/1000) + "s");
31 Log.info(Demo.class, "issuing command");
33 //at40k.iob_top(2, true).oe(false);
34 //at40k.iob_top(2, false).oe(false);
35 //at40k.iob_top(1, true).oe(false);
37 // this command confirmed to turn *on* led0
38 //at40k.iob_top(1, false).output(0);
40 for(int i=0; i<20; i++) {
41 at40k.iob_bot(i, false).output(0);
42 at40k.iob_bot(i, true).output(0);
46 //System.out.println("tick");
48 //System.out.println("tick");
49 //at40k.cell(0x01, 0x17).xlut((byte)0x);
52 System.out.println(Integer.toString(0xff & at40k.cell(0x01, 0x17).xlut(), 16));
53 System.out.println(Integer.toString(0xff & at40k.cell(0x01, 0x17).ylut(), 16));
54 at40k.cell(0x01, 0x17).ylut((byte)0xff);
57 //at40k.cell(0x01, 0x17).wi(L1);
59 System.out.println("a: " + at40k.new SectorWire(true, 0, 4, 0x17).driverRight());
60 System.out.println("b: " + at40k.new SectorWire(true, 1, 4, 0x17).driverRight());
61 Fpslic.SectorWire h0p0 = at40k.new SectorWire(true, 0, 0, 0x17);
62 Fpslic.SectorWire h0p1 = at40k.new SectorWire(true, 1, 0, 0x17);
63 Fpslic.SectorWire h0p2 = at40k.new SectorWire(true, 2, 0, 0x17);
64 Fpslic.SectorWire h4p0 = at40k.new SectorWire(true, 0, 4, 0x17);
65 Fpslic.SectorWire h4p1 = at40k.new SectorWire(true, 1, 4, 0x17);
66 Fpslic.SectorWire h4p2 = at40k.new SectorWire(true, 2, 4, 0x17);
68 //h4p1.drives(h0p1, false);
69 //at40k.cell(0x04, 0x17).out(L1, false);
70 //at40k.cell(0x04, 0x17).h(L0, false);
72 for(int plane=0; plane<5; plane++) {
73 at40k.new SectorWire(true, plane, 4, 0x17).drives(at40k.new SectorWire(true, plane, 0, 0x17), false);
74 at40k.cell(0x04, 0x17).out(plane, false);
75 at40k.cell(0x04, 0x17).h(plane, false);
76 at40k.cell(0x01, 0x17).h(plane, false);
78 try { Thread.sleep(2000); } catch (Exception e) { }
81 at40k.new SectorWire(true, plane, 4, 0x17).drives(at40k.new SectorWire(true, plane, 0, 0x17), true);
82 at40k.cell(0x04, 0x17).out(plane, true);
83 at40k.cell(0x04, 0x17).h(plane, true);
84 at40k.cell(0x01, 0x17).h(plane, true);
85 at40k.cell(0x01, 0x17).wi(plane);
90 System.out.println("xlut is " + hex(at40k.cell(0x04, 0x17).xlut()));
91 System.out.println("ylut is " + hex(at40k.cell(0x04, 0x17).ylut()));
92 Fpslic.Cell cell = at40k.cell(0x04, 0x17);
95 System.out.println(cell.c());
102 //cell.t(false, false, true);
103 cell.t(false, true, false);
114 for(int i=3; i>=1; i--) {
115 at40k.cell(i, 0x17).yi(EAST);
116 at40k.cell(i, 0x17).ylut(0x55);
117 at40k.cell(i, 0x17).yo(false);
121 //System.out.println("reading port status: " + Integer.toString(device.readBus() & 0xff, 16));
126 at40k.cell(23, 8).ylut(0xff);
127 at40k.cell(23, 11).ylut(0xff);
128 at40k.iob_right(8, true).enableOutput();
129 at40k.iob_right(11, true).enableOutput();
131 //for(int x=4; x<=22; x++) swap(at40k.cell(x, 22), NW, NORTH);
134 // entry cell: just copy X->X Y->Y
135 //at40k.cell(4,23).b(false);
136 //at40k.cell(4,23).yo(false);
137 //at40k.cell(4,23).ylut(at40k.cell(4,23).xlut());
138 //at40k.cell(4,23).xo(false);
140 at40k.cell(4,23).xlut(0x55);
141 at40k.cell(4,23).ylut(0x55);
144 at40k.cell(4,23).xlut(0x71);
145 at40k.cell(4,23).ylut(0x44);
146 at40k.cell(4,23).c(YLUT);
147 at40k.cell(4,23).f(false);
148 at40k.cell(4,23).t(false, false, true);
151 //for(int x=6; x<=23; x++) copy(at40k.cell(x, 23), NW, WEST); // top row copies to the right
153 copy(at40k.cell(5, 22), NW, NORTH);
154 for(int x=6; x<=22; x++) copy(at40k.cell(x, 22), NW, WEST); // second top row copies to the right
155 //for(int y=22; y>=10; y--) copy(at40k.cell(23, y), NW, NORTH); // right edge copies down
156 for(int y=21; y>=9; y--) copy(at40k.cell(22, y), NW, NORTH); // second right edge copies down
157 copy(at40k.cell(23, 9), NW, WEST); // second output
160 handshaker(at40k.cell(4,23));
161 at40k.cell(4,23).xi(NW);
162 at40k.cell(4,23).yi(SOUTH);
164 //handshaker(at40k.cell(5,23));
165 //at40k.cell(5,23).yi(NORTH);
167 at40k.cell(5,23).yi(NORTH);
168 at40k.cell(5,23).xlut(0x55);
169 at40k.cell(5,23).xi(SW);
170 at40k.cell(5,23).ylut(0x55);
171 at40k.cell(5,22).yi(NORTH);
172 at40k.cell(5,22).xlut(0x55);
174 bounce(at40k.cell(4,22));
176 // cell southeast of entry cell
177 at40k.cell(3,22).xi(NE); // NW->xin
178 at40k.cell(3,22).ylut(0x33); // xin->y
179 at40k.cell(3,22).yo(false); // y->yout
180 copy(at40k.cell(3, 21), NW, NORTH); // second top row copies to the right
181 copy(at40k.cell(4, 21), NW, EAST); // second top row copies to the right
182 copy(at40k.cell(5, 21), NW, EAST); // second top row copies to the right
183 copy(at40k.cell(6, 21), NW, EAST); // second top row copies to the right
184 copy(at40k.cell(6, 22), NW, SOUTH); // second top row copies to the right
187 at40k.cell(05,22).xlut(0xff);
188 at40k.cell(05,22).ylut(0xff);
189 at40k.cell(05,22).c(XLUT);
190 at40k.cell(05,22).f(false);
191 at40k.cell(05,22).b(false);
192 at40k.cell(05,22).oe(NONE);
193 at40k.cell(05,22).v(L3, true);
194 at40k.cell(05,22).out(L3, true);
197 at40k.cell(4,23).ylut(~0xCC);
198 at40k.cell(4,23).xlut(~0xAA);
199 at40k.cell(5,23).ylut(~0xAA);
200 at40k.cell(5,23).xlut(~0xAA);
201 for(int i=6; i<PIPELEN+2; i++) {
202 at40k.cell(i, 23).ylut(0xAA);
203 at40k.cell(i, 23).xlut(0xCC);
204 at40k.cell(i, 23).yi(WEST);
209 System.out.println("doit");
210 if (mullers) doitx(at40k, device);
211 //System.out.println("counter");
212 //counter(at40k, device);
214 at40k.cell(21,15).yi(WEST);
215 at40k.cell(21,15).ylut(0xAA);
217 at40k.cell(22,15).yi(WEST);
218 at40k.cell(22,15).ylut(0xAA);
220 at40k.cell(23,15).h(3, true);
221 at40k.cell(23,15).yi(L3);
222 at40k.cell(23,15).ylut(0xAA);
223 at40k.iob_right(15, true).enableOutput(WEST);
226 Fpslic.Cell c = at40k.cell(10,10);
233 copy(c.west(), EAST, NW);
234 copy(c.west().north().west(), SE, SE);
243 copy(c.east(), WEST, SE);
244 copy(c.east().south().east(), NW, NW);
247 copy(c.north(), SOUTH, SOUTH);
248 c.xlut((LUT_SELF & ~LUT_OTHER) | LUT_Z);
262 copy(c.north(), SOUTH, SOUTH);
263 c.xlut((LUT_SELF & ~LUT_OTHER) | LUT_Z);
284 c.hwire(L4).west().drives(c.hwire(L4), false);
285 c.hwire(L4).east().drives(c.hwire(L4), false);
296 c.hwire(L4).west().drives(c.hwire(L4), false);
297 c.hwire(L4).east().drives(c.hwire(L4), false);
301 copy(c.south(), NORTH, NORTH);
302 c.xlut(((~LUT_SELF) & (~LUT_OTHER)) | LUT_Z);
316 copy(c.south(), NORTH, NORTH);
317 c.xlut((LUT_SELF & LUT_OTHER) | LUT_Z);
331 // catch a rising transition
342 c.hwire(L2).west().drives(c.hwire(L2), false);
343 c.hwire(L2).east().drives(c.hwire(L2), false);
349 c = at40k.cell(20,20);
359 c = at40k.cell(21,20);
390 at40k.cell(9,10).xo(true);
391 at40k.cell(9,10).yo(true);
392 at40k.cell(9,10).c(YLUT);
393 at40k.cell(9,10).b(false);
395 //for(int x=5; x<PIPELEN; x++) {
396 //at40k.cell(x,23).hwire(L0).drives(at40k.cell(x,23).hwire(L0).east());
400 at40k.cell(22,11).ylut(0xff);
401 at40k.cell(23,11).yi(L3);
402 //at40k.cell(23,11).yi(WEST);
403 //at40k.cell(23,11).xi(L1);
404 at40k.cell(23,11).ylut(0xAA);
405 at40k.iob_right(11, true).enableOutput(WEST);
406 at40k.cell(23,11).v(L3, true);
407 at40k.cell(23,11).yo(false);
413 System.out.println("correct: " + at40k.cell(19,15).hwire(L3) + " drives " + at40k.cell(20,15).hwire(L3));
414 System.out.println("correct: " + at40k.cell(15,15).hwire(L3) + " drives " + at40k.cell(19,15).hwire(L3));
415 System.out.println("correct: " + at40k.cell(11,15).hwire(L3) + " drives " + at40k.cell(15,15).hwire(L3));
416 System.out.println("correct: " + at40k.cell(07,15).hwire(L3) + " drives " + at40k.cell(11,15).hwire(L3));
418 at40k.cell(19,15).hwire(L3).drives(at40k.cell(20,15).hwire(L3), true);
419 at40k.cell(15,15).hwire(L3).drives(at40k.cell(19,15).hwire(L3), true);
420 at40k.cell(11,15).hwire(L3).drives(at40k.cell(15,15).hwire(L3), true);
421 at40k.cell(07,15).hwire(L3).drives(at40k.cell(11,15).hwire(L3), true);
423 //at40k.cell(05,vv).xlut(0xff);
424 //at40k.cell(05,vv).ylut(0xff);
426 at40k.cell(vx,vv).c(YLUT);
427 at40k.cell(vx,vv).f(false);
428 at40k.cell(vx,vv).b(false);
429 at40k.cell(vx,vv).oe(NONE);
430 at40k.cell(vx,vv).v(L3, true);
431 at40k.cell(vx,vv).out(L3, true);
434 at40k.cell(vx,15).v(L3, true);
435 at40k.cell(vx,15).h(L3, true);
436 at40k.cell(vx,19).vwire(L3).drives(at40k.cell(vx,15).vwire(L3), true);
437 at40k.cell(vx,23).vwire(L3).drives(at40k.cell(vx,19).vwire(L3), true);
440 //at40k.cell(5,23).ylut(0x00);
441 //at40k.cell(6,22).ylut(0xff);
442 //at40k.cell(22,11).ylut(0xff);
444 Fpslic.Cell cell = at40k.cell(4, 16);
455 //scan(at40k, cell, YLUT, true);
456 //scan(at40k, cell, YLUT, false);
458 //device.scanFPGA(true);
460 at40k.cell(10,10).f(true);
461 at40k.cell(10,10).c(ZMUX);
463 at40k.cell(8,7).xlut(LUT_SELF);
464 at40k.cell(8,7).xi(NW);
466 at40k.cell(7,8).xlut(LUT_SELF & LUT_Z);
467 at40k.cell(7,8).xi(SE);
468 at40k.cell(7,8).c(XLUT);
469 at40k.cell(7,8).f(false);
470 at40k.cell(7,8).b(false);
471 at40k.cell(7,8).t(TMUX_FB);
472 at40k.cell(7,8).xo(false);
473 System.out.println(at40k.cell(7,8).fb_relevant());
475 at40k.cell(6,13).xi(SE);
476 at40k.cell(6,13).c(ZMUX);
477 at40k.cell(6,13).xlut(LUT_SELF);
478 at40k.cell(6,13).ylut(LUT_OTHER);
479 at40k.cell(6,13).xo(false);
480 at40k.cell(6,13).yo(false);
481 at40k.cell(7,12).xi(SE);
483 for(int i=0; i<24; i++) {
484 at40k.iob_bot(i, true).enableOutput(NORTH);
485 at40k.iob_bot(i, false).enableOutput(NW);
486 at40k.cell(i, 0).xlut(0xff);
487 at40k.cell(i, 0).ylut(0xff);
492 Gui vis = new Gui(at40k, device);
493 Frame fr = new Frame();
494 fr.addKeyListener(vis);
495 fr.setLayout(new BorderLayout());
496 fr.add(vis, BorderLayout.CENTER);
498 fr.setSize(900, 900);
502 synchronized(Demo.class) { Demo.class.wait(); }
507 Visualizer v = new Visualizer(at40k, device);
509 v.setSize(1380, 1080);
510 Fpslic.Cell cell = at40k.cell(4, 23);
512 //Image img = v.createImage(v.getWidth(), v.getHeight());
516 cell = at40k.cell(x,y);
517 scan(at40k, cell, YLUT, true);
527 //selfTest(device, at40k, v);
528 //System.out.println("save: " + FtdiBoard.save + " of " + (FtdiBoard.saveof*5));
530 at40k.iob_top(0, true).enableInput();
531 copy(at40k.cell(0, 23), NORTH, NORTH);
532 at40k.iob_bot(0, true).enableOutput(NORTH);
534 for(int i=0; i<10000; i++) {
536 try { Thread.sleep(100); } catch (Exception e) { }
540 //at40k.cell(0x01, 0x17).h(0, false);
541 //at40k.cell(0x01, 0x17).xi(NE);
542 //at40k.cell(0x01, 0x17).ylut((byte)0x55);
544 //at40k.cell(0x04, 0x17).xlut((byte)0x10);
545 //at40k.cell(0x04, 0x17).ylut((byte)0x10);
546 //at40k.cell(0x04, 0x17).yo(false);
547 //at40k.cell(0x04, 0x17).xo();
550 at40k.cell(0x01, 0x17).xi(L0);
551 at40k.cell(0x01, 0x17).h(L0, true);
554 at40k.cell(0x03, 0x17).xlut((byte)0x55);
555 at40k.cell(0x03, 0x17).ylut((byte)0x55);
556 at40k.cell(0x03, 0x17).yi(EAST);
557 at40k.cell(0x03, 0x17).ylut((byte)0x55);
558 at40k.cell(0x03, 0x17).yo(true);
560 at40k.cell(0x03, 0x17).f(false);
561 at40k.cell(0x03, 0x17).c(XLUT);
562 at40k.cell(0x03, 0x17).oe(NONE);
563 at40k.cell(0x03, 0x17).out(L0, true);
565 at40k.cell(0x02, 0x17).yi(EAST);
566 at40k.cell(0x02, 0x17).ylut((byte)0x55);
567 at40k.cell(0x02, 0x17).yo(false);
569 at40k.cell(0x01, 0x17).yi(EAST);
570 at40k.cell(0x01, 0x17).ylut((byte)0x55);
571 at40k.cell(0x01, 0x17).yo(false);
573 at40k.cell(0x01, 0x17).h(L0, true);
574 at40k.cell(0x01, 0x17).v(L0, false);
576 //at40k.cell(0x01, 0x17).yi(L0);
577 //at40k.cell(0x01, 0x17).xi(L0);
578 //at40k.cell(0x01, 0x17).ylut((byte)0x33);
581 at40k.cell(0x03, 0x17).h(L0, true);
582 at40k.cell(0x03, 0x17).out(L0, true);
583 at40k.cell(0x03, 0x17).c(XLUT);
584 at40k.cell(0x03, 0x17).f(false);
587 at40k.cell(0x01, 0x17).xin(4);
588 at40k.cell(0x01, 0x17).yin(4);
589 at40k.cell(0x01, 0x16).ylut((byte)0x00);
590 device.mode4(2, 0x17, 0x01, 0);
592 for(int i=0; i<10; i++) {
594 System.out.println("tick");
595 //at40k.cell(0x01, 0x17).xlut((byte)0xFF);
596 at40k.cell(0x00, 0x17).ylut((byte)0x00);
599 System.out.println("tick");
600 //at40k.cell(0x01, 0x17).xlut((byte)0x00);
601 at40k.cell(0x00, 0x17).ylut((byte)0xFF);
608 at40k.iob_top(0, true).output(0);
609 at40k.iob_top(0, true).oe(false);
610 at40k.iob_top(0, true).pullup();
614 Log.info(Demo.class, "issuing command");
615 at40k.iob_top(1, true).pulldown();
618 Log.info(Demo.class, "done");
620 } catch (Exception e) { e.printStackTrace(); }
623 public static void scan(Fpslic dev, Fpslic.Cell cell, int source, boolean setup) {
625 if (source != NONE) cell.c(source);
626 if (cell.b()) cell.b(false);
627 if (cell.f()) cell.f(false);
629 if (cell.out(L3)!=setup) cell.out(L3, setup);
630 if (cell.vx(L3)!=setup) cell.v(L3, setup);
632 Fpslic.SectorWire sw = cell.vwire(L3);
633 //System.out.println("wire is: " + sw);
635 if (sw.row > (12 & ~0x3) && sw.north()!=null && sw.north().drives(sw))
636 sw.north().drives(sw, false);
637 while(sw.row > (12 & ~0x3) && sw.south() != null) {
638 //System.out.println(sw + " -> " + sw.south());
639 if (sw.drives(sw.south())!=setup) sw.drives(sw.south(), setup);
642 if (sw.row < (12 & ~0x3) && sw.south() != null && sw.south().drives(sw))
643 sw.north().drives(sw, false);
644 while(sw.row < (12 & ~0x3) && sw.north() != null) {
645 //System.out.println(sw + " -> " + sw.north());
646 if (sw.drives(sw.north())!=setup) sw.drives(sw.north(), setup);
650 //cell = dev.cell(19, 15);
651 cell = dev.cell(cell.col, 15);
653 System.out.println("cell is " + cell);
662 if (cell.hx(L3) != setup) cell.h(L3, setup);
663 if (cell.vx(L3) != setup) cell.v(L3, setup);
666 if (sw.west()!=null && sw.west().drives(sw)) { sw.west().drives(sw, false); }
667 while(sw.east() != null) {
668 //System.out.println(sw + " -> " + sw.east());
669 if (sw.drives(sw.east())!=setup) sw.drives(sw.east(), setup);
675 public static void copy(Fpslic.Cell c, int xdir, int ydir) {
677 case NW: case NE: case SW: case SE: {
682 case NORTH: case SOUTH: case EAST: case WEST: {
688 default: throw new Error();
691 case NW: case NE: case SW: case SE: {
696 case NORTH: case SOUTH: case EAST: case WEST: {
702 default: throw new Error();
707 public static String hex(int x) {
708 return Long.toString(x & 0xffffffffL, 16);
711 public static void handshaker(Fpslic.Cell cell) {
716 cell.t(false, false, true);
720 private static String pad(int i, String s) { if (s.length()>i) return s; return "0"+pad((i-1),s); }
721 public static String bin8(byte b) {
724 for(int i=7; i>=0; i--)
725 ret += (n & (1<<i))==0 ? "0" : "1";
729 public static void bounce(Fpslic.Cell cell, int xi, int yi) {
730 cell.xlut((byte)0xCC);
731 cell.ylut((byte)0xCC);
737 public static void muller(Fpslic.Cell cell, int xi, int yi) {
741 cell.t(false, false, true);
748 /** watches for a rising/falling edge on Yin, emits a pulse on Xout */
749 public static void pulse_detect(Fpslic.Cell c, int in, boolean falling) {
753 case NW: case NE: case SW: case SE: {
756 if (!falling) c.ylut(FpslicUtil.lutSwap(0x0C)); /* x & !z */
757 else c.ylut(FpslicUtil.lutSwap(0x30)); /* !x & z */
761 case NORTH: case SOUTH: case EAST: case WEST: {
764 if (!falling) c.xlut(0x0C); /* y & !z */
765 else c.xlut(0x30); /* !y & z */
769 default: throw new Error();
773 /** watches for a pulse on Xin, copies value of Yin */
774 public static void pulse_copy(Fpslic.Cell cell, int xi, int yi, boolean invert) {
775 loopback(cell, YLUT);
776 if (!invert) cell.ylut(0xB8); /* yo = x ? yi : z => 1011 1000 */
777 else cell.ylut(0x74); /* yo = x ? !yi : z => 0111 0100 */
778 if (!invert) cell.xlut(FpslicUtil.lutSwap(0xB8)); /* yo = x ? yi : z => 1011 1000 */
779 else cell.xlut(FpslicUtil.lutSwap(0x74)); /* yo = x ? !yi : z => 0111 0100 */
784 public static void loopback(Fpslic.Cell cell, int cin) {
787 cell.t(false, false, true);
793 public static void doit(Fpslic at40k, FtdiBoard device) throws Exception {
795 Fpslic.Cell led = at40k.cell(1, 23);
803 Fpslic.Cell c = at40k.cell(1, 22);
811 c.v(L0, /*false*/true);
818 for(int i=0; i<4; i++) at40k.cell(i, 20).h(L0, false);
819 Fpslic.Cell z = at40k.cell(1, 20);
830 z.hwire(L0).east().drives(z.hwire(L0), false);
831 z.hwire(L1).east().drives(z.hwire(L1), false);
832 z.vwire(L0).south().drives(z.vwire(L0), false);
833 z.vwire(L1).south().drives(z.vwire(L1), false);
836 z = at40k.cell(0, 20);
854 for(int y=20; y<=22; y++)
855 for(int x=2; x<=5; x++) {
856 c = at40k.cell(x, y);
860 //c = at40k.cell(2, 22);
864 c = at40k.cell(1, 21);
878 c = at40k.cell(13, 22);
879 c.xlut(LUT_OTHER | 0xF0);
881 c.t(false, false, true);
888 // this gate detects a rising edge on its Xin (delayed copy on Yin); when viewed, it inverts its state
889 c = at40k.cell(14, 22);
894 c.t(false, false, true);
899 c.ylut(0xA6); // (x & !z) ? ~y : y
902 c = at40k.cell(14, 20);
905 c = at40k.cell(14, 21);
909 c = at40k.cell(13, 22);
911 c.xlut(LUT_OTHER);// | 0xF0);
913 //c = at40k.cell(13, 22);
920 c.t(false, false, true);
925 c.ylut(0x54); // (x || z) & !y
929 c = at40k.cell(2, 21);
934 c.t(false, false, true);
941 //at40k.cell(2, 21).xlut(0xF0);
943 at40k.cell(3, 22).ylut(LUT_OTHER);
944 at40k.cell(3, 22).xi(SW);
946 //at40k.iob_top(5, true).enableOutput(SOUTH);
947 //at40k.iob_top(5, false).enableOutput(SE);
950 public static int yofs = mullers ? 19 : 22;
951 public static void counter(Fpslic at40k, FtdiBoard device) throws Exception {
952 // watch for rising edge from south, emit pulse on Xout (to NE)
953 //copy(at40k.cell(16,23), SW, WEST);
955 for(int x=22; x>=1; x-=2) {
956 pulse_detect(at40k.cell(x, yofs), SE, false);
957 pulse_detect(at40k.cell(x, yofs-1), EAST, true);
958 pulse_copy(at40k.cell(x-1, yofs), SE, SOUTH, false);
959 pulse_copy(at40k.cell(x-1, yofs-1), NE, NORTH, true);
961 //pulse_detect(at40k.cell(15, 22), NORTH, false);
962 //pulse_detect(at40k.cell(16, 22), NW, true);
963 //pulse_copy(at40k.cell(16, 21), NW, WEST, false);
964 //pulse_copy(at40k.cell(15, 21), NE, EAST, true);
966 for(int x=23; x>1; x-=2) {
967 pulse_detect(at40k.cell(x-1, yofs-2), SW, false);
968 pulse_detect(at40k.cell(x-1, yofs-3), WEST, true);
969 pulse_copy(at40k.cell(x, yofs-2), SW, SOUTH, false);
970 pulse_copy(at40k.cell(x, yofs-3), NW, NORTH, true);
972 //pulse_detect(at40k.cell(15, 22), NORTH, false);
973 //pulse_detect(at40k.cell(16, 22), NW, true);
974 //pulse_copy(at40k.cell(16, 21), NW, WEST, false);
975 //pulse_copy(at40k.cell(15, 21), NE, EAST, true);
977 copy(at40k.cell(1, yofs-2), SOUTH, SOUTH);
978 copy(at40k.cell(1, yofs-3), NORTH, NORTH);
979 at40k.cell(1, yofs-3).ylut(~at40k.cell(1, yofs-3).ylut());
980 at40k.cell(1, yofs-3).xlut(~at40k.cell(1, yofs-3).xlut());
982 copy(at40k.cell(23, yofs), SOUTH, SOUTH);
983 copy(at40k.cell(23, yofs-1), SOUTH, SOUTH);
985 for(int i=23; i>yofs; i--) copy(at40k.cell(1, i), SOUTH, SOUTH);
987 //at40k.iob_top(1, true).slew(SLOW);
988 //at40k.iob_top(1, false).slew(SLOW);
992 public static void fill(Fpslic at40k, FtdiBoard device, int num) throws Exception {
993 //muller(at40k.cell(PIPELEN,22), NE, WEST);
994 Fpslic.Cell a = at40k.cell(10,22);
995 Fpslic.Cell b = at40k.cell(11,22);
997 for(int i=0; i<num; i++) {
998 //System.out.println(i);
1001 try { Thread.sleep(1); } catch (Exception e) { }
1004 try { Thread.sleep(1); } catch (Exception e) { }
1010 public static void drain(Fpslic at40k, FtdiBoard device) throws Exception {
1011 Fpslic.Cell a = at40k.cell(10,22);
1012 Fpslic.Cell b = at40k.cell(11,22);
1015 for(int i=0; i<30; i++) {
1016 //System.out.println(i);
1019 try { Thread.sleep(1); } catch (Exception e) { }
1022 try { Thread.sleep(1); } catch (Exception e) { }
1028 public static void doitx(Fpslic at40k, FtdiBoard device) throws Exception {
1029 for(int i=5; i<PIPELEN+1; i++) bounce(at40k.cell(i, 23), SE, SOUTH);
1030 for(int x=5; x<PIPELEN; x++) muller(at40k.cell(x, 22), x==PIPELEN-1 ? SE : NE, WEST);
1032 bounce(at40k.cell(PIPELEN, 21), NW, WEST);
1034 for(int x=5; x<PIPELEN; x++) muller(at40k.cell(x, 21), SW, x==PIPELEN-1 ? NORTH : EAST);
1035 for(int x=4; x<PIPELEN+1; x++) bounce(at40k.cell(x, 20), NW, NORTH);
1037 bounce(at40k.cell(4, 22), SE, EAST);
1038 //muller(at40k.cell(4PIPELEN-1,21), SW, NORTH);
1040 //muller(at40k.cell(4,22), NE, WEST);
1041 //at40k.cell(4,22).ylut(0xEE);
1042 muller(at40k.cell(5, 22), NE, SOUTH);
1043 muller(at40k.cell(5, 21), NW, EAST);
1045 for(int x=4; x>=0; x--) {
1046 at40k.cell(x, 21).ylut(0xAA);
1047 at40k.cell(x, 21).yi(EAST);
1048 at40k.cell(x, 21).yo(false);
1051 at40k.cell(0, 22).ylut(0xAA);
1052 at40k.cell(0, 22).yi(SOUTH);
1053 at40k.cell(0, 22).yo(false);
1055 at40k.cell(0, 23).ylut(~0xAA);
1056 at40k.cell(0, 23).xlut(~0xcc);
1057 at40k.cell(0, 23).yi(SOUTH);
1058 at40k.cell(0, 23).yo(false);
1060 for(int x=3; x<=23; x+=2) {
1061 pulse_detect(at40k.cell(x-1, 19), SW, false);
1062 pulse_detect(at40k.cell(x-1, 18), WEST, true);
1063 pulse_copy(at40k.cell(x, 19), SW, SOUTH, false);
1064 pulse_copy(at40k.cell(x, 18), NW, NORTH, true);
1067 pulse_detect(at40k.cell(x-1, 16), SW, false);
1068 pulse_detect(at40k.cell(x-1, 15), WEST, true);
1069 pulse_copy(at40k.cell(x, 16), SW, SOUTH, false);
1070 pulse_copy(at40k.cell(x, 15), NW, NORTH, true);
1072 //pulse_detect(at40k.cell(15, 22), NORTH, false);
1073 //pulse_detect(at40k.cell(16, 22), NW, true);
1074 //pulse_copy(at40k.cell(16, 21), NW, WEST, false);
1075 //pulse_copy(at40k.cell(15, 21), NE, EAST, true);
1077 for(int x=14; x>=1; x--)
1078 copy(at40k.cell(x, 17), EAST, EAST);
1079 for(int x=4; x>=0; x--)
1080 copy(at40k.cell(x, 21), EAST, EAST);
1081 copy(at40k.cell(13, 17), SOUTH, SOUTH);
1083 copy(at40k.cell(0, 20), NORTH, NORTH);
1084 copy(at40k.cell(0, 19), NORTH, NORTH);
1085 copy(at40k.cell(0, 18), NORTH, NORTH);
1086 copy(at40k.cell(0, 17), NORTH, NORTH);
1087 copy(at40k.cell(0, 16), NORTH, NORTH);
1088 copy(at40k.cell(1, 16), WEST, WEST);
1089 copy(at40k.cell(1, 15), NORTH, NORTH);
1091 copy(at40k.cell(1, 20), SOUTH, SOUTH);
1092 copy(at40k.cell(1, 19), SOUTH, SOUTH);
1093 copy(at40k.cell(1, 18), SOUTH, SOUTH);
1095 for(int y=20; y<=23; y++)
1096 copy(at40k.cell(23, y), SOUTH, SOUTH);
1099 //for(int x=19; x<=23; x++)
1100 //copy(at40k.cell(x, 0), WEST, WEST);
1101 //copy(at40k.cell(18, 19), NW, NW);
1102 //at40k.iob_top(5, true).enableOutput(SOUTH);
1103 //at40k.iob_top(5, false).enableOutput(SOUTH);