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.*;
16 public static boolean mullers = true;
17 public static int masterx = 1;
19 public static int PIPELEN=20;
21 public static void main(String[] s) throws Exception {
22 SlipwayBoard slipway = new SlipwayBoard();
23 FpslicDevice device = slipway.getFpslicDevice();
24 FpslicDevice at40k = device;
26 Log.info(Demo.class, "issuing command");
28 //at40k.iob_top(2, true).oe(false);
29 //at40k.iob_top(2, false).oe(false);
30 //at40k.iob_top(1, true).oe(false);
32 // this command confirmed to turn *on* led0
33 //at40k.iob_top(1, false).output(0);
35 for(int i=0; i<20; i++) {
36 at40k.iob_bot(i, false).output(0);
37 at40k.iob_bot(i, true).output(0);
41 //System.out.println("tick");
43 //System.out.println("tick");
44 //at40k.cell(0x01, 0x17).xlut((byte)0x);
47 System.out.println(Integer.toString(0xff & at40k.cell(0x01, 0x17).xlut(), 16));
48 System.out.println(Integer.toString(0xff & at40k.cell(0x01, 0x17).ylut(), 16));
49 at40k.cell(0x01, 0x17).ylut((byte)0xff);
52 //at40k.cell(0x01, 0x17).wi(L1);
54 System.out.println("a: " + at40k.new SectorWire(true, 0, 4, 0x17).driverRight());
55 System.out.println("b: " + at40k.new SectorWire(true, 1, 4, 0x17).driverRight());
56 FpslicDevice.SectorWire h0p0 = at40k.new SectorWire(true, 0, 0, 0x17);
57 FpslicDevice.SectorWire h0p1 = at40k.new SectorWire(true, 1, 0, 0x17);
58 FpslicDevice.SectorWire h0p2 = at40k.new SectorWire(true, 2, 0, 0x17);
59 FpslicDevice.SectorWire h4p0 = at40k.new SectorWire(true, 0, 4, 0x17);
60 FpslicDevice.SectorWire h4p1 = at40k.new SectorWire(true, 1, 4, 0x17);
61 FpslicDevice.SectorWire h4p2 = at40k.new SectorWire(true, 2, 4, 0x17);
63 //h4p1.drives(h0p1, false);
64 //at40k.cell(0x04, 0x17).out(L1, false);
65 //at40k.cell(0x04, 0x17).h(L0, false);
67 for(int plane=0; plane<5; plane++) {
68 at40k.new SectorWire(true, plane, 4, 0x17).drives(at40k.new SectorWire(true, plane, 0, 0x17), false);
69 at40k.cell(0x04, 0x17).out(plane, false);
70 at40k.cell(0x04, 0x17).h(plane, false);
71 at40k.cell(0x01, 0x17).h(plane, false);
73 try { Thread.sleep(2000); } catch (Exception e) { }
76 at40k.new SectorWire(true, plane, 4, 0x17).drives(at40k.new SectorWire(true, plane, 0, 0x17), true);
77 at40k.cell(0x04, 0x17).out(plane, true);
78 at40k.cell(0x04, 0x17).h(plane, true);
79 at40k.cell(0x01, 0x17).h(plane, true);
80 at40k.cell(0x01, 0x17).wi(plane);
85 System.out.println("xlut is " + hex(at40k.cell(0x04, 0x17).xlut()));
86 System.out.println("ylut is " + hex(at40k.cell(0x04, 0x17).ylut()));
87 FpslicDevice.Cell cell = at40k.cell(0x04, 0x17);
90 System.out.println(cell.c());
97 //cell.t(false, false, true);
98 cell.t(false, true, false);
109 for(int i=3; i>=1; i--) {
110 at40k.cell(i, 0x17).yi(EAST);
111 at40k.cell(i, 0x17).ylut(0x55);
112 at40k.cell(i, 0x17).yo(false);
116 //System.out.println("reading port status: " + Integer.toString(device.readFpgaData() & 0xff, 16));
121 at40k.cell(23, 8).ylut(0xff);
122 at40k.cell(23, 11).ylut(0xff);
123 at40k.iob_right(8, true).enableOutput();
124 at40k.iob_right(11, true).enableOutput();
126 //for(int x=4; x<=22; x++) swap(at40k.cell(x, 22), NW, NORTH);
129 // entry cell: just copy X->X Y->Y
130 //at40k.cell(4,23).b(false);
131 //at40k.cell(4,23).yo(false);
132 //at40k.cell(4,23).ylut(at40k.cell(4,23).xlut());
133 //at40k.cell(4,23).xo(false);
135 at40k.cell(4,23).xlut(0x55);
136 at40k.cell(4,23).ylut(0x55);
139 at40k.cell(4,23).xlut(0x71);
140 at40k.cell(4,23).ylut(0x44);
141 at40k.cell(4,23).c(YLUT);
142 at40k.cell(4,23).f(false);
143 at40k.cell(4,23).t(false, false, true);
146 //for(int x=6; x<=23; x++) copy(at40k.cell(x, 23), NW, WEST); // top row copies to the right
148 copy(at40k.cell(5, 22), NW, NORTH);
149 for(int x=6; x<=22; x++) copy(at40k.cell(x, 22), NW, WEST); // second top row copies to the right
150 //for(int y=22; y>=10; y--) copy(at40k.cell(23, y), NW, NORTH); // right edge copies down
151 for(int y=21; y>=9; y--) copy(at40k.cell(22, y), NW, NORTH); // second right edge copies down
152 copy(at40k.cell(23, 9), NW, WEST); // second output
155 handshaker(at40k.cell(4,23));
156 at40k.cell(4,23).xi(NW);
157 at40k.cell(4,23).yi(SOUTH);
159 //handshaker(at40k.cell(5,23));
160 //at40k.cell(5,23).yi(NORTH);
162 at40k.cell(5,23).yi(NORTH);
163 at40k.cell(5,23).xlut(0x55);
164 at40k.cell(5,23).xi(SW);
165 at40k.cell(5,23).ylut(0x55);
166 at40k.cell(5,22).yi(NORTH);
167 at40k.cell(5,22).xlut(0x55);
169 bounce(at40k.cell(4,22));
171 // cell southeast of entry cell
172 at40k.cell(3,22).xi(NE); // NW->xin
173 at40k.cell(3,22).ylut(0x33); // xin->y
174 at40k.cell(3,22).yo(false); // y->yout
175 copy(at40k.cell(3, 21), NW, NORTH); // second top row copies to the right
176 copy(at40k.cell(4, 21), NW, EAST); // second top row copies to the right
177 copy(at40k.cell(5, 21), NW, EAST); // second top row copies to the right
178 copy(at40k.cell(6, 21), NW, EAST); // second top row copies to the right
179 copy(at40k.cell(6, 22), NW, SOUTH); // second top row copies to the right
182 at40k.cell(05,22).xlut(0xff);
183 at40k.cell(05,22).ylut(0xff);
184 at40k.cell(05,22).c(XLUT);
185 at40k.cell(05,22).f(false);
186 at40k.cell(05,22).b(false);
187 at40k.cell(05,22).oe(NONE);
188 at40k.cell(05,22).v(L3, true);
189 at40k.cell(05,22).out(L3, true);
192 at40k.cell(4,23).ylut(~0xCC);
193 at40k.cell(4,23).xlut(~0xAA);
194 at40k.cell(5,23).ylut(~0xAA);
195 at40k.cell(5,23).xlut(~0xAA);
196 for(int i=6; i<PIPELEN+2; i++) {
197 at40k.cell(i, 23).ylut(0xAA);
198 at40k.cell(i, 23).xlut(0xCC);
199 at40k.cell(i, 23).yi(WEST);
203 doitx(at40k, slipway);
204 Gui vis = new Gui(device, slipway);
205 Frame fr = new Frame();
206 fr.addKeyListener(vis);
207 fr.setLayout(new BorderLayout());
208 fr.add(vis, BorderLayout.CENTER);
210 fr.setSize(900, 900);
214 synchronized(Demo.class) { Demo.class.wait(); }
216 System.out.println("doit");
217 if (mullers) doitx(at40k, device);
218 //System.out.println("counter");
219 //counter(at40k, device);
221 at40k.cell(21,15).yi(WEST);
222 at40k.cell(21,15).ylut(0xAA);
224 at40k.cell(22,15).yi(WEST);
225 at40k.cell(22,15).ylut(0xAA);
228 FpslicDevice.Cell root = at40k.cell(10,20);
230 root.yo(root.north());
231 root.ylut(~LUT_SELF);
235 root.yo(root.east());
236 root.ylut(~LUT_SELF);
240 root.yo(root.south());
241 root.ylut(~LUT_SELF);
245 root.yo(root.west());
249 //////////////////////////////////////////////////////////////////////////////
251 at40k.cell(23,15).h(3, true);
252 at40k.cell(23,15).yi(L3);
253 at40k.cell(23,15).ylut(0xAA);
254 at40k.iob_right(15, true).enableOutput(WEST);
257 FpslicDevice.Cell c = at40k.cell(10,10);
264 copy(c.west(), EAST, NW);
265 copy(c.west().north().west(), SE, SE);
274 copy(c.east(), WEST, SE);
275 copy(c.east().south().east(), NW, NW);
278 copy(c.north(), SOUTH, SOUTH);
279 c.xlut((LUT_SELF & ~LUT_OTHER) | LUT_Z);
293 copy(c.north(), SOUTH, SOUTH);
294 c.xlut((LUT_SELF & ~LUT_OTHER) | LUT_Z);
315 c.hwire(L4).west().drives(c.hwire(L4), false);
316 c.hwire(L4).east().drives(c.hwire(L4), false);
327 c.hwire(L4).west().drives(c.hwire(L4), false);
328 c.hwire(L4).east().drives(c.hwire(L4), false);
332 copy(c.south(), NORTH, NORTH);
333 c.xlut(((~LUT_SELF) & (~LUT_OTHER)) | LUT_Z);
347 copy(c.south(), NORTH, NORTH);
348 c.xlut((LUT_SELF & LUT_OTHER) | LUT_Z);
362 // catch a rising transition
373 c.hwire(L2).west().drives(c.hwire(L2), false);
374 c.hwire(L2).east().drives(c.hwire(L2), false);
380 c = at40k.cell(20,20);
390 c = at40k.cell(21,20);
421 at40k.cell(9,10).xo(true);
422 at40k.cell(9,10).yo(true);
423 at40k.cell(9,10).c(YLUT);
424 at40k.cell(9,10).b(false);
426 //for(int x=5; x<PIPELEN; x++) {
427 //at40k.cell(x,23).hwire(L0).drives(at40k.cell(x,23).hwire(L0).east());
431 at40k.cell(22,11).ylut(0xff);
432 at40k.cell(23,11).yi(L3);
433 //at40k.cell(23,11).yi(WEST);
434 //at40k.cell(23,11).xi(L1);
435 at40k.cell(23,11).ylut(0xAA);
436 at40k.iob_right(11, true).enableOutput(WEST);
437 at40k.cell(23,11).v(L3, true);
438 at40k.cell(23,11).yo(false);
444 System.out.println("correct: " + at40k.cell(19,15).hwire(L3) + " drives " + at40k.cell(20,15).hwire(L3));
445 System.out.println("correct: " + at40k.cell(15,15).hwire(L3) + " drives " + at40k.cell(19,15).hwire(L3));
446 System.out.println("correct: " + at40k.cell(11,15).hwire(L3) + " drives " + at40k.cell(15,15).hwire(L3));
447 System.out.println("correct: " + at40k.cell(07,15).hwire(L3) + " drives " + at40k.cell(11,15).hwire(L3));
449 at40k.cell(19,15).hwire(L3).drives(at40k.cell(20,15).hwire(L3), true);
450 at40k.cell(15,15).hwire(L3).drives(at40k.cell(19,15).hwire(L3), true);
451 at40k.cell(11,15).hwire(L3).drives(at40k.cell(15,15).hwire(L3), true);
452 at40k.cell(07,15).hwire(L3).drives(at40k.cell(11,15).hwire(L3), true);
454 //at40k.cell(05,vv).xlut(0xff);
455 //at40k.cell(05,vv).ylut(0xff);
457 at40k.cell(vx,vv).c(YLUT);
458 at40k.cell(vx,vv).f(false);
459 at40k.cell(vx,vv).b(false);
460 at40k.cell(vx,vv).oe(NONE);
461 at40k.cell(vx,vv).v(L3, true);
462 at40k.cell(vx,vv).out(L3, true);
465 at40k.cell(vx,15).v(L3, true);
466 at40k.cell(vx,15).h(L3, true);
467 at40k.cell(vx,19).vwire(L3).drives(at40k.cell(vx,15).vwire(L3), true);
468 at40k.cell(vx,23).vwire(L3).drives(at40k.cell(vx,19).vwire(L3), true);
471 //at40k.cell(5,23).ylut(0x00);
472 //at40k.cell(6,22).ylut(0xff);
473 //at40k.cell(22,11).ylut(0xff);
475 FpslicDevice.Cell cell = at40k.cell(4, 16);
486 //scan(at40k, cell, YLUT, true);
487 //scan(at40k, cell, YLUT, false);
489 //device.scanFPGA(true);
491 at40k.cell(10,10).f(true);
492 at40k.cell(10,10).c(ZMUX);
494 at40k.cell(8,7).xlut(LUT_SELF);
495 at40k.cell(8,7).xi(NW);
497 at40k.cell(7,8).xlut(LUT_SELF & LUT_Z);
498 at40k.cell(7,8).xi(SE);
499 at40k.cell(7,8).c(XLUT);
500 at40k.cell(7,8).f(false);
501 at40k.cell(7,8).b(false);
502 at40k.cell(7,8).t(TMUX_FB);
503 at40k.cell(7,8).xo(false);
504 System.out.println(at40k.cell(7,8).fb_relevant());
506 at40k.cell(6,13).xi(SE);
507 at40k.cell(6,13).c(ZMUX);
508 at40k.cell(6,13).xlut(LUT_SELF);
509 at40k.cell(6,13).ylut(LUT_OTHER);
510 at40k.cell(6,13).xo(false);
511 at40k.cell(6,13).yo(false);
512 at40k.cell(7,12).xi(SE);
514 for(int i=0; i<24; i++) {
515 at40k.iob_bot(i, true).enableOutput(NORTH);
516 at40k.iob_bot(i, false).enableOutput(NW);
517 at40k.cell(i, 0).xlut(0xff);
518 at40k.cell(i, 0).ylut(0xff);
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 FpslicDevice.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: " + SlipwayBoard.save + " of " + (SlipwayBoard.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);
626 device.getFpslicDevice().flush();
628 System.out.println("tick");
629 //at40k.cell(0x01, 0x17).xlut((byte)0x00);
630 at40k.cell(0x00, 0x17).ylut((byte)0xFF);
631 device.getFpslicDevice().flush();
637 at40k.iob_top(0, true).output(0);
638 at40k.iob_top(0, true).oe(false);
639 at40k.iob_top(0, true).pullup();
640 device.getFpslicDevice().flush();
643 Log.info(Demo.class, "issuing command");
644 at40k.iob_top(1, true).pulldown();
645 device.getFpslicDevice().flush();
647 Log.info(Demo.class, "done");
649 } catch (Exception e) { e.printStackTrace(); }
653 public static void copy(FpslicDevice.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(FpslicDevice.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(FpslicDevice.Cell cell, int xi, int yi) {
708 cell.xlut((byte)0xCC);
709 cell.ylut((byte)0xCC);
715 public static void muller(FpslicDevice.Cell cell, int xi, int yi) {
719 cell.t(false, false, true);
726 public static int lutSwap(int x) {
738 /** watches for a rising/falling edge on Yin, emits a pulse on Xout */
739 public static void pulse_detect(FpslicDevice.Cell c, int in, boolean falling) {
743 case NW: case NE: case SW: case SE: {
746 if (!falling) c.ylut(lutSwap(0x0C)); /* x & !z */
747 else c.ylut(lutSwap(0x30)); /* !x & z */
751 case NORTH: case SOUTH: case EAST: case WEST: {
754 if (!falling) c.xlut(0x0C); /* y & !z */
755 else c.xlut(0x30); /* !y & z */
759 default: throw new Error();
763 /** watches for a pulse on Xin, copies value of Yin */
764 public static void pulse_copy(FpslicDevice.Cell cell, int xi, int yi, boolean invert) {
765 loopback(cell, YLUT);
766 if (!invert) cell.ylut(0xB8); /* yo = x ? yi : z => 1011 1000 */
767 else cell.ylut(0x74); /* yo = x ? !yi : z => 0111 0100 */
768 if (!invert) cell.xlut(lutSwap(0xB8)); /* yo = x ? yi : z => 1011 1000 */
769 else cell.xlut(lutSwap(0x74)); /* yo = x ? !yi : z => 0111 0100 */
774 public static void loopback(FpslicDevice.Cell cell, int cin) {
777 cell.t(false, false, true);
783 public static void doit(FpslicDevice at40k, SlipwayBoard device) throws Exception {
785 FpslicDevice.Cell led = at40k.cell(1, 23);
793 FpslicDevice.Cell c = at40k.cell(1, 22);
801 c.v(L0, /*false*/true);
808 for(int i=0; i<4; i++) at40k.cell(i, 20).h(L0, false);
809 FpslicDevice.Cell z = at40k.cell(1, 20);
820 z.hwire(L0).east().drives(z.hwire(L0), false);
821 z.hwire(L1).east().drives(z.hwire(L1), false);
822 z.vwire(L0).south().drives(z.vwire(L0), false);
823 z.vwire(L1).south().drives(z.vwire(L1), false);
826 z = at40k.cell(0, 20);
844 for(int y=20; y<=22; y++)
845 for(int x=2; x<=5; x++) {
846 c = at40k.cell(x, y);
850 //c = at40k.cell(2, 22);
854 c = at40k.cell(1, 21);
868 c = at40k.cell(13, 22);
869 c.xlut(LUT_OTHER | 0xF0);
871 c.t(false, false, true);
878 // this gate detects a rising edge on its Xin (delayed copy on Yin); when viewed, it inverts its state
879 c = at40k.cell(14, 22);
884 c.t(false, false, true);
889 c.ylut(0xA6); // (x & !z) ? ~y : y
892 c = at40k.cell(14, 20);
895 c = at40k.cell(14, 21);
899 c = at40k.cell(13, 22);
901 c.xlut(LUT_OTHER);// | 0xF0);
903 //c = at40k.cell(13, 22);
910 c.t(false, false, true);
915 c.ylut(0x54); // (x || z) & !y
919 c = at40k.cell(2, 21);
924 c.t(false, false, true);
931 //at40k.cell(2, 21).xlut(0xF0);
933 at40k.cell(3, 22).ylut(LUT_OTHER);
934 at40k.cell(3, 22).xi(SW);
936 //at40k.iob_top(5, true).enableOutput(SOUTH);
937 //at40k.iob_top(5, false).enableOutput(SE);
940 public static int yofs = mullers ? 19 : 22;
941 public static void counter(FpslicDevice at40k, SlipwayBoard device) throws Exception {
942 // watch for rising edge from south, emit pulse on Xout (to NE)
943 //copy(at40k.cell(16,23), SW, WEST);
945 for(int x=22; x>=1; x-=2) {
946 pulse_detect(at40k.cell(x, yofs), SE, false);
947 pulse_detect(at40k.cell(x, yofs-1), EAST, true);
948 pulse_copy(at40k.cell(x-1, yofs), SE, SOUTH, false);
949 pulse_copy(at40k.cell(x-1, yofs-1), NE, NORTH, true);
951 //pulse_detect(at40k.cell(15, 22), NORTH, false);
952 //pulse_detect(at40k.cell(16, 22), NW, true);
953 //pulse_copy(at40k.cell(16, 21), NW, WEST, false);
954 //pulse_copy(at40k.cell(15, 21), NE, EAST, true);
956 for(int x=23; x>1; x-=2) {
957 pulse_detect(at40k.cell(x-1, yofs-2), SW, false);
958 pulse_detect(at40k.cell(x-1, yofs-3), WEST, true);
959 pulse_copy(at40k.cell(x, yofs-2), SW, SOUTH, false);
960 pulse_copy(at40k.cell(x, yofs-3), NW, NORTH, true);
962 //pulse_detect(at40k.cell(15, 22), NORTH, false);
963 //pulse_detect(at40k.cell(16, 22), NW, true);
964 //pulse_copy(at40k.cell(16, 21), NW, WEST, false);
965 //pulse_copy(at40k.cell(15, 21), NE, EAST, true);
967 copy(at40k.cell(1, yofs-2), SOUTH, SOUTH);
968 copy(at40k.cell(1, yofs-3), NORTH, NORTH);
969 at40k.cell(1, yofs-3).ylut(~at40k.cell(1, yofs-3).ylut());
970 at40k.cell(1, yofs-3).xlut(~at40k.cell(1, yofs-3).xlut());
972 copy(at40k.cell(23, yofs), SOUTH, SOUTH);
973 copy(at40k.cell(23, yofs-1), SOUTH, SOUTH);
975 for(int i=23; i>yofs; i--) copy(at40k.cell(1, i), SOUTH, SOUTH);
977 //at40k.iob_top(1, true).slew(SLOW);
978 //at40k.iob_top(1, false).slew(SLOW);
982 public static void fill(FpslicDevice at40k, SlipwayBoard device, int num) throws Exception {
983 //muller(at40k.cell(PIPELEN,22), NE, WEST);
984 FpslicDevice.Cell a = at40k.cell(10,22);
985 FpslicDevice.Cell b = at40k.cell(11,22);
987 for(int i=0; i<num; i++) {
988 //System.out.println(i);
990 device.getFpslicDevice().flush();
991 try { Thread.sleep(1); } catch (Exception e) { }
993 device.getFpslicDevice().flush();
994 try { Thread.sleep(1); } catch (Exception e) { }
1000 public static void drain(FpslicDevice at40k, SlipwayBoard device) throws Exception {
1001 FpslicDevice.Cell a = at40k.cell(10,22);
1002 FpslicDevice.Cell b = at40k.cell(11,22);
1005 for(int i=0; i<30; i++) {
1006 //System.out.println(i);
1008 device.getFpslicDevice().flush();
1009 try { Thread.sleep(1); } catch (Exception e) { }
1011 device.getFpslicDevice().flush();
1012 try { Thread.sleep(1); } catch (Exception e) { }
1018 public static void doitx(FpslicDevice at40k, SlipwayBoard device) throws Exception {
1019 for(int i=5; i<PIPELEN+1; i++) bounce(at40k.cell(i, 23), SE, SOUTH);
1020 for(int x=5; x<PIPELEN; x++) muller(at40k.cell(x, 22), x==PIPELEN-1 ? SE : NE, WEST);
1022 bounce(at40k.cell(PIPELEN, 21), NW, WEST);
1024 for(int x=5; x<PIPELEN; x++) muller(at40k.cell(x, 21), SW, x==PIPELEN-1 ? NORTH : EAST);
1025 for(int x=4; x<PIPELEN+1; x++) bounce(at40k.cell(x, 20), NW, NORTH);
1027 bounce(at40k.cell(4, 22), SE, EAST);
1028 //muller(at40k.cell(4PIPELEN-1,21), SW, NORTH);
1030 //muller(at40k.cell(4,22), NE, WEST);
1031 //at40k.cell(4,22).ylut(0xEE);
1032 muller(at40k.cell(5, 22), NE, SOUTH);
1033 muller(at40k.cell(5, 21), NW, EAST);
1035 for(int x=4; x>=0; x--) {
1036 at40k.cell(x, 21).ylut(0xAA);
1037 at40k.cell(x, 21).yi(EAST);
1038 at40k.cell(x, 21).yo(false);
1041 at40k.cell(0, 22).ylut(0xAA);
1042 at40k.cell(0, 22).yi(SOUTH);
1043 at40k.cell(0, 22).yo(false);
1045 at40k.cell(0, 23).ylut(~0xAA);
1046 at40k.cell(0, 23).xlut(~0xcc);
1047 at40k.cell(0, 23).yi(SOUTH);
1048 at40k.cell(0, 23).yo(false);
1050 for(int x=3; x<=23; x+=2) {
1051 pulse_detect(at40k.cell(x-1, 19), SW, false);
1052 pulse_detect(at40k.cell(x-1, 18), WEST, true);
1053 pulse_copy(at40k.cell(x, 19), SW, SOUTH, false);
1054 pulse_copy(at40k.cell(x, 18), NW, NORTH, true);
1057 pulse_detect(at40k.cell(x-1, 16), SW, false);
1058 pulse_detect(at40k.cell(x-1, 15), WEST, true);
1059 pulse_copy(at40k.cell(x, 16), SW, SOUTH, false);
1060 pulse_copy(at40k.cell(x, 15), NW, NORTH, true);
1062 //pulse_detect(at40k.cell(15, 22), NORTH, false);
1063 //pulse_detect(at40k.cell(16, 22), NW, true);
1064 //pulse_copy(at40k.cell(16, 21), NW, WEST, false);
1065 //pulse_copy(at40k.cell(15, 21), NE, EAST, true);
1067 for(int x=14; x>=1; x--)
1068 copy(at40k.cell(x, 17), EAST, EAST);
1069 for(int x=4; x>=0; x--)
1070 copy(at40k.cell(x, 21), EAST, EAST);
1071 copy(at40k.cell(13, 17), SOUTH, SOUTH);
1073 copy(at40k.cell(0, 20), NORTH, NORTH);
1074 copy(at40k.cell(0, 19), NORTH, NORTH);
1075 copy(at40k.cell(0, 18), NORTH, NORTH);
1076 copy(at40k.cell(0, 17), NORTH, NORTH);
1077 copy(at40k.cell(0, 16), NORTH, NORTH);
1078 copy(at40k.cell(1, 16), WEST, WEST);
1079 copy(at40k.cell(1, 15), NORTH, NORTH);
1081 copy(at40k.cell(1, 20), SOUTH, SOUTH);
1082 copy(at40k.cell(1, 19), SOUTH, SOUTH);
1083 copy(at40k.cell(1, 18), SOUTH, SOUTH);
1085 for(int y=20; y<=23; y++)
1086 copy(at40k.cell(23, y), SOUTH, SOUTH);
1089 //for(int x=19; x<=23; x++)
1090 //copy(at40k.cell(x, 0), WEST, WEST);
1091 //copy(at40k.cell(18, 19), NW, NW);
1092 //at40k.iob_top(5, true).enableOutput(SOUTH);
1093 //at40k.iob_top(5, false).enableOutput(SOUTH);