From daff49a8da20b577ab7af4a2e52b5901fbcbf9a9 Mon Sep 17 00:00:00 2001 From: adam Date: Sat, 23 Sep 2006 12:46:38 +0100 Subject: [PATCH] checkpoint --- src/com/atmel/fpslic/Fpslic.java | 11 +- src/edu/berkeley/slipway/Demo.java | 681 +++++++++++++------------- src/edu/berkeley/slipway/DemoVisualizer.java | 4 + src/edu/berkeley/slipway/gui/Gui.java | 102 +++- 4 files changed, 452 insertions(+), 346 deletions(-) diff --git a/src/com/atmel/fpslic/Fpslic.java b/src/com/atmel/fpslic/Fpslic.java index fa7dc5d..3a97c03 100644 --- a/src/com/atmel/fpslic/Fpslic.java +++ b/src/com/atmel/fpslic/Fpslic.java @@ -602,14 +602,17 @@ public abstract class Fpslic { // Relevance ////////////////////////////////////////////////////////////////////////////// + public boolean relevant() { + return xo_relevant() || yo_relevant() || out_relevant(); + } public boolean xo_relevant() { return xo_relevant(NE) || xo_relevant(SE) || xo_relevant(NW) || xo_relevant(SW); } public boolean xo_relevant(int direction) { switch(direction) { - case NE: return ne() != null && ne().xi()==SW /*&& ne().xi_relevant()*/; - case NW: return nw() != null && nw().xi()==SE /*&& nw().xi_relevant()*/; - case SE: return se() != null && se().xi()==NW /*&& se().xi_relevant()*/; - case SW: return sw() != null && sw().xi()==NE /*&& sw().xi_relevant()*/; + case NE: return ne() != null && ne().xi()==SW; + case NW: return nw() != null && nw().xi()==SE; + case SE: return se() != null && se().xi()==NW; + case SW: return sw() != null && sw().xi()==NE; default: return false; } } diff --git a/src/edu/berkeley/slipway/Demo.java b/src/edu/berkeley/slipway/Demo.java index 358daf1..3df2767 100644 --- a/src/edu/berkeley/slipway/Demo.java +++ b/src/edu/berkeley/slipway/Demo.java @@ -19,12 +19,72 @@ public class Demo { public static int masterx = 1; public static int PIPELEN=20; + public static void main(String[] s) throws Exception { FtdiBoard device = new FtdiBoard(); Fpslic at40k = device; + + long begin = System.currentTimeMillis(); + //FpslicUtil.readMode4(new ProgressInputStream("configuring fabric", System.in, 111740), device); + long end = System.currentTimeMillis(); + Log.info(Demo.class, "finished in " + ((end-begin)/1000) + "s"); + Thread.sleep(1000); + Log.info(Demo.class, "issuing command"); + + for(int i=0; i<24; i++) { + at40k.iob_bot(i, true).enableOutput(NORTH); + at40k.iob_bot(i, false).enableOutput(NW); + at40k.cell(i, 0).xlut(0xff); + at40k.cell(i, 0).ylut(0xff); + } + + at40k.cell(23,15).h(3, true); + at40k.cell(23,15).yi(L3); + at40k.cell(23,15).ylut(0xAA); + at40k.iob_right(15, true).enableOutput(WEST); + + device.flush(); + + Fpslic.Cell root = at40k.cell(10,20); + + root.yo(root.north()); + root.ylut(~LUT_SELF); + root.c(YLUT); + root = root.north(); + + root.yo(root.east()); + root.ylut(~LUT_SELF); + root.c(YLUT); + root = root.east(); + + root.yo(root.south()); + root.ylut(~LUT_SELF); + root.c(YLUT); + root = root.south(); + + root.yo(root.west()); + root.c(YLUT); + root = root.west(); + + Gui vis = new Gui(at40k, device); + Frame fr = new Frame(); + fr.addKeyListener(vis); + fr.setLayout(new BorderLayout()); + fr.add(vis, BorderLayout.CENTER); + fr.pack(); + fr.setSize(900, 900); + vis.repaint(); + fr.repaint(); + fr.show(); + synchronized(Demo.class) { Demo.class.wait(); } + } + + public static void mainw(String[] s) throws Exception { + FtdiBoard device = new FtdiBoard(); + Fpslic at40k = device; try { long begin = System.currentTimeMillis(); - FpslicUtil.readMode4(new ProgressInputStream("configuring fabric", System.in, 111740), device); + //FpslicUtil.readMode4(new ProgressInputStream("configuring fabric", System.in, 111740), device); long end = System.currentTimeMillis(); Log.info(Demo.class, "finished in " + ((end-begin)/1000) + "s"); Thread.sleep(1000); @@ -37,85 +97,85 @@ public class Demo { // this command confirmed to turn *on* led0 //at40k.iob_top(1, false).output(0); /* - for(int i=0; i<20; i++) { - at40k.iob_bot(i, false).output(0); - at40k.iob_bot(i, true).output(0); - } + for(int i=0; i<20; i++) { + at40k.iob_bot(i, false).output(0); + at40k.iob_bot(i, true).output(0); + } */ //System.out.println("tick"); - //Thread.sleep(3000); - //System.out.println("tick"); - //at40k.cell(0x01, 0x17).xlut((byte)0x); + //Thread.sleep(3000); + //System.out.println("tick"); + //at40k.cell(0x01, 0x17).xlut((byte)0x); /* - System.out.println(Integer.toString(0xff & at40k.cell(0x01, 0x17).xlut(), 16)); - System.out.println(Integer.toString(0xff & at40k.cell(0x01, 0x17).ylut(), 16)); - at40k.cell(0x01, 0x17).ylut((byte)0xff); + System.out.println(Integer.toString(0xff & at40k.cell(0x01, 0x17).xlut(), 16)); + System.out.println(Integer.toString(0xff & at40k.cell(0x01, 0x17).ylut(), 16)); + at40k.cell(0x01, 0x17).ylut((byte)0xff); */ //at40k.cell(0x01, 0x17).wi(L1); /* - System.out.println("a: " + at40k.new SectorWire(true, 0, 4, 0x17).driverRight()); - System.out.println("b: " + at40k.new SectorWire(true, 1, 4, 0x17).driverRight()); - Fpslic.SectorWire h0p0 = at40k.new SectorWire(true, 0, 0, 0x17); - Fpslic.SectorWire h0p1 = at40k.new SectorWire(true, 1, 0, 0x17); - Fpslic.SectorWire h0p2 = at40k.new SectorWire(true, 2, 0, 0x17); - Fpslic.SectorWire h4p0 = at40k.new SectorWire(true, 0, 4, 0x17); - Fpslic.SectorWire h4p1 = at40k.new SectorWire(true, 1, 4, 0x17); - Fpslic.SectorWire h4p2 = at40k.new SectorWire(true, 2, 4, 0x17); - - //h4p1.drives(h0p1, false); - //at40k.cell(0x04, 0x17).out(L1, false); - //at40k.cell(0x04, 0x17).h(L0, false); - - for(int plane=0; plane<5; plane++) { - at40k.new SectorWire(true, plane, 4, 0x17).drives(at40k.new SectorWire(true, plane, 0, 0x17), false); - at40k.cell(0x04, 0x17).out(plane, false); - at40k.cell(0x04, 0x17).h(plane, false); - at40k.cell(0x01, 0x17).h(plane, false); - } - try { Thread.sleep(2000); } catch (Exception e) { } - - int plane=0; - at40k.new SectorWire(true, plane, 4, 0x17).drives(at40k.new SectorWire(true, plane, 0, 0x17), true); - at40k.cell(0x04, 0x17).out(plane, true); - at40k.cell(0x04, 0x17).h(plane, true); - at40k.cell(0x01, 0x17).h(plane, true); - at40k.cell(0x01, 0x17).wi(plane); + System.out.println("a: " + at40k.new SectorWire(true, 0, 4, 0x17).driverRight()); + System.out.println("b: " + at40k.new SectorWire(true, 1, 4, 0x17).driverRight()); + Fpslic.SectorWire h0p0 = at40k.new SectorWire(true, 0, 0, 0x17); + Fpslic.SectorWire h0p1 = at40k.new SectorWire(true, 1, 0, 0x17); + Fpslic.SectorWire h0p2 = at40k.new SectorWire(true, 2, 0, 0x17); + Fpslic.SectorWire h4p0 = at40k.new SectorWire(true, 0, 4, 0x17); + Fpslic.SectorWire h4p1 = at40k.new SectorWire(true, 1, 4, 0x17); + Fpslic.SectorWire h4p2 = at40k.new SectorWire(true, 2, 4, 0x17); + + //h4p1.drives(h0p1, false); + //at40k.cell(0x04, 0x17).out(L1, false); + //at40k.cell(0x04, 0x17).h(L0, false); + + for(int plane=0; plane<5; plane++) { + at40k.new SectorWire(true, plane, 4, 0x17).drives(at40k.new SectorWire(true, plane, 0, 0x17), false); + at40k.cell(0x04, 0x17).out(plane, false); + at40k.cell(0x04, 0x17).h(plane, false); + at40k.cell(0x01, 0x17).h(plane, false); + } + try { Thread.sleep(2000); } catch (Exception e) { } + + int plane=0; + at40k.new SectorWire(true, plane, 4, 0x17).drives(at40k.new SectorWire(true, plane, 0, 0x17), true); + at40k.cell(0x04, 0x17).out(plane, true); + at40k.cell(0x04, 0x17).h(plane, true); + at40k.cell(0x01, 0x17).h(plane, true); + at40k.cell(0x01, 0x17).wi(plane); */ /* - System.out.println("xlut is " + hex(at40k.cell(0x04, 0x17).xlut())); - System.out.println("ylut is " + hex(at40k.cell(0x04, 0x17).ylut())); - Fpslic.Cell cell = at40k.cell(0x04, 0x17); - //cell.xlut(0xff); - //cell.f(false); - System.out.println(cell.c()); - cell.c(YLUT); - cell.ylut(0x4D); - cell.xlut(0x00); - - cell.b(false); - cell.f(false); - //cell.t(false, false, true); - cell.t(false, true, false); - cell.out(L3, true); - cell.wi(L3); - - cell.yo(false); - cell.h(L0, false); - cell.h(L1, false); - cell.h(L2, false); - cell.h(L3, false); - cell.h(L4, false); - - for(int i=3; i>=1; i--) { - at40k.cell(i, 0x17).yi(EAST); - at40k.cell(i, 0x17).ylut(0x55); - at40k.cell(i, 0x17).yo(false); - } + System.out.println("xlut is " + hex(at40k.cell(0x04, 0x17).xlut())); + System.out.println("ylut is " + hex(at40k.cell(0x04, 0x17).ylut())); + Fpslic.Cell cell = at40k.cell(0x04, 0x17); + //cell.xlut(0xff); + //cell.f(false); + System.out.println(cell.c()); + cell.c(YLUT); + cell.ylut(0x4D); + cell.xlut(0x00); + + cell.b(false); + cell.f(false); + //cell.t(false, false, true); + cell.t(false, true, false); + cell.out(L3, true); + cell.wi(L3); + + cell.yo(false); + cell.h(L0, false); + cell.h(L1, false); + cell.h(L2, false); + cell.h(L3, false); + cell.h(L4, false); + + for(int i=3; i>=1; i--) { + at40k.cell(i, 0x17).yi(EAST); + at40k.cell(i, 0x17).ylut(0x55); + at40k.cell(i, 0x17).yo(false); + } */ //System.out.println("reading port status: " + Integer.toString(device.readBus() & 0xff, 16)); @@ -123,10 +183,10 @@ public class Demo { // blank these out /* - at40k.cell(23, 8).ylut(0xff); - at40k.cell(23, 11).ylut(0xff); - at40k.iob_right(8, true).enableOutput(); - at40k.iob_right(11, true).enableOutput(); + at40k.cell(23, 8).ylut(0xff); + at40k.cell(23, 11).ylut(0xff); + at40k.iob_right(8, true).enableOutput(); + at40k.iob_right(11, true).enableOutput(); */ //for(int x=4; x<=22; x++) swap(at40k.cell(x, 22), NW, NORTH); @@ -137,85 +197,85 @@ public class Demo { //at40k.cell(4,23).ylut(at40k.cell(4,23).xlut()); //at40k.cell(4,23).xo(false); /* - at40k.cell(4,23).xlut(0x55); - at40k.cell(4,23).ylut(0x55); + at40k.cell(4,23).xlut(0x55); + at40k.cell(4,23).ylut(0x55); */ /* - at40k.cell(4,23).xlut(0x71); - at40k.cell(4,23).ylut(0x44); - at40k.cell(4,23).c(YLUT); - at40k.cell(4,23).f(false); - at40k.cell(4,23).t(false, false, true); + at40k.cell(4,23).xlut(0x71); + at40k.cell(4,23).ylut(0x44); + at40k.cell(4,23).c(YLUT); + at40k.cell(4,23).f(false); + at40k.cell(4,23).t(false, false, true); */ //for(int x=6; x<=23; x++) copy(at40k.cell(x, 23), NW, WEST); // top row copies to the right /* - copy(at40k.cell(5, 22), NW, NORTH); - for(int x=6; x<=22; x++) copy(at40k.cell(x, 22), NW, WEST); // second top row copies to the right - //for(int y=22; y>=10; y--) copy(at40k.cell(23, y), NW, NORTH); // right edge copies down - for(int y=21; y>=9; y--) copy(at40k.cell(22, y), NW, NORTH); // second right edge copies down - copy(at40k.cell(23, 9), NW, WEST); // second output + copy(at40k.cell(5, 22), NW, NORTH); + for(int x=6; x<=22; x++) copy(at40k.cell(x, 22), NW, WEST); // second top row copies to the right + //for(int y=22; y>=10; y--) copy(at40k.cell(23, y), NW, NORTH); // right edge copies down + for(int y=21; y>=9; y--) copy(at40k.cell(22, y), NW, NORTH); // second right edge copies down + copy(at40k.cell(23, 9), NW, WEST); // second output */ /* - handshaker(at40k.cell(4,23)); - at40k.cell(4,23).xi(NW); - at40k.cell(4,23).yi(SOUTH); - - //handshaker(at40k.cell(5,23)); - //at40k.cell(5,23).yi(NORTH); - - at40k.cell(5,23).yi(NORTH); - at40k.cell(5,23).xlut(0x55); - at40k.cell(5,23).xi(SW); - at40k.cell(5,23).ylut(0x55); - at40k.cell(5,22).yi(NORTH); - at40k.cell(5,22).xlut(0x55); - - bounce(at40k.cell(4,22)); - - // cell southeast of entry cell - at40k.cell(3,22).xi(NE); // NW->xin - at40k.cell(3,22).ylut(0x33); // xin->y - at40k.cell(3,22).yo(false); // y->yout - copy(at40k.cell(3, 21), NW, NORTH); // second top row copies to the right - copy(at40k.cell(4, 21), NW, EAST); // second top row copies to the right - copy(at40k.cell(5, 21), NW, EAST); // second top row copies to the right - copy(at40k.cell(6, 21), NW, EAST); // second top row copies to the right - copy(at40k.cell(6, 22), NW, SOUTH); // second top row copies to the right + handshaker(at40k.cell(4,23)); + at40k.cell(4,23).xi(NW); + at40k.cell(4,23).yi(SOUTH); + + //handshaker(at40k.cell(5,23)); + //at40k.cell(5,23).yi(NORTH); + + at40k.cell(5,23).yi(NORTH); + at40k.cell(5,23).xlut(0x55); + at40k.cell(5,23).xi(SW); + at40k.cell(5,23).ylut(0x55); + at40k.cell(5,22).yi(NORTH); + at40k.cell(5,22).xlut(0x55); + + bounce(at40k.cell(4,22)); + + // cell southeast of entry cell + at40k.cell(3,22).xi(NE); // NW->xin + at40k.cell(3,22).ylut(0x33); // xin->y + at40k.cell(3,22).yo(false); // y->yout + copy(at40k.cell(3, 21), NW, NORTH); // second top row copies to the right + copy(at40k.cell(4, 21), NW, EAST); // second top row copies to the right + copy(at40k.cell(5, 21), NW, EAST); // second top row copies to the right + copy(at40k.cell(6, 21), NW, EAST); // second top row copies to the right + copy(at40k.cell(6, 22), NW, SOUTH); // second top row copies to the right */ /* - at40k.cell(05,22).xlut(0xff); - at40k.cell(05,22).ylut(0xff); - at40k.cell(05,22).c(XLUT); - at40k.cell(05,22).f(false); - at40k.cell(05,22).b(false); - at40k.cell(05,22).oe(NONE); - at40k.cell(05,22).v(L3, true); - at40k.cell(05,22).out(L3, true); + at40k.cell(05,22).xlut(0xff); + at40k.cell(05,22).ylut(0xff); + at40k.cell(05,22).c(XLUT); + at40k.cell(05,22).f(false); + at40k.cell(05,22).b(false); + at40k.cell(05,22).oe(NONE); + at40k.cell(05,22).v(L3, true); + at40k.cell(05,22).out(L3, true); */ /* - at40k.cell(4,23).ylut(~0xCC); - at40k.cell(4,23).xlut(~0xAA); - at40k.cell(5,23).ylut(~0xAA); - at40k.cell(5,23).xlut(~0xAA); - for(int i=6; i (12 & ~0x3) && sw.north()!=null && sw.north().drives(sw)) - sw.north().drives(sw, false); - while(sw.row > (12 & ~0x3) && sw.south() != null) { - //System.out.println(sw + " -> " + sw.south()); - if (sw.drives(sw.south())!=setup) sw.drives(sw.south(), setup); - sw = sw.south(); - } - if (sw.row < (12 & ~0x3) && sw.south() != null && sw.south().drives(sw)) - sw.north().drives(sw, false); - while(sw.row < (12 & ~0x3) && sw.north() != null) { - //System.out.println(sw + " -> " + sw.north()); - if (sw.drives(sw.north())!=setup) sw.drives(sw.north(), setup); - sw = sw.north(); - } - - //cell = dev.cell(19, 15); - cell = dev.cell(cell.col, 15); - /* - System.out.println("cell is " + cell); - cell.xlut(0xff); - cell.ylut(0xff); - cell.b(false); - cell.f(false); - cell.c(XLUT); - cell.out(L3, true); - cell.oe(NONE); - */ - if (cell.hx(L3) != setup) cell.h(L3, setup); - if (cell.vx(L3) != setup) cell.v(L3, setup); - sw = cell.hwire(L3); - - if (sw.west()!=null && sw.west().drives(sw)) { sw.west().drives(sw, false); } - while(sw.east() != null) { - //System.out.println(sw + " -> " + sw.east()); - if (sw.drives(sw.east())!=setup) sw.drives(sw.east(), setup); - sw = sw.east(); - } - - } public static void copy(Fpslic.Cell c, int xdir, int ydir) { switch(xdir) { @@ -933,39 +942,39 @@ public class Demo { c = at40k.cell(13, 22); c.xlut(0x00); c.xlut(LUT_OTHER);// | 0xF0); -*/ + */ //c = at40k.cell(13, 22); //copy(c, NW, EAST); /* - c.ylut(0x00); - c.c(YLUT); - c.f(false); - c.b(false); - c.t(false, false, true); - c.xi(SE); - c.yi(NORTH); - c.yo(false); - c.xo(false); - c.ylut(0x54); // (x || z) & !y + c.ylut(0x00); + c.c(YLUT); + c.f(false); + c.b(false); + c.t(false, false, true); + c.xi(SE); + c.yi(NORTH); + c.yo(false); + c.xo(false); + c.ylut(0x54); // (x || z) & !y */ /* - c = at40k.cell(2, 21); - c.ylut(0x00); - c.c(YLUT); - c.f(false); - c.b(false); - c.t(false, false, true); - c.xi(SE); - c.yi(WEST); - c.yo(false); - c.xo(false); - c.ylut(0xE8); + c = at40k.cell(2, 21); + c.ylut(0x00); + c.c(YLUT); + c.f(false); + c.b(false); + c.t(false, false, true); + c.xi(SE); + c.yi(WEST); + c.yo(false); + c.xo(false); + c.ylut(0xE8); - //at40k.cell(2, 21).xlut(0xF0); + //at40k.cell(2, 21).xlut(0xF0); - at40k.cell(3, 22).ylut(LUT_OTHER); - at40k.cell(3, 22).xi(SW); + at40k.cell(3, 22).ylut(LUT_OTHER); + at40k.cell(3, 22).xi(SW); */ //at40k.iob_top(5, true).enableOutput(SOUTH); //at40k.iob_top(5, false).enableOutput(SE); @@ -1066,20 +1075,20 @@ public class Demo { muller(at40k.cell(5, 22), NE, SOUTH); muller(at40k.cell(5, 21), NW, EAST); /* - for(int x=4; x>=0; x--) { - at40k.cell(x, 21).ylut(0xAA); - at40k.cell(x, 21).yi(EAST); - at40k.cell(x, 21).yo(false); - } - - at40k.cell(0, 22).ylut(0xAA); - at40k.cell(0, 22).yi(SOUTH); - at40k.cell(0, 22).yo(false); - - at40k.cell(0, 23).ylut(~0xAA); - at40k.cell(0, 23).xlut(~0xcc); - at40k.cell(0, 23).yi(SOUTH); - at40k.cell(0, 23).yo(false); + for(int x=4; x>=0; x--) { + at40k.cell(x, 21).ylut(0xAA); + at40k.cell(x, 21).yi(EAST); + at40k.cell(x, 21).yo(false); + } + + at40k.cell(0, 22).ylut(0xAA); + at40k.cell(0, 22).yi(SOUTH); + at40k.cell(0, 22).yo(false); + + at40k.cell(0, 23).ylut(~0xAA); + at40k.cell(0, 23).xlut(~0xcc); + at40k.cell(0, 23).yi(SOUTH); + at40k.cell(0, 23).yo(false); */ for(int x=3; x<=23; x+=2) { pulse_detect(at40k.cell(x-1, 19), SW, false); diff --git a/src/edu/berkeley/slipway/DemoVisualizer.java b/src/edu/berkeley/slipway/DemoVisualizer.java index 953fa4c..6d9f892 100644 --- a/src/edu/berkeley/slipway/DemoVisualizer.java +++ b/src/edu/berkeley/slipway/DemoVisualizer.java @@ -216,6 +216,7 @@ public class DemoVisualizer extends Frame implements KeyListener, MouseMotionLis g.setColor(BLUE); g.drawString(v+"="+(y?"1":"0"), left(cell) + 8, top(cell) + 35); } }; + /* try { scan(dev, cell, NONE, true); drone.readBus(bc); @@ -225,6 +226,7 @@ public class DemoVisualizer extends Frame implements KeyListener, MouseMotionLis } catch (IOException ex) { throw new RuntimeException(ex); } + */ } public void mouseMoved(MouseEvent e) { @@ -448,6 +450,7 @@ public class DemoVisualizer extends Frame implements KeyListener, MouseMotionLis //if (x==PIPELEN-1 && y==22) System.out.println("time: " + (System.currentTimeMillis()-then)); } }; + /* scan(dev, cell, NONE, true); try { drone.readBus(bc); @@ -458,6 +461,7 @@ public class DemoVisualizer extends Frame implements KeyListener, MouseMotionLis } catch (IOException ex) { throw new RuntimeException(ex); } + */ } } } diff --git a/src/edu/berkeley/slipway/gui/Gui.java b/src/edu/berkeley/slipway/gui/Gui.java index 371da77..c218649 100644 --- a/src/edu/berkeley/slipway/gui/Gui.java +++ b/src/edu/berkeley/slipway/gui/Gui.java @@ -729,7 +729,7 @@ public class Gui extends ZoomingPanel implements KeyListener, MouseMotionListene public void scan(final Gui.Cell c) { try { final Fpslic.Cell cell = c.cell; - Demo.scan(at40k, cell, NONE, true); + scan(at40k, cell, NONE, true); boolean safe = !cell.fb_relevant(); if (cell.xo()) safe = false; if (cell.yo()) safe = false; @@ -741,25 +741,117 @@ public class Gui extends ZoomingPanel implements KeyListener, MouseMotionListene if (cell.xlut_relevant()) { cell.c(XLUT); drone.readBus(new BCB(c, XLUT)); + } else { + c.xknown = false; } if (cell.ylut_relevant()) { cell.c(YLUT); drone.readBus(new BCB(c, YLUT)); + } else { + c.yknown = false; } cell.c(oldc); } else { switch(cell.c()) { - case XLUT: if (cell.xlut_relevant()) drone.readBus(new BCB(c, XLUT)); break; - case YLUT: if (cell.ylut_relevant()) drone.readBus(new BCB(c, YLUT)); break; + case XLUT: + if (!cell.xlut_relevant()) { + c.xknown = false; + } else { + drone.readBus(new BCB(c, XLUT)); + } + for(Fpslic.Cell c2 : new Fpslic.Cell[] { cell.north(), cell.south(), cell.east(), cell.west() }) + if (c2!=null && !c2.relevant()) { + scan(at40k, cell, NONE, false); + c2.yo(cell); + scan(at40k, c2, NONE, true); + c2.c(YLUT); + drone.readBus(new BCB(c, YLUT)); + scan(at40k, c2, NONE, false); + c2.yi(NONE); + return; + } + c.yknown = false; + break; + case YLUT: + if (!cell.ylut_relevant()) { + c.yknown = false; + } else { + drone.readBus(new BCB(c, YLUT)); + } + for(Fpslic.Cell c2 : new Fpslic.Cell[] { cell.nw(), cell.sw(), cell.ne(), cell.se() }) + if (c2!=null && !c2.relevant()) { + scan(at40k, cell, NONE, false); + c2.xo(cell); + scan(at40k, c2, NONE, true); + c2.c(XLUT); + drone.readBus(new BCB(c, XLUT)); + scan(at40k, c2, NONE, false); + c2.xi(NONE); + return; + } + c.xknown = false; + break; } } - Demo.scan(at40k, cell, NONE, false); + scan(at40k, cell, NONE, false); } catch (IOException e) { throw new RuntimeException(e); } } + public static void scan(Fpslic dev, Fpslic.Cell cell, int source, boolean setup) { + if (setup) { + if (source != NONE) cell.c(source); + if (cell.b()) cell.b(false); + if (cell.f()) cell.f(false); + } + if (cell.out(L3)!=setup) cell.out(L3, setup); + if (cell.vx(L3)!=setup) cell.v(L3, setup); + + Fpslic.SectorWire sw = cell.vwire(L3); + //System.out.println("wire is: " + sw); + + if (sw.row > (12 & ~0x3) && sw.north()!=null && sw.north().drives(sw)) + sw.north().drives(sw, false); + while(sw.row > (12 & ~0x3) && sw.south() != null) { + //System.out.println(sw + " -> " + sw.south()); + if (sw.drives(sw.south())!=setup) sw.drives(sw.south(), setup); + sw = sw.south(); + } + if (sw.row < (12 & ~0x3) && sw.south() != null && sw.south().drives(sw)) + sw.north().drives(sw, false); + while(sw.row < (12 & ~0x3) && sw.north() != null) { + //System.out.println(sw + " -> " + sw.north()); + if (sw.drives(sw.north())!=setup) sw.drives(sw.north(), setup); + sw = sw.north(); + } + + //cell = dev.cell(19, 15); + cell = dev.cell(cell.col, 15); + /* + System.out.println("cell is " + cell); + cell.xlut(0xff); + cell.ylut(0xff); + cell.b(false); + cell.f(false); + cell.c(XLUT); + cell.out(L3, true); + cell.oe(NONE); + */ + if (cell.hx(L3) != setup) cell.h(L3, setup); + if (cell.vx(L3) != setup) cell.v(L3, setup); + sw = cell.hwire(L3); + + if (sw.west()!=null && sw.west().drives(sw)) { sw.west().drives(sw, false); } + while(sw.east() != null) { + //System.out.println(sw + " -> " + sw.east()); + if (sw.drives(sw.east())!=setup) sw.drives(sw.east(), setup); + sw = sw.east(); + } + + } + int made = 0; private class BCB extends FtdiBoard.ByteCallback { @@ -771,8 +863,6 @@ public class Gui extends ZoomingPanel implements KeyListener, MouseMotionListene } public void call(byte b) throws Exception { boolean on = (b & 0x80) != 0; - c.xknown = false; - c.yknown = false; switch(who) { case YLUT: c.yknown = true; -- 1.7.10.4