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);
221 Fpslic.Cell root = at40k.cell(10,20);
223 root.yo(root.north());
224 root.ylut(~LUT_SELF);
228 root.yo(root.east());
229 root.ylut(~LUT_SELF);
233 root.yo(root.south());
234 root.ylut(~LUT_SELF);
238 root.yo(root.west());
242 //////////////////////////////////////////////////////////////////////////////
244 at40k.cell(23,15).h(3, true);
245 at40k.cell(23,15).yi(L3);
246 at40k.cell(23,15).ylut(0xAA);
247 at40k.iob_right(15, true).enableOutput(WEST);
250 Fpslic.Cell c = at40k.cell(10,10);
257 copy(c.west(), EAST, NW);
258 copy(c.west().north().west(), SE, SE);
267 copy(c.east(), WEST, SE);
268 copy(c.east().south().east(), NW, NW);
271 copy(c.north(), SOUTH, SOUTH);
272 c.xlut((LUT_SELF & ~LUT_OTHER) | LUT_Z);
286 copy(c.north(), SOUTH, SOUTH);
287 c.xlut((LUT_SELF & ~LUT_OTHER) | LUT_Z);
308 c.hwire(L4).west().drives(c.hwire(L4), false);
309 c.hwire(L4).east().drives(c.hwire(L4), false);
320 c.hwire(L4).west().drives(c.hwire(L4), false);
321 c.hwire(L4).east().drives(c.hwire(L4), false);
325 copy(c.south(), NORTH, NORTH);
326 c.xlut(((~LUT_SELF) & (~LUT_OTHER)) | LUT_Z);
340 copy(c.south(), NORTH, NORTH);
341 c.xlut((LUT_SELF & LUT_OTHER) | LUT_Z);
355 // catch a rising transition
366 c.hwire(L2).west().drives(c.hwire(L2), false);
367 c.hwire(L2).east().drives(c.hwire(L2), false);
373 c = at40k.cell(20,20);
383 c = at40k.cell(21,20);
414 at40k.cell(9,10).xo(true);
415 at40k.cell(9,10).yo(true);
416 at40k.cell(9,10).c(YLUT);
417 at40k.cell(9,10).b(false);
419 //for(int x=5; x<PIPELEN; x++) {
420 //at40k.cell(x,23).hwire(L0).drives(at40k.cell(x,23).hwire(L0).east());
424 at40k.cell(22,11).ylut(0xff);
425 at40k.cell(23,11).yi(L3);
426 //at40k.cell(23,11).yi(WEST);
427 //at40k.cell(23,11).xi(L1);
428 at40k.cell(23,11).ylut(0xAA);
429 at40k.iob_right(11, true).enableOutput(WEST);
430 at40k.cell(23,11).v(L3, true);
431 at40k.cell(23,11).yo(false);
437 System.out.println("correct: " + at40k.cell(19,15).hwire(L3) + " drives " + at40k.cell(20,15).hwire(L3));
438 System.out.println("correct: " + at40k.cell(15,15).hwire(L3) + " drives " + at40k.cell(19,15).hwire(L3));
439 System.out.println("correct: " + at40k.cell(11,15).hwire(L3) + " drives " + at40k.cell(15,15).hwire(L3));
440 System.out.println("correct: " + at40k.cell(07,15).hwire(L3) + " drives " + at40k.cell(11,15).hwire(L3));
442 at40k.cell(19,15).hwire(L3).drives(at40k.cell(20,15).hwire(L3), true);
443 at40k.cell(15,15).hwire(L3).drives(at40k.cell(19,15).hwire(L3), true);
444 at40k.cell(11,15).hwire(L3).drives(at40k.cell(15,15).hwire(L3), true);
445 at40k.cell(07,15).hwire(L3).drives(at40k.cell(11,15).hwire(L3), true);
447 //at40k.cell(05,vv).xlut(0xff);
448 //at40k.cell(05,vv).ylut(0xff);
450 at40k.cell(vx,vv).c(YLUT);
451 at40k.cell(vx,vv).f(false);
452 at40k.cell(vx,vv).b(false);
453 at40k.cell(vx,vv).oe(NONE);
454 at40k.cell(vx,vv).v(L3, true);
455 at40k.cell(vx,vv).out(L3, true);
458 at40k.cell(vx,15).v(L3, true);
459 at40k.cell(vx,15).h(L3, true);
460 at40k.cell(vx,19).vwire(L3).drives(at40k.cell(vx,15).vwire(L3), true);
461 at40k.cell(vx,23).vwire(L3).drives(at40k.cell(vx,19).vwire(L3), true);
464 //at40k.cell(5,23).ylut(0x00);
465 //at40k.cell(6,22).ylut(0xff);
466 //at40k.cell(22,11).ylut(0xff);
468 Fpslic.Cell cell = at40k.cell(4, 16);
479 //scan(at40k, cell, YLUT, true);
480 //scan(at40k, cell, YLUT, false);
482 //device.scanFPGA(true);
484 at40k.cell(10,10).f(true);
485 at40k.cell(10,10).c(ZMUX);
487 at40k.cell(8,7).xlut(LUT_SELF);
488 at40k.cell(8,7).xi(NW);
490 at40k.cell(7,8).xlut(LUT_SELF & LUT_Z);
491 at40k.cell(7,8).xi(SE);
492 at40k.cell(7,8).c(XLUT);
493 at40k.cell(7,8).f(false);
494 at40k.cell(7,8).b(false);
495 at40k.cell(7,8).t(TMUX_FB);
496 at40k.cell(7,8).xo(false);
497 System.out.println(at40k.cell(7,8).fb_relevant());
499 at40k.cell(6,13).xi(SE);
500 at40k.cell(6,13).c(ZMUX);
501 at40k.cell(6,13).xlut(LUT_SELF);
502 at40k.cell(6,13).ylut(LUT_OTHER);
503 at40k.cell(6,13).xo(false);
504 at40k.cell(6,13).yo(false);
505 at40k.cell(7,12).xi(SE);
507 for(int i=0; i<24; i++) {
508 at40k.iob_bot(i, true).enableOutput(NORTH);
509 at40k.iob_bot(i, false).enableOutput(NW);
510 at40k.cell(i, 0).xlut(0xff);
511 at40k.cell(i, 0).ylut(0xff);
516 Gui vis = new Gui(at40k, device);
517 Frame fr = new Frame();
518 fr.addKeyListener(vis);
519 fr.setLayout(new BorderLayout());
520 fr.add(vis, BorderLayout.CENTER);
522 fr.setSize(900, 900);
526 synchronized(Demo.class) { Demo.class.wait(); }
531 Visualizer v = new Visualizer(at40k, device);
533 v.setSize(1380, 1080);
534 Fpslic.Cell cell = at40k.cell(4, 23);
536 //Image img = v.createImage(v.getWidth(), v.getHeight());
540 cell = at40k.cell(x,y);
541 scan(at40k, cell, YLUT, true);
551 //selfTest(device, at40k, v);
552 //System.out.println("save: " + FtdiBoard.save + " of " + (FtdiBoard.saveof*5));
554 at40k.iob_top(0, true).enableInput();
555 copy(at40k.cell(0, 23), NORTH, NORTH);
556 at40k.iob_bot(0, true).enableOutput(NORTH);
558 for(int i=0; i<10000; i++) {
560 try { Thread.sleep(100); } catch (Exception e) { }
564 //at40k.cell(0x01, 0x17).h(0, false);
565 //at40k.cell(0x01, 0x17).xi(NE);
566 //at40k.cell(0x01, 0x17).ylut((byte)0x55);
568 //at40k.cell(0x04, 0x17).xlut((byte)0x10);
569 //at40k.cell(0x04, 0x17).ylut((byte)0x10);
570 //at40k.cell(0x04, 0x17).yo(false);
571 //at40k.cell(0x04, 0x17).xo();
574 at40k.cell(0x01, 0x17).xi(L0);
575 at40k.cell(0x01, 0x17).h(L0, true);
578 at40k.cell(0x03, 0x17).xlut((byte)0x55);
579 at40k.cell(0x03, 0x17).ylut((byte)0x55);
580 at40k.cell(0x03, 0x17).yi(EAST);
581 at40k.cell(0x03, 0x17).ylut((byte)0x55);
582 at40k.cell(0x03, 0x17).yo(true);
584 at40k.cell(0x03, 0x17).f(false);
585 at40k.cell(0x03, 0x17).c(XLUT);
586 at40k.cell(0x03, 0x17).oe(NONE);
587 at40k.cell(0x03, 0x17).out(L0, true);
589 at40k.cell(0x02, 0x17).yi(EAST);
590 at40k.cell(0x02, 0x17).ylut((byte)0x55);
591 at40k.cell(0x02, 0x17).yo(false);
593 at40k.cell(0x01, 0x17).yi(EAST);
594 at40k.cell(0x01, 0x17).ylut((byte)0x55);
595 at40k.cell(0x01, 0x17).yo(false);
597 at40k.cell(0x01, 0x17).h(L0, true);
598 at40k.cell(0x01, 0x17).v(L0, false);
600 //at40k.cell(0x01, 0x17).yi(L0);
601 //at40k.cell(0x01, 0x17).xi(L0);
602 //at40k.cell(0x01, 0x17).ylut((byte)0x33);
605 at40k.cell(0x03, 0x17).h(L0, true);
606 at40k.cell(0x03, 0x17).out(L0, true);
607 at40k.cell(0x03, 0x17).c(XLUT);
608 at40k.cell(0x03, 0x17).f(false);
611 at40k.cell(0x01, 0x17).xin(4);
612 at40k.cell(0x01, 0x17).yin(4);
613 at40k.cell(0x01, 0x16).ylut((byte)0x00);
614 device.mode4(2, 0x17, 0x01, 0);
616 for(int i=0; i<10; i++) {
618 System.out.println("tick");
619 //at40k.cell(0x01, 0x17).xlut((byte)0xFF);
620 at40k.cell(0x00, 0x17).ylut((byte)0x00);
623 System.out.println("tick");
624 //at40k.cell(0x01, 0x17).xlut((byte)0x00);
625 at40k.cell(0x00, 0x17).ylut((byte)0xFF);
632 at40k.iob_top(0, true).output(0);
633 at40k.iob_top(0, true).oe(false);
634 at40k.iob_top(0, true).pullup();
638 Log.info(Demo.class, "issuing command");
639 at40k.iob_top(1, true).pulldown();
642 Log.info(Demo.class, "done");
644 } catch (Exception e) { e.printStackTrace(); }
647 public static void scan(Fpslic dev, Fpslic.Cell cell, int source, boolean setup) {
649 if (source != NONE) cell.c(source);
650 if (cell.b()) cell.b(false);
651 if (cell.f()) cell.f(false);
653 if (cell.out(L3)!=setup) cell.out(L3, setup);
654 if (cell.vx(L3)!=setup) cell.v(L3, setup);
656 Fpslic.SectorWire sw = cell.vwire(L3);
657 //System.out.println("wire is: " + sw);
659 if (sw.row > (12 & ~0x3) && sw.north()!=null && sw.north().drives(sw))
660 sw.north().drives(sw, false);
661 while(sw.row > (12 & ~0x3) && sw.south() != null) {
662 //System.out.println(sw + " -> " + sw.south());
663 if (sw.drives(sw.south())!=setup) sw.drives(sw.south(), setup);
666 if (sw.row < (12 & ~0x3) && sw.south() != null && sw.south().drives(sw))
667 sw.north().drives(sw, false);
668 while(sw.row < (12 & ~0x3) && sw.north() != null) {
669 //System.out.println(sw + " -> " + sw.north());
670 if (sw.drives(sw.north())!=setup) sw.drives(sw.north(), setup);
674 //cell = dev.cell(19, 15);
675 cell = dev.cell(cell.col, 15);
677 System.out.println("cell is " + cell);
686 if (cell.hx(L3) != setup) cell.h(L3, setup);
687 if (cell.vx(L3) != setup) cell.v(L3, setup);
690 if (sw.west()!=null && sw.west().drives(sw)) { sw.west().drives(sw, false); }
691 while(sw.east() != null) {
692 //System.out.println(sw + " -> " + sw.east());
693 if (sw.drives(sw.east())!=setup) sw.drives(sw.east(), setup);
699 public static void copy(Fpslic.Cell c, int xdir, int ydir) {
701 case NW: case NE: case SW: case SE: {
706 case NORTH: case SOUTH: case EAST: case WEST: {
712 default: throw new Error();
715 case NW: case NE: case SW: case SE: {
720 case NORTH: case SOUTH: case EAST: case WEST: {
726 default: throw new Error();
731 public static String hex(int x) {
732 return Long.toString(x & 0xffffffffL, 16);
735 public static void handshaker(Fpslic.Cell cell) {
740 cell.t(false, false, true);
744 private static String pad(int i, String s) { if (s.length()>i) return s; return "0"+pad((i-1),s); }
745 public static String bin8(byte b) {
748 for(int i=7; i>=0; i--)
749 ret += (n & (1<<i))==0 ? "0" : "1";
753 public static void bounce(Fpslic.Cell cell, int xi, int yi) {
754 cell.xlut((byte)0xCC);
755 cell.ylut((byte)0xCC);
761 public static void muller(Fpslic.Cell cell, int xi, int yi) {
765 cell.t(false, false, true);
772 /** watches for a rising/falling edge on Yin, emits a pulse on Xout */
773 public static void pulse_detect(Fpslic.Cell c, int in, boolean falling) {
777 case NW: case NE: case SW: case SE: {
780 if (!falling) c.ylut(FpslicUtil.lutSwap(0x0C)); /* x & !z */
781 else c.ylut(FpslicUtil.lutSwap(0x30)); /* !x & z */
785 case NORTH: case SOUTH: case EAST: case WEST: {
788 if (!falling) c.xlut(0x0C); /* y & !z */
789 else c.xlut(0x30); /* !y & z */
793 default: throw new Error();
797 /** watches for a pulse on Xin, copies value of Yin */
798 public static void pulse_copy(Fpslic.Cell cell, int xi, int yi, boolean invert) {
799 loopback(cell, YLUT);
800 if (!invert) cell.ylut(0xB8); /* yo = x ? yi : z => 1011 1000 */
801 else cell.ylut(0x74); /* yo = x ? !yi : z => 0111 0100 */
802 if (!invert) cell.xlut(FpslicUtil.lutSwap(0xB8)); /* yo = x ? yi : z => 1011 1000 */
803 else cell.xlut(FpslicUtil.lutSwap(0x74)); /* yo = x ? !yi : z => 0111 0100 */
808 public static void loopback(Fpslic.Cell cell, int cin) {
811 cell.t(false, false, true);
817 public static void doit(Fpslic at40k, FtdiBoard device) throws Exception {
819 Fpslic.Cell led = at40k.cell(1, 23);
827 Fpslic.Cell c = at40k.cell(1, 22);
835 c.v(L0, /*false*/true);
842 for(int i=0; i<4; i++) at40k.cell(i, 20).h(L0, false);
843 Fpslic.Cell z = at40k.cell(1, 20);
854 z.hwire(L0).east().drives(z.hwire(L0), false);
855 z.hwire(L1).east().drives(z.hwire(L1), false);
856 z.vwire(L0).south().drives(z.vwire(L0), false);
857 z.vwire(L1).south().drives(z.vwire(L1), false);
860 z = at40k.cell(0, 20);
878 for(int y=20; y<=22; y++)
879 for(int x=2; x<=5; x++) {
880 c = at40k.cell(x, y);
884 //c = at40k.cell(2, 22);
888 c = at40k.cell(1, 21);
902 c = at40k.cell(13, 22);
903 c.xlut(LUT_OTHER | 0xF0);
905 c.t(false, false, true);
912 // this gate detects a rising edge on its Xin (delayed copy on Yin); when viewed, it inverts its state
913 c = at40k.cell(14, 22);
918 c.t(false, false, true);
923 c.ylut(0xA6); // (x & !z) ? ~y : y
926 c = at40k.cell(14, 20);
929 c = at40k.cell(14, 21);
933 c = at40k.cell(13, 22);
935 c.xlut(LUT_OTHER);// | 0xF0);
937 //c = at40k.cell(13, 22);
944 c.t(false, false, true);
949 c.ylut(0x54); // (x || z) & !y
953 c = at40k.cell(2, 21);
958 c.t(false, false, true);
965 //at40k.cell(2, 21).xlut(0xF0);
967 at40k.cell(3, 22).ylut(LUT_OTHER);
968 at40k.cell(3, 22).xi(SW);
970 //at40k.iob_top(5, true).enableOutput(SOUTH);
971 //at40k.iob_top(5, false).enableOutput(SE);
974 public static int yofs = mullers ? 19 : 22;
975 public static void counter(Fpslic at40k, FtdiBoard device) throws Exception {
976 // watch for rising edge from south, emit pulse on Xout (to NE)
977 //copy(at40k.cell(16,23), SW, WEST);
979 for(int x=22; x>=1; x-=2) {
980 pulse_detect(at40k.cell(x, yofs), SE, false);
981 pulse_detect(at40k.cell(x, yofs-1), EAST, true);
982 pulse_copy(at40k.cell(x-1, yofs), SE, SOUTH, false);
983 pulse_copy(at40k.cell(x-1, yofs-1), NE, NORTH, true);
985 //pulse_detect(at40k.cell(15, 22), NORTH, false);
986 //pulse_detect(at40k.cell(16, 22), NW, true);
987 //pulse_copy(at40k.cell(16, 21), NW, WEST, false);
988 //pulse_copy(at40k.cell(15, 21), NE, EAST, true);
990 for(int x=23; x>1; x-=2) {
991 pulse_detect(at40k.cell(x-1, yofs-2), SW, false);
992 pulse_detect(at40k.cell(x-1, yofs-3), WEST, true);
993 pulse_copy(at40k.cell(x, yofs-2), SW, SOUTH, false);
994 pulse_copy(at40k.cell(x, yofs-3), NW, NORTH, true);
996 //pulse_detect(at40k.cell(15, 22), NORTH, false);
997 //pulse_detect(at40k.cell(16, 22), NW, true);
998 //pulse_copy(at40k.cell(16, 21), NW, WEST, false);
999 //pulse_copy(at40k.cell(15, 21), NE, EAST, true);
1001 copy(at40k.cell(1, yofs-2), SOUTH, SOUTH);
1002 copy(at40k.cell(1, yofs-3), NORTH, NORTH);
1003 at40k.cell(1, yofs-3).ylut(~at40k.cell(1, yofs-3).ylut());
1004 at40k.cell(1, yofs-3).xlut(~at40k.cell(1, yofs-3).xlut());
1006 copy(at40k.cell(23, yofs), SOUTH, SOUTH);
1007 copy(at40k.cell(23, yofs-1), SOUTH, SOUTH);
1009 for(int i=23; i>yofs; i--) copy(at40k.cell(1, i), SOUTH, SOUTH);
1011 //at40k.iob_top(1, true).slew(SLOW);
1012 //at40k.iob_top(1, false).slew(SLOW);
1016 public static void fill(Fpslic at40k, FtdiBoard device, int num) throws Exception {
1017 //muller(at40k.cell(PIPELEN,22), NE, WEST);
1018 Fpslic.Cell a = at40k.cell(10,22);
1019 Fpslic.Cell b = at40k.cell(11,22);
1021 for(int i=0; i<num; i++) {
1022 //System.out.println(i);
1025 try { Thread.sleep(1); } catch (Exception e) { }
1028 try { Thread.sleep(1); } catch (Exception e) { }
1034 public static void drain(Fpslic at40k, FtdiBoard device) throws Exception {
1035 Fpslic.Cell a = at40k.cell(10,22);
1036 Fpslic.Cell b = at40k.cell(11,22);
1039 for(int i=0; i<30; i++) {
1040 //System.out.println(i);
1043 try { Thread.sleep(1); } catch (Exception e) { }
1046 try { Thread.sleep(1); } catch (Exception e) { }
1052 public static void doitx(Fpslic at40k, FtdiBoard device) throws Exception {
1053 for(int i=5; i<PIPELEN+1; i++) bounce(at40k.cell(i, 23), SE, SOUTH);
1054 for(int x=5; x<PIPELEN; x++) muller(at40k.cell(x, 22), x==PIPELEN-1 ? SE : NE, WEST);
1056 bounce(at40k.cell(PIPELEN, 21), NW, WEST);
1058 for(int x=5; x<PIPELEN; x++) muller(at40k.cell(x, 21), SW, x==PIPELEN-1 ? NORTH : EAST);
1059 for(int x=4; x<PIPELEN+1; x++) bounce(at40k.cell(x, 20), NW, NORTH);
1061 bounce(at40k.cell(4, 22), SE, EAST);
1062 //muller(at40k.cell(4PIPELEN-1,21), SW, NORTH);
1064 //muller(at40k.cell(4,22), NE, WEST);
1065 //at40k.cell(4,22).ylut(0xEE);
1066 muller(at40k.cell(5, 22), NE, SOUTH);
1067 muller(at40k.cell(5, 21), NW, EAST);
1069 for(int x=4; x>=0; x--) {
1070 at40k.cell(x, 21).ylut(0xAA);
1071 at40k.cell(x, 21).yi(EAST);
1072 at40k.cell(x, 21).yo(false);
1075 at40k.cell(0, 22).ylut(0xAA);
1076 at40k.cell(0, 22).yi(SOUTH);
1077 at40k.cell(0, 22).yo(false);
1079 at40k.cell(0, 23).ylut(~0xAA);
1080 at40k.cell(0, 23).xlut(~0xcc);
1081 at40k.cell(0, 23).yi(SOUTH);
1082 at40k.cell(0, 23).yo(false);
1084 for(int x=3; x<=23; x+=2) {
1085 pulse_detect(at40k.cell(x-1, 19), SW, false);
1086 pulse_detect(at40k.cell(x-1, 18), WEST, true);
1087 pulse_copy(at40k.cell(x, 19), SW, SOUTH, false);
1088 pulse_copy(at40k.cell(x, 18), NW, NORTH, true);
1091 pulse_detect(at40k.cell(x-1, 16), SW, false);
1092 pulse_detect(at40k.cell(x-1, 15), WEST, true);
1093 pulse_copy(at40k.cell(x, 16), SW, SOUTH, false);
1094 pulse_copy(at40k.cell(x, 15), NW, NORTH, true);
1096 //pulse_detect(at40k.cell(15, 22), NORTH, false);
1097 //pulse_detect(at40k.cell(16, 22), NW, true);
1098 //pulse_copy(at40k.cell(16, 21), NW, WEST, false);
1099 //pulse_copy(at40k.cell(15, 21), NE, EAST, true);
1101 for(int x=14; x>=1; x--)
1102 copy(at40k.cell(x, 17), EAST, EAST);
1103 for(int x=4; x>=0; x--)
1104 copy(at40k.cell(x, 21), EAST, EAST);
1105 copy(at40k.cell(13, 17), SOUTH, SOUTH);
1107 copy(at40k.cell(0, 20), NORTH, NORTH);
1108 copy(at40k.cell(0, 19), NORTH, NORTH);
1109 copy(at40k.cell(0, 18), NORTH, NORTH);
1110 copy(at40k.cell(0, 17), NORTH, NORTH);
1111 copy(at40k.cell(0, 16), NORTH, NORTH);
1112 copy(at40k.cell(1, 16), WEST, WEST);
1113 copy(at40k.cell(1, 15), NORTH, NORTH);
1115 copy(at40k.cell(1, 20), SOUTH, SOUTH);
1116 copy(at40k.cell(1, 19), SOUTH, SOUTH);
1117 copy(at40k.cell(1, 18), SOUTH, SOUTH);
1119 for(int y=20; y<=23; y++)
1120 copy(at40k.cell(23, y), SOUTH, SOUTH);
1123 //for(int x=19; x<=23; x++)
1124 //copy(at40k.cell(x, 0), WEST, WEST);
1125 //copy(at40k.cell(18, 19), NW, NW);
1126 //at40k.iob_top(5, true).enableOutput(SOUTH);
1127 //at40k.iob_top(5, false).enableOutput(SOUTH);