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 FtdiBoard device = new FtdiBoard();
25 Fpslic at40k = device;
27 long begin = System.currentTimeMillis();
28 //FpslicUtil.readMode4(new ProgressInputStream("configuring fabric", System.in, 111740), device);
29 long end = System.currentTimeMillis();
30 Log.info(Demo.class, "finished in " + ((end-begin)/1000) + "s");
32 Log.info(Demo.class, "issuing command");
34 for(int i=0; i<24; i++) {
35 at40k.iob_bot(i, true).enableOutput(NORTH);
36 at40k.iob_bot(i, false).enableOutput(NW);
37 at40k.cell(i, 0).xlut(0xff);
38 at40k.cell(i, 0).ylut(0xff);
41 at40k.cell(23,15).h(3, true);
42 at40k.cell(23,15).yi(L3);
43 at40k.cell(23,15).ylut(0xAA);
44 at40k.iob_right(15, true).enableOutput(WEST);
48 Fpslic.Cell root = at40k.cell(10,20);
50 root.yo(root.north());
60 root.yo(root.south());
69 Gui vis = new Gui(at40k, device);
70 Frame fr = new Frame();
71 fr.addKeyListener(vis);
72 fr.setLayout(new BorderLayout());
73 fr.add(vis, BorderLayout.CENTER);
79 synchronized(Demo.class) { Demo.class.wait(); }
82 public static void mainw(String[] s) throws Exception {
83 FtdiBoard device = new FtdiBoard();
84 Fpslic at40k = device;
86 long begin = System.currentTimeMillis();
87 //FpslicUtil.readMode4(new ProgressInputStream("configuring fabric", System.in, 111740), device);
88 long end = System.currentTimeMillis();
89 Log.info(Demo.class, "finished in " + ((end-begin)/1000) + "s");
91 Log.info(Demo.class, "issuing command");
93 //at40k.iob_top(2, true).oe(false);
94 //at40k.iob_top(2, false).oe(false);
95 //at40k.iob_top(1, true).oe(false);
97 // this command confirmed to turn *on* led0
98 //at40k.iob_top(1, false).output(0);
100 for(int i=0; i<20; i++) {
101 at40k.iob_bot(i, false).output(0);
102 at40k.iob_bot(i, true).output(0);
106 //System.out.println("tick");
107 //Thread.sleep(3000);
108 //System.out.println("tick");
109 //at40k.cell(0x01, 0x17).xlut((byte)0x);
112 System.out.println(Integer.toString(0xff & at40k.cell(0x01, 0x17).xlut(), 16));
113 System.out.println(Integer.toString(0xff & at40k.cell(0x01, 0x17).ylut(), 16));
114 at40k.cell(0x01, 0x17).ylut((byte)0xff);
117 //at40k.cell(0x01, 0x17).wi(L1);
119 System.out.println("a: " + at40k.new SectorWire(true, 0, 4, 0x17).driverRight());
120 System.out.println("b: " + at40k.new SectorWire(true, 1, 4, 0x17).driverRight());
121 Fpslic.SectorWire h0p0 = at40k.new SectorWire(true, 0, 0, 0x17);
122 Fpslic.SectorWire h0p1 = at40k.new SectorWire(true, 1, 0, 0x17);
123 Fpslic.SectorWire h0p2 = at40k.new SectorWire(true, 2, 0, 0x17);
124 Fpslic.SectorWire h4p0 = at40k.new SectorWire(true, 0, 4, 0x17);
125 Fpslic.SectorWire h4p1 = at40k.new SectorWire(true, 1, 4, 0x17);
126 Fpslic.SectorWire h4p2 = at40k.new SectorWire(true, 2, 4, 0x17);
128 //h4p1.drives(h0p1, false);
129 //at40k.cell(0x04, 0x17).out(L1, false);
130 //at40k.cell(0x04, 0x17).h(L0, false);
132 for(int plane=0; plane<5; plane++) {
133 at40k.new SectorWire(true, plane, 4, 0x17).drives(at40k.new SectorWire(true, plane, 0, 0x17), false);
134 at40k.cell(0x04, 0x17).out(plane, false);
135 at40k.cell(0x04, 0x17).h(plane, false);
136 at40k.cell(0x01, 0x17).h(plane, false);
138 try { Thread.sleep(2000); } catch (Exception e) { }
141 at40k.new SectorWire(true, plane, 4, 0x17).drives(at40k.new SectorWire(true, plane, 0, 0x17), true);
142 at40k.cell(0x04, 0x17).out(plane, true);
143 at40k.cell(0x04, 0x17).h(plane, true);
144 at40k.cell(0x01, 0x17).h(plane, true);
145 at40k.cell(0x01, 0x17).wi(plane);
150 System.out.println("xlut is " + hex(at40k.cell(0x04, 0x17).xlut()));
151 System.out.println("ylut is " + hex(at40k.cell(0x04, 0x17).ylut()));
152 Fpslic.Cell cell = at40k.cell(0x04, 0x17);
155 System.out.println(cell.c());
162 //cell.t(false, false, true);
163 cell.t(false, true, false);
174 for(int i=3; i>=1; i--) {
175 at40k.cell(i, 0x17).yi(EAST);
176 at40k.cell(i, 0x17).ylut(0x55);
177 at40k.cell(i, 0x17).yo(false);
181 //System.out.println("reading port status: " + Integer.toString(device.readBus() & 0xff, 16));
186 at40k.cell(23, 8).ylut(0xff);
187 at40k.cell(23, 11).ylut(0xff);
188 at40k.iob_right(8, true).enableOutput();
189 at40k.iob_right(11, true).enableOutput();
191 //for(int x=4; x<=22; x++) swap(at40k.cell(x, 22), NW, NORTH);
194 // entry cell: just copy X->X Y->Y
195 //at40k.cell(4,23).b(false);
196 //at40k.cell(4,23).yo(false);
197 //at40k.cell(4,23).ylut(at40k.cell(4,23).xlut());
198 //at40k.cell(4,23).xo(false);
200 at40k.cell(4,23).xlut(0x55);
201 at40k.cell(4,23).ylut(0x55);
204 at40k.cell(4,23).xlut(0x71);
205 at40k.cell(4,23).ylut(0x44);
206 at40k.cell(4,23).c(YLUT);
207 at40k.cell(4,23).f(false);
208 at40k.cell(4,23).t(false, false, true);
211 //for(int x=6; x<=23; x++) copy(at40k.cell(x, 23), NW, WEST); // top row copies to the right
213 copy(at40k.cell(5, 22), NW, NORTH);
214 for(int x=6; x<=22; x++) copy(at40k.cell(x, 22), NW, WEST); // second top row copies to the right
215 //for(int y=22; y>=10; y--) copy(at40k.cell(23, y), NW, NORTH); // right edge copies down
216 for(int y=21; y>=9; y--) copy(at40k.cell(22, y), NW, NORTH); // second right edge copies down
217 copy(at40k.cell(23, 9), NW, WEST); // second output
220 handshaker(at40k.cell(4,23));
221 at40k.cell(4,23).xi(NW);
222 at40k.cell(4,23).yi(SOUTH);
224 //handshaker(at40k.cell(5,23));
225 //at40k.cell(5,23).yi(NORTH);
227 at40k.cell(5,23).yi(NORTH);
228 at40k.cell(5,23).xlut(0x55);
229 at40k.cell(5,23).xi(SW);
230 at40k.cell(5,23).ylut(0x55);
231 at40k.cell(5,22).yi(NORTH);
232 at40k.cell(5,22).xlut(0x55);
234 bounce(at40k.cell(4,22));
236 // cell southeast of entry cell
237 at40k.cell(3,22).xi(NE); // NW->xin
238 at40k.cell(3,22).ylut(0x33); // xin->y
239 at40k.cell(3,22).yo(false); // y->yout
240 copy(at40k.cell(3, 21), NW, NORTH); // second top row copies to the right
241 copy(at40k.cell(4, 21), NW, EAST); // second top row copies to the right
242 copy(at40k.cell(5, 21), NW, EAST); // second top row copies to the right
243 copy(at40k.cell(6, 21), NW, EAST); // second top row copies to the right
244 copy(at40k.cell(6, 22), NW, SOUTH); // second top row copies to the right
247 at40k.cell(05,22).xlut(0xff);
248 at40k.cell(05,22).ylut(0xff);
249 at40k.cell(05,22).c(XLUT);
250 at40k.cell(05,22).f(false);
251 at40k.cell(05,22).b(false);
252 at40k.cell(05,22).oe(NONE);
253 at40k.cell(05,22).v(L3, true);
254 at40k.cell(05,22).out(L3, true);
257 at40k.cell(4,23).ylut(~0xCC);
258 at40k.cell(4,23).xlut(~0xAA);
259 at40k.cell(5,23).ylut(~0xAA);
260 at40k.cell(5,23).xlut(~0xAA);
261 for(int i=6; i<PIPELEN+2; i++) {
262 at40k.cell(i, 23).ylut(0xAA);
263 at40k.cell(i, 23).xlut(0xCC);
264 at40k.cell(i, 23).yi(WEST);
269 System.out.println("doit");
270 if (mullers) doitx(at40k, device);
271 //System.out.println("counter");
272 //counter(at40k, device);
274 at40k.cell(21,15).yi(WEST);
275 at40k.cell(21,15).ylut(0xAA);
277 at40k.cell(22,15).yi(WEST);
278 at40k.cell(22,15).ylut(0xAA);
281 Fpslic.Cell root = at40k.cell(10,20);
283 root.yo(root.north());
284 root.ylut(~LUT_SELF);
288 root.yo(root.east());
289 root.ylut(~LUT_SELF);
293 root.yo(root.south());
294 root.ylut(~LUT_SELF);
298 root.yo(root.west());
302 //////////////////////////////////////////////////////////////////////////////
304 at40k.cell(23,15).h(3, true);
305 at40k.cell(23,15).yi(L3);
306 at40k.cell(23,15).ylut(0xAA);
307 at40k.iob_right(15, true).enableOutput(WEST);
310 Fpslic.Cell c = at40k.cell(10,10);
317 copy(c.west(), EAST, NW);
318 copy(c.west().north().west(), SE, SE);
327 copy(c.east(), WEST, SE);
328 copy(c.east().south().east(), NW, NW);
331 copy(c.north(), SOUTH, SOUTH);
332 c.xlut((LUT_SELF & ~LUT_OTHER) | LUT_Z);
346 copy(c.north(), SOUTH, SOUTH);
347 c.xlut((LUT_SELF & ~LUT_OTHER) | LUT_Z);
368 c.hwire(L4).west().drives(c.hwire(L4), false);
369 c.hwire(L4).east().drives(c.hwire(L4), false);
380 c.hwire(L4).west().drives(c.hwire(L4), false);
381 c.hwire(L4).east().drives(c.hwire(L4), false);
385 copy(c.south(), NORTH, NORTH);
386 c.xlut(((~LUT_SELF) & (~LUT_OTHER)) | LUT_Z);
400 copy(c.south(), NORTH, NORTH);
401 c.xlut((LUT_SELF & LUT_OTHER) | LUT_Z);
415 // catch a rising transition
426 c.hwire(L2).west().drives(c.hwire(L2), false);
427 c.hwire(L2).east().drives(c.hwire(L2), false);
433 c = at40k.cell(20,20);
443 c = at40k.cell(21,20);
474 at40k.cell(9,10).xo(true);
475 at40k.cell(9,10).yo(true);
476 at40k.cell(9,10).c(YLUT);
477 at40k.cell(9,10).b(false);
479 //for(int x=5; x<PIPELEN; x++) {
480 //at40k.cell(x,23).hwire(L0).drives(at40k.cell(x,23).hwire(L0).east());
484 at40k.cell(22,11).ylut(0xff);
485 at40k.cell(23,11).yi(L3);
486 //at40k.cell(23,11).yi(WEST);
487 //at40k.cell(23,11).xi(L1);
488 at40k.cell(23,11).ylut(0xAA);
489 at40k.iob_right(11, true).enableOutput(WEST);
490 at40k.cell(23,11).v(L3, true);
491 at40k.cell(23,11).yo(false);
497 System.out.println("correct: " + at40k.cell(19,15).hwire(L3) + " drives " + at40k.cell(20,15).hwire(L3));
498 System.out.println("correct: " + at40k.cell(15,15).hwire(L3) + " drives " + at40k.cell(19,15).hwire(L3));
499 System.out.println("correct: " + at40k.cell(11,15).hwire(L3) + " drives " + at40k.cell(15,15).hwire(L3));
500 System.out.println("correct: " + at40k.cell(07,15).hwire(L3) + " drives " + at40k.cell(11,15).hwire(L3));
502 at40k.cell(19,15).hwire(L3).drives(at40k.cell(20,15).hwire(L3), true);
503 at40k.cell(15,15).hwire(L3).drives(at40k.cell(19,15).hwire(L3), true);
504 at40k.cell(11,15).hwire(L3).drives(at40k.cell(15,15).hwire(L3), true);
505 at40k.cell(07,15).hwire(L3).drives(at40k.cell(11,15).hwire(L3), true);
507 //at40k.cell(05,vv).xlut(0xff);
508 //at40k.cell(05,vv).ylut(0xff);
510 at40k.cell(vx,vv).c(YLUT);
511 at40k.cell(vx,vv).f(false);
512 at40k.cell(vx,vv).b(false);
513 at40k.cell(vx,vv).oe(NONE);
514 at40k.cell(vx,vv).v(L3, true);
515 at40k.cell(vx,vv).out(L3, true);
518 at40k.cell(vx,15).v(L3, true);
519 at40k.cell(vx,15).h(L3, true);
520 at40k.cell(vx,19).vwire(L3).drives(at40k.cell(vx,15).vwire(L3), true);
521 at40k.cell(vx,23).vwire(L3).drives(at40k.cell(vx,19).vwire(L3), true);
524 //at40k.cell(5,23).ylut(0x00);
525 //at40k.cell(6,22).ylut(0xff);
526 //at40k.cell(22,11).ylut(0xff);
528 Fpslic.Cell cell = at40k.cell(4, 16);
539 //scan(at40k, cell, YLUT, true);
540 //scan(at40k, cell, YLUT, false);
542 //device.scanFPGA(true);
544 at40k.cell(10,10).f(true);
545 at40k.cell(10,10).c(ZMUX);
547 at40k.cell(8,7).xlut(LUT_SELF);
548 at40k.cell(8,7).xi(NW);
550 at40k.cell(7,8).xlut(LUT_SELF & LUT_Z);
551 at40k.cell(7,8).xi(SE);
552 at40k.cell(7,8).c(XLUT);
553 at40k.cell(7,8).f(false);
554 at40k.cell(7,8).b(false);
555 at40k.cell(7,8).t(TMUX_FB);
556 at40k.cell(7,8).xo(false);
557 System.out.println(at40k.cell(7,8).fb_relevant());
559 at40k.cell(6,13).xi(SE);
560 at40k.cell(6,13).c(ZMUX);
561 at40k.cell(6,13).xlut(LUT_SELF);
562 at40k.cell(6,13).ylut(LUT_OTHER);
563 at40k.cell(6,13).xo(false);
564 at40k.cell(6,13).yo(false);
565 at40k.cell(7,12).xi(SE);
567 for(int i=0; i<24; i++) {
568 at40k.iob_bot(i, true).enableOutput(NORTH);
569 at40k.iob_bot(i, false).enableOutput(NW);
570 at40k.cell(i, 0).xlut(0xff);
571 at40k.cell(i, 0).ylut(0xff);
576 Gui vis = new Gui(at40k, device);
577 Frame fr = new Frame();
578 fr.addKeyListener(vis);
579 fr.setLayout(new BorderLayout());
580 fr.add(vis, BorderLayout.CENTER);
582 fr.setSize(900, 900);
586 synchronized(Demo.class) { Demo.class.wait(); }
591 Visualizer v = new Visualizer(at40k, device);
593 v.setSize(1380, 1080);
594 Fpslic.Cell cell = at40k.cell(4, 23);
596 //Image img = v.createImage(v.getWidth(), v.getHeight());
600 cell = at40k.cell(x,y);
601 scan(at40k, cell, YLUT, true);
611 //selfTest(device, at40k, v);
612 //System.out.println("save: " + FtdiBoard.save + " of " + (FtdiBoard.saveof*5));
614 at40k.iob_top(0, true).enableInput();
615 copy(at40k.cell(0, 23), NORTH, NORTH);
616 at40k.iob_bot(0, true).enableOutput(NORTH);
618 for(int i=0; i<10000; i++) {
620 try { Thread.sleep(100); } catch (Exception e) { }
624 //at40k.cell(0x01, 0x17).h(0, false);
625 //at40k.cell(0x01, 0x17).xi(NE);
626 //at40k.cell(0x01, 0x17).ylut((byte)0x55);
628 //at40k.cell(0x04, 0x17).xlut((byte)0x10);
629 //at40k.cell(0x04, 0x17).ylut((byte)0x10);
630 //at40k.cell(0x04, 0x17).yo(false);
631 //at40k.cell(0x04, 0x17).xo();
634 at40k.cell(0x01, 0x17).xi(L0);
635 at40k.cell(0x01, 0x17).h(L0, true);
638 at40k.cell(0x03, 0x17).xlut((byte)0x55);
639 at40k.cell(0x03, 0x17).ylut((byte)0x55);
640 at40k.cell(0x03, 0x17).yi(EAST);
641 at40k.cell(0x03, 0x17).ylut((byte)0x55);
642 at40k.cell(0x03, 0x17).yo(true);
644 at40k.cell(0x03, 0x17).f(false);
645 at40k.cell(0x03, 0x17).c(XLUT);
646 at40k.cell(0x03, 0x17).oe(NONE);
647 at40k.cell(0x03, 0x17).out(L0, true);
649 at40k.cell(0x02, 0x17).yi(EAST);
650 at40k.cell(0x02, 0x17).ylut((byte)0x55);
651 at40k.cell(0x02, 0x17).yo(false);
653 at40k.cell(0x01, 0x17).yi(EAST);
654 at40k.cell(0x01, 0x17).ylut((byte)0x55);
655 at40k.cell(0x01, 0x17).yo(false);
657 at40k.cell(0x01, 0x17).h(L0, true);
658 at40k.cell(0x01, 0x17).v(L0, false);
660 //at40k.cell(0x01, 0x17).yi(L0);
661 //at40k.cell(0x01, 0x17).xi(L0);
662 //at40k.cell(0x01, 0x17).ylut((byte)0x33);
665 at40k.cell(0x03, 0x17).h(L0, true);
666 at40k.cell(0x03, 0x17).out(L0, true);
667 at40k.cell(0x03, 0x17).c(XLUT);
668 at40k.cell(0x03, 0x17).f(false);
671 at40k.cell(0x01, 0x17).xin(4);
672 at40k.cell(0x01, 0x17).yin(4);
673 at40k.cell(0x01, 0x16).ylut((byte)0x00);
674 device.mode4(2, 0x17, 0x01, 0);
676 for(int i=0; i<10; i++) {
678 System.out.println("tick");
679 //at40k.cell(0x01, 0x17).xlut((byte)0xFF);
680 at40k.cell(0x00, 0x17).ylut((byte)0x00);
683 System.out.println("tick");
684 //at40k.cell(0x01, 0x17).xlut((byte)0x00);
685 at40k.cell(0x00, 0x17).ylut((byte)0xFF);
692 at40k.iob_top(0, true).output(0);
693 at40k.iob_top(0, true).oe(false);
694 at40k.iob_top(0, true).pullup();
698 Log.info(Demo.class, "issuing command");
699 at40k.iob_top(1, true).pulldown();
702 Log.info(Demo.class, "done");
704 } catch (Exception e) { e.printStackTrace(); }
708 public static void copy(Fpslic.Cell c, int xdir, int ydir) {
710 case NW: case NE: case SW: case SE: {
715 case NORTH: case SOUTH: case EAST: case WEST: {
721 default: throw new Error();
724 case NW: case NE: case SW: case SE: {
729 case NORTH: case SOUTH: case EAST: case WEST: {
735 default: throw new Error();
740 public static String hex(int x) {
741 return Long.toString(x & 0xffffffffL, 16);
744 public static void handshaker(Fpslic.Cell cell) {
749 cell.t(false, false, true);
753 private static String pad(int i, String s) { if (s.length()>i) return s; return "0"+pad((i-1),s); }
754 public static String bin8(byte b) {
757 for(int i=7; i>=0; i--)
758 ret += (n & (1<<i))==0 ? "0" : "1";
762 public static void bounce(Fpslic.Cell cell, int xi, int yi) {
763 cell.xlut((byte)0xCC);
764 cell.ylut((byte)0xCC);
770 public static void muller(Fpslic.Cell cell, int xi, int yi) {
774 cell.t(false, false, true);
781 /** watches for a rising/falling edge on Yin, emits a pulse on Xout */
782 public static void pulse_detect(Fpslic.Cell c, int in, boolean falling) {
786 case NW: case NE: case SW: case SE: {
789 if (!falling) c.ylut(FpslicUtil.lutSwap(0x0C)); /* x & !z */
790 else c.ylut(FpslicUtil.lutSwap(0x30)); /* !x & z */
794 case NORTH: case SOUTH: case EAST: case WEST: {
797 if (!falling) c.xlut(0x0C); /* y & !z */
798 else c.xlut(0x30); /* !y & z */
802 default: throw new Error();
806 /** watches for a pulse on Xin, copies value of Yin */
807 public static void pulse_copy(Fpslic.Cell cell, int xi, int yi, boolean invert) {
808 loopback(cell, YLUT);
809 if (!invert) cell.ylut(0xB8); /* yo = x ? yi : z => 1011 1000 */
810 else cell.ylut(0x74); /* yo = x ? !yi : z => 0111 0100 */
811 if (!invert) cell.xlut(FpslicUtil.lutSwap(0xB8)); /* yo = x ? yi : z => 1011 1000 */
812 else cell.xlut(FpslicUtil.lutSwap(0x74)); /* yo = x ? !yi : z => 0111 0100 */
817 public static void loopback(Fpslic.Cell cell, int cin) {
820 cell.t(false, false, true);
826 public static void doit(Fpslic at40k, FtdiBoard device) throws Exception {
828 Fpslic.Cell led = at40k.cell(1, 23);
836 Fpslic.Cell c = at40k.cell(1, 22);
844 c.v(L0, /*false*/true);
851 for(int i=0; i<4; i++) at40k.cell(i, 20).h(L0, false);
852 Fpslic.Cell z = at40k.cell(1, 20);
863 z.hwire(L0).east().drives(z.hwire(L0), false);
864 z.hwire(L1).east().drives(z.hwire(L1), false);
865 z.vwire(L0).south().drives(z.vwire(L0), false);
866 z.vwire(L1).south().drives(z.vwire(L1), false);
869 z = at40k.cell(0, 20);
887 for(int y=20; y<=22; y++)
888 for(int x=2; x<=5; x++) {
889 c = at40k.cell(x, y);
893 //c = at40k.cell(2, 22);
897 c = at40k.cell(1, 21);
911 c = at40k.cell(13, 22);
912 c.xlut(LUT_OTHER | 0xF0);
914 c.t(false, false, true);
921 // this gate detects a rising edge on its Xin (delayed copy on Yin); when viewed, it inverts its state
922 c = at40k.cell(14, 22);
927 c.t(false, false, true);
932 c.ylut(0xA6); // (x & !z) ? ~y : y
935 c = at40k.cell(14, 20);
938 c = at40k.cell(14, 21);
942 c = at40k.cell(13, 22);
944 c.xlut(LUT_OTHER);// | 0xF0);
946 //c = at40k.cell(13, 22);
953 c.t(false, false, true);
958 c.ylut(0x54); // (x || z) & !y
962 c = at40k.cell(2, 21);
967 c.t(false, false, true);
974 //at40k.cell(2, 21).xlut(0xF0);
976 at40k.cell(3, 22).ylut(LUT_OTHER);
977 at40k.cell(3, 22).xi(SW);
979 //at40k.iob_top(5, true).enableOutput(SOUTH);
980 //at40k.iob_top(5, false).enableOutput(SE);
983 public static int yofs = mullers ? 19 : 22;
984 public static void counter(Fpslic at40k, FtdiBoard device) throws Exception {
985 // watch for rising edge from south, emit pulse on Xout (to NE)
986 //copy(at40k.cell(16,23), SW, WEST);
988 for(int x=22; x>=1; x-=2) {
989 pulse_detect(at40k.cell(x, yofs), SE, false);
990 pulse_detect(at40k.cell(x, yofs-1), EAST, true);
991 pulse_copy(at40k.cell(x-1, yofs), SE, SOUTH, false);
992 pulse_copy(at40k.cell(x-1, yofs-1), NE, NORTH, true);
994 //pulse_detect(at40k.cell(15, 22), NORTH, false);
995 //pulse_detect(at40k.cell(16, 22), NW, true);
996 //pulse_copy(at40k.cell(16, 21), NW, WEST, false);
997 //pulse_copy(at40k.cell(15, 21), NE, EAST, true);
999 for(int x=23; x>1; x-=2) {
1000 pulse_detect(at40k.cell(x-1, yofs-2), SW, false);
1001 pulse_detect(at40k.cell(x-1, yofs-3), WEST, true);
1002 pulse_copy(at40k.cell(x, yofs-2), SW, SOUTH, false);
1003 pulse_copy(at40k.cell(x, yofs-3), NW, NORTH, true);
1005 //pulse_detect(at40k.cell(15, 22), NORTH, false);
1006 //pulse_detect(at40k.cell(16, 22), NW, true);
1007 //pulse_copy(at40k.cell(16, 21), NW, WEST, false);
1008 //pulse_copy(at40k.cell(15, 21), NE, EAST, true);
1010 copy(at40k.cell(1, yofs-2), SOUTH, SOUTH);
1011 copy(at40k.cell(1, yofs-3), NORTH, NORTH);
1012 at40k.cell(1, yofs-3).ylut(~at40k.cell(1, yofs-3).ylut());
1013 at40k.cell(1, yofs-3).xlut(~at40k.cell(1, yofs-3).xlut());
1015 copy(at40k.cell(23, yofs), SOUTH, SOUTH);
1016 copy(at40k.cell(23, yofs-1), SOUTH, SOUTH);
1018 for(int i=23; i>yofs; i--) copy(at40k.cell(1, i), SOUTH, SOUTH);
1020 //at40k.iob_top(1, true).slew(SLOW);
1021 //at40k.iob_top(1, false).slew(SLOW);
1025 public static void fill(Fpslic at40k, FtdiBoard device, int num) throws Exception {
1026 //muller(at40k.cell(PIPELEN,22), NE, WEST);
1027 Fpslic.Cell a = at40k.cell(10,22);
1028 Fpslic.Cell b = at40k.cell(11,22);
1030 for(int i=0; i<num; i++) {
1031 //System.out.println(i);
1034 try { Thread.sleep(1); } catch (Exception e) { }
1037 try { Thread.sleep(1); } catch (Exception e) { }
1043 public static void drain(Fpslic at40k, FtdiBoard device) throws Exception {
1044 Fpslic.Cell a = at40k.cell(10,22);
1045 Fpslic.Cell b = at40k.cell(11,22);
1048 for(int i=0; i<30; i++) {
1049 //System.out.println(i);
1052 try { Thread.sleep(1); } catch (Exception e) { }
1055 try { Thread.sleep(1); } catch (Exception e) { }
1061 public static void doitx(Fpslic at40k, FtdiBoard device) throws Exception {
1062 for(int i=5; i<PIPELEN+1; i++) bounce(at40k.cell(i, 23), SE, SOUTH);
1063 for(int x=5; x<PIPELEN; x++) muller(at40k.cell(x, 22), x==PIPELEN-1 ? SE : NE, WEST);
1065 bounce(at40k.cell(PIPELEN, 21), NW, WEST);
1067 for(int x=5; x<PIPELEN; x++) muller(at40k.cell(x, 21), SW, x==PIPELEN-1 ? NORTH : EAST);
1068 for(int x=4; x<PIPELEN+1; x++) bounce(at40k.cell(x, 20), NW, NORTH);
1070 bounce(at40k.cell(4, 22), SE, EAST);
1071 //muller(at40k.cell(4PIPELEN-1,21), SW, NORTH);
1073 //muller(at40k.cell(4,22), NE, WEST);
1074 //at40k.cell(4,22).ylut(0xEE);
1075 muller(at40k.cell(5, 22), NE, SOUTH);
1076 muller(at40k.cell(5, 21), NW, EAST);
1078 for(int x=4; x>=0; x--) {
1079 at40k.cell(x, 21).ylut(0xAA);
1080 at40k.cell(x, 21).yi(EAST);
1081 at40k.cell(x, 21).yo(false);
1084 at40k.cell(0, 22).ylut(0xAA);
1085 at40k.cell(0, 22).yi(SOUTH);
1086 at40k.cell(0, 22).yo(false);
1088 at40k.cell(0, 23).ylut(~0xAA);
1089 at40k.cell(0, 23).xlut(~0xcc);
1090 at40k.cell(0, 23).yi(SOUTH);
1091 at40k.cell(0, 23).yo(false);
1093 for(int x=3; x<=23; x+=2) {
1094 pulse_detect(at40k.cell(x-1, 19), SW, false);
1095 pulse_detect(at40k.cell(x-1, 18), WEST, true);
1096 pulse_copy(at40k.cell(x, 19), SW, SOUTH, false);
1097 pulse_copy(at40k.cell(x, 18), NW, NORTH, true);
1100 pulse_detect(at40k.cell(x-1, 16), SW, false);
1101 pulse_detect(at40k.cell(x-1, 15), WEST, true);
1102 pulse_copy(at40k.cell(x, 16), SW, SOUTH, false);
1103 pulse_copy(at40k.cell(x, 15), NW, NORTH, true);
1105 //pulse_detect(at40k.cell(15, 22), NORTH, false);
1106 //pulse_detect(at40k.cell(16, 22), NW, true);
1107 //pulse_copy(at40k.cell(16, 21), NW, WEST, false);
1108 //pulse_copy(at40k.cell(15, 21), NE, EAST, true);
1110 for(int x=14; x>=1; x--)
1111 copy(at40k.cell(x, 17), EAST, EAST);
1112 for(int x=4; x>=0; x--)
1113 copy(at40k.cell(x, 21), EAST, EAST);
1114 copy(at40k.cell(13, 17), SOUTH, SOUTH);
1116 copy(at40k.cell(0, 20), NORTH, NORTH);
1117 copy(at40k.cell(0, 19), NORTH, NORTH);
1118 copy(at40k.cell(0, 18), NORTH, NORTH);
1119 copy(at40k.cell(0, 17), NORTH, NORTH);
1120 copy(at40k.cell(0, 16), NORTH, NORTH);
1121 copy(at40k.cell(1, 16), WEST, WEST);
1122 copy(at40k.cell(1, 15), NORTH, NORTH);
1124 copy(at40k.cell(1, 20), SOUTH, SOUTH);
1125 copy(at40k.cell(1, 19), SOUTH, SOUTH);
1126 copy(at40k.cell(1, 18), SOUTH, SOUTH);
1128 for(int y=20; y<=23; y++)
1129 copy(at40k.cell(23, y), SOUTH, SOUTH);
1132 //for(int x=19; x<=23; x++)
1133 //copy(at40k.cell(x, 0), WEST, WEST);
1134 //copy(at40k.cell(18, 19), NW, NW);
1135 //at40k.iob_top(5, true).enableOutput(SOUTH);
1136 //at40k.iob_top(5, false).enableOutput(SOUTH);