X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fslipway%2FDemo2.java;h=68289db0eb27ce391021027ab51748514b91c484;hb=f6f476bd63c268a2dbcc09c85f79dbc807a74ba3;hp=9906fca6a421a9466c8dafa49dc529571ebbde96;hpb=6a7c71b440b8ec920a95b26d9c7a60595c3f6bcf;p=slipway.git diff --git a/src/edu/berkeley/slipway/Demo2.java b/src/edu/berkeley/slipway/Demo2.java index 9906fca..68289db 100644 --- a/src/edu/berkeley/slipway/Demo2.java +++ b/src/edu/berkeley/slipway/Demo2.java @@ -1,5 +1,6 @@ package edu.berkeley.slipway; +import static java.awt.event.KeyEvent.*; import edu.berkeley.slipway.*; import com.atmel.fpslic.*; import static com.atmel.fpslic.FpslicConstants.*; @@ -13,19 +14,26 @@ import java.io.*; import java.util.*; import gnu.io.*; -public class Demo2 { +public class Demo2 implements KeyListener { public static void main(String[] s) throws Exception { - FtdiBoard device = new FtdiBoard(); - Fpslic at40k = device; + new Demo2().go(); + } + public FtdiBoard device; + public Demo2() throws Exception { + device = new FtdiBoard(); + } + public void go() throws Exception { 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"); - Fpslic.Cell root = at40k.cell(5,5); + Fpslic.Cell root = device.cell(5,5); root.ylut(LUT_SELF); root.yi(NORTH); @@ -36,6 +44,8 @@ public class Demo2 { root = root.north(); root.ylut(LUT_SELF); root.yi(WEST); + root.out(1, true); + root.h(1, true); root.wi(L1); root.zi(L3); @@ -53,9 +63,55 @@ public class Demo2 { root.zi(L0); //root = root.n(); + device.iob_bot(12, false).enableOutput(NW); + Fpslic.Cell c = device.cell(12, 0); + c.xo(c.east()); + while(c.east() != null && c.east().east() != null) { + c.yo(c.east()); + c = c.east(); + } device.flush(); - Gui3 vis = new Gui3(at40k, device); + Fpslic.Cell div = device.cell(19, 21); + while(true) { + AsyncPaperDemo.divider(div); + div = div.south().south(); + if (div == null) break; + } + device.flush(); + + int MAX=17; + for(int x=2; x (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(); + } + + } + + + private class BCB extends FtdiBoard.ByteCallback { + GuiCell c; + public BCB(GuiCell c) { + this.c = c; + } + public void call(byte b) throws Exception { + boolean on = (b & 0x80) != 0; + c.val = on; + vis.repaint(); + } + } }