resolve lots of compile errors, remove dead code
authormegacz <adam@megacz.com>
Sun, 26 Apr 2009 02:37:55 +0000 (19:37 -0700)
committermegacz <adam@megacz.com>
Sun, 26 Apr 2009 02:37:55 +0000 (19:37 -0700)
15 files changed:
Makefile
src/com/atmel/fpslic/FakeFpslic.java
src/com/atmel/fpslic/Fpslic.java [deleted file]
src/com/atmel/fpslic/FpslicUtil.java
src/edu/berkeley/slipway/Board.java
src/edu/berkeley/slipway/FakeBoard.java
src/edu/berkeley/slipway/FtdiBoard.java [deleted file]
src/edu/berkeley/slipway/SerialBoard.java
src/edu/berkeley/slipway/demos/AsyncPaperDemo.java [moved from src/edu/berkeley/slipway/AsyncPaperDemo.java with 89% similarity]
src/edu/berkeley/slipway/demos/Demo.java
src/edu/berkeley/slipway/demos/Demo2.java
src/edu/berkeley/slipway/demos/Demo3.java [moved from src/edu/berkeley/slipway/Demo.java with 92% similarity]
src/edu/berkeley/slipway/demos/Demo4.java [moved from src/edu/berkeley/slipway/Demo2.java with 84% similarity]
src/edu/berkeley/slipway/demos/DemoVisualizer.java [moved from src/edu/berkeley/slipway/DemoVisualizer.java with 91% similarity]
src/edu/berkeley/slipway/mpar/MPARDemo.java

index d54cd4f..c23ffeb 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 ifeq ($(shell uname),Darwin)
-linkerflags = -Wl,-framework -Wl,IOKit -Wl,-framework -Wl,CoreFoundation
+linkerflags = -Wl,-framework -Wl,IOKit -Wl,-framework -Wl,CoreFoundation -dynamiclib -framework JavaVM
 jnilib      = libFtdiUartNative.jnilib
 else
 linkerflags =
@@ -36,9 +36,9 @@ build/$(jnilib): build/src/com/ftdi/usb/FtdiUart.c upstream/libusb/.built
                upstream/libftdi/ftdi.c \
                upstream/libusb/.libs/libusb.a \
                $(linkerflags) \
-               -o $@ -dynamiclib -framework JavaVM
+               -o $@
 
-slipway.jar: build/$(jnilib) $(shell find src build/src -name \*.java) misc/slipway_drone.bst
+slipway.jar: build/$(jnilib) $(shell find src build/src -name \*.java) misc/slipway_drone.bst upstream/jhdl-edifparser.jar
        mkdir -p build
        $(javac) -d build $(shell find src build/src -name \*.java)
        cp misc/slipway_drone.bst build/edu/berkeley/slipway/
@@ -71,16 +71,16 @@ build/slipway_drone.hex: src/edu/berkeley/slipway/SlipwaySlave.c  upstream/avr-l
        upstream/prefix/bin/avr-objcopy -O ihex $@.o $@
 
 # this only works on my personal setup [adam]
-misc/slipway_drone.bst: build/slipway_drone.hex
-       cp $<    /afs/research.cs.berkeley.edu/user/megacz/slipway/$<
-       fs flush /afs/research.cs.berkeley.edu/user/megacz/slipway/$<
-       echo okay...
-       read
-       rm /afs/research.cs.berkeley.edu/user/megacz/slipway/$<
-       diff -u /afs/research.cs.berkeley.edu/user/megacz/slipway/$@ $@ && \
-               exit -1; true
-       mv /afs/research.cs.berkeley.edu/user/megacz/slipway/$@ $@
-       touch $@
+#misc/slipway_drone.bst: build/slipway_drone.hex
+#      cp $<    /afs/research.cs.berkeley.edu/user/megacz/slipway/$<
+#      fs flush /afs/research.cs.berkeley.edu/user/megacz/slipway/$<
+#      echo okay...
+#      read
+#      rm /afs/research.cs.berkeley.edu/user/megacz/slipway/$<
+#      diff -u /afs/research.cs.berkeley.edu/user/megacz/slipway/$@ $@ && \
+#              exit -1; true
+#      mv /afs/research.cs.berkeley.edu/user/megacz/slipway/$@ $@
+#      touch $@
 
 
 
index 9bf1742..53135c5 100644 (file)
@@ -6,7 +6,7 @@ import java.util.*;
 import java.io.*;
 import org.ibex.util.Log;
 
-public class FakeFpslic extends Fpslic {
+public class FakeFpslic extends FpslicDevice {
 
     public FakeFpslic(int width, int height) { super(width, height); }
 
diff --git a/src/com/atmel/fpslic/Fpslic.java b/src/com/atmel/fpslic/Fpslic.java
deleted file mode 100644 (file)
index 8182d21..0000000
+++ /dev/null
@@ -1,925 +0,0 @@
-package com.atmel.fpslic;
-
-import java.util.*;
-import java.io.*;
-import org.ibex.util.Log;
-import static com.atmel.fpslic.FpslicConstants.*;
-
-public abstract class Fpslic {
-
-    public Fpslic(int width, int height) { this.width = width; this.height = height; }
-
-    private int width;
-    private int height;
-    public int getWidth() { return width; }
-    public int getHeight() { return height; }
-
-    public abstract void flush();
-    public abstract void mode4(int z, int y, int x, int d);
-    public abstract byte mode4(int z, int y, int x);
-
-    public          byte mode4zyx(int zyx) { return mode4(zyx>>24, (zyx>>16)&0xff, (zyx>>8)&0xff); }
-    public          void mode4zyx(int zyx, int d, int invmask) { mode4(zyx>>24, (zyx>>16)&0xff, (zyx>>8)&0xff, d, invmask); }
-    public          void mode4(int z, int y, int x, int d, int invmask) {
-        int old = mode4(z, y, x);
-        old &= ~invmask;
-        old |= d;
-        mode4(z, y, x, old);
-    }
-    public          void mode4zyx(int zyx, int bit, boolean set) { mode4(zyx>>24, (zyx>>16)&0xff, (zyx>>8)&0xff, bit, set); }
-    public          void mode4(int z, int y, int x, int bit, boolean set) {
-        int old = mode4(z, y, x);
-        old &= ~(1 << bit);
-        old |= set ? (1 << bit) : 0;
-        mode4(z, y, x, old);
-    }
-
-    // Inner Classes ///////////////////////////////////////////////////////////////////////////////
-
-    public final class Sector {
-        public final int col;
-        public final int row;
-        public Sector(Cell c) { this((c.col/4)*4, (c.row/4)*4); }
-        private Sector(int col, int row) {
-            if (row % 4 != 0) throw new Error("Sector must be created with a multiple-of-4 row");
-            if (col % 4 != 0) throw new Error("Sector must be created with a multiple-of-4 col");
-            this.row = row;
-            this.col = col;
-        }
-        public Sector north() { return row+4>=getHeight() ? null : new Sector(col, row+4); }
-        public Sector south() { return row==0 ?             null : new Sector(col, row-4); }
-        public Sector east()  { return col+4>=getWidth() ?  null : new Sector(col+4, row); }
-        public Sector west()  { return col==0 ?             null : new Sector(col-4, row); }
-        public Cell cell()    { return Fpslic.this.cell(col, row); }
-    }
-
-    public final class SectorWire {
-        public final boolean global;
-        public final boolean horizontal;
-        public final int     plane;
-        public final int     row;
-        public final int     col;
-        public SectorWire(boolean horizontal, int plane, int col, int row) {
-            this(horizontal, plane, col, row, false);
-        }
-
-        public void useColumnClock() {
-            // this is very poorly understood
-            if (horizontal) throw new RuntimeException();
-            mode4(0x25, (row>>2)+1, col, 0x80);
-            mode4(0x29, (row>>2),   col, 0x40);
-        }
-
-        public SectorWire(boolean horizontal, int plane, int col, int row, boolean global) {
-            this.horizontal=horizontal;
-            this.global=global;
-            this.plane=plane;
-            this.col= horizontal ? (col & ~0x3) : col;
-            this.row=!horizontal ? (row & ~0x3) : row;
-        }
-        public SectorWire global() {
-            return new SectorWire(horizontal, plane, col, row, true);
-        }
-        public boolean isDriven() {
-            // FIXME: bridging connections (horiz-to-vert)
-            for(int i=0; i<4; i++)
-                if (cell(horizontal ? col+i : col,
-                         horizontal ? row   : row+i).out(plane)) return true;
-            // FIXME: sector switchbox drivers
-            return false;
-        }
-        private int z(int z)       { return (horizontal ? 0x30 : 0x20) | z; }
-        public int code(boolean topleft) {
-            switch(plane) {
-                case 0: return z(8)+(topleft?0:1);
-                case 1: return z(6)+(topleft?0:1);
-                case 2: return z(2*(4-plane))+(topleft?0:1);
-                case 3: return z(2*(4-plane))+(topleft?0:1);
-                case 4: return z(2*(4-plane))+(topleft?0:1);
-            }
-            throw new Error();
-        }
-
-        private final int fine()   { return horizontal ? row : col; }
-        public  final int coarse() { return horizontal ? col : row; }
-        private int _row()  { return horizontal ? row          : ((row)>>2); }
-        private int _col()  { return horizontal ? ((col)>>2) : col;          }
-
-        public SectorWire west()  { return !horizontal ? null : col-4<0       ? null : new SectorWire(horizontal, plane, col-4, row); }
-        public SectorWire east()  { return !horizontal ? null : col+4>=getWidth()  ? null : new SectorWire(horizontal, plane, col+4, row); }
-        public SectorWire north() { return  horizontal ? null : row+4>=getHeight() ? null : new SectorWire(horizontal, plane, col,   row+4); }
-        public SectorWire south() { return  horizontal ? null : row-4<0       ? null : new SectorWire(horizontal, plane, col,   row-4); }
-
-        public String toString() {
-            return
-                (horizontal?(col+":"+(col+3)):(""+col))+","+
-                (horizontal?(row+"")         :(row+":"+(row+3)))+
-                "x"+plane;
-        }
-
-        /** returns the ZYX0 coordinate of the byte controlling the switchbox that allows <tt>w</tt> to drive this wire */
-        public int switchbox(SectorWire w) {
-            if (w.horizontal==horizontal) {
-                if (w.plane!=plane) throw new Error();
-                if (Math.abs(w.coarse()-coarse())!=4) throw new Error(w.coarse() + " -- " + coarse());
-                boolean topleft = horizontal ? (w.coarse() < coarse()) : (w.coarse() > coarse());
-                int col = _col() + (( horizontal && !topleft) ? 1 : 0);
-                int row = _row() + ((!horizontal &&  topleft) ? 1 : 0);
-                return (code(topleft) << 24) | (row<<16) | (col<<8);
-            }
-            throw new Error("not implemented");
-        }
-
-        public void dork() {
-            mode4zyx(switchbox(north()), (1<<6), (1<<6));
-        }
-
-        public void drives(SectorWire w, boolean enable) {
-            // FIXME: better error checks?
-            int val = 0;
-            if (enable) {
-                if (!global) val = 0x02;
-                else         val = 0x04;      
-            }
-            int mask = 0x07;
-            if (w.global) { mask = mask << 3; val = val << 3; }
-            mode4zyx(switchbox(w), val, mask);
-        }
-
-        public boolean drives(SectorWire w) {
-            // FIXME: better error checks?
-            int connect = (mode4zyx(switchbox(w)) >> (global?3:0)) & 0x7;
-            return (connect & 0x2)!=0;
-        }
-        public SectorWire driverRight() {
-            //System.out.println("checking " + Integer.toString(code(true), 16) + " " +
-            //Integer.toString(_row(), 16) + " " + Integer.toString(_col(), 16));
-            int ret = mode4(z(code(true)), _row(), _col());
-            ret = (ret >> (global?3:0)) & 0x7;
-            switch(ret) {
-                case 0: return null;
-                case 1: return null;  /* global wire on same side */
-                case 2: return new SectorWire(horizontal, plane, horizontal?(col+4):col, horizontal?row:(row+4));
-                case 4: return null;  /* global wire on other side */
-                default: throw new Error("multiple drivers on " + this + "!");
-            }
-        }
-
-        public boolean touches(Cell c) {
-            return
-                horizontal
-                ? (c.row==_row() && (_col()/4 == c.col/4))
-                : (c.col==_col() && (_row()/4 == c.row/4));
-        }
-    }
-    /*    
-    public final class SwitchBox {
-        public final boolean h;
-        public final int col;
-        public final int row;
-        public final int plane;
-        public SwitchBox(boolean h, int col, int row, int plane) { this.h = h; this.col = col; this.row = row; this.plane = plane; }
-        public SectorWire west(boolean global)  { return !h ? null : global ? null : new SectorWire(h, col-4, row,   plane); }
-        public SectorWire east(boolean global)  { return !h ? null : global ? null : new SectorWire(h, col+4, row,   plane); }
-        public SectorWire north(boolean global) { return !h ? null : global ? null : new SectorWire(h, col,   row-4, plane); }
-        public SectorWire south(boolean global) { return !h ? null : global ? null : new SectorWire(h, col,   row+4, plane); }
-    }
-    */
-
-    public Cell cell(int col, int row) {
-        if (col<0) return null;
-        if (row<0) return null;
-        if (col>=getWidth()) return null;
-        if (row>=getHeight()) return null;
-        return new Cell(col, row);
-    }
-
-    public final class Cell {
-        public final int col;
-        public final int row;
-
-        public void setColumnClock(int where) {
-            mode4(0x50, 0x00, col, where);
-        }
-
-        public String toString() { return "cell@("+col+","+row+")"; }
-
-        public Cell(int col, int row) {
-            this.row = row;
-            this.col = col;
-        }
-        
-        public Fpslic fpslic() { return Fpslic.this; }
-        public int hashCode() { return col ^ row ^ Fpslic.this.hashCode(); }
-        public boolean equals(Object o) {
-            if (o==null || (!(o instanceof Cell))) return false;
-            Cell c = (Cell)o;
-            return c.col == col && c.row == row && c.fpslic()==fpslic();
-        }
-
-        // Accessors for Neighbors //////////////////////////////////////////////////////////////////////////////
-
-        public SectorWire hwire(int plane)  { return new SectorWire(true, plane, col, row); }
-        public SectorWire vwire(int plane)  { return new SectorWire(false, plane, col, row); }
-        public Cell east() { return cell(col+1, row); }
-        public Cell west() { return cell(col-1, row); }
-        public Cell north() { return cell(col,   row+1); }
-        public Cell south() { return cell(col,   row-1); }
-        public Cell ne() { return cell(col+1, row+1); }
-        public Cell nw() { return cell(col-1, row+1); }
-        public Cell se() { return cell(col+1, row-1); }
-        public Cell sw() { return cell(col-1, row-1); }
-        public Sector sector() { return new Sector(this); }
-
-        /* bit positions mean:  [MSB] zxy z_y zx_ z__ _xy __y _x_ ___ [LSB] */
-        public void lut(int xlut, int ylut) { xlut(xlut); ylut(ylut); }
-        public void xlut(int table)    { mode4(7, row, col, (byte)(table & 0xff)); }
-        public byte xlut()             { return (byte)(mode4(7, row, col) & 0xff); }
-        public String printXLut()      { return FpslicUtil.printLut(xlut(), "x", "y", "t"); }
-        public String printXLutX()     { return FpslicUtil.printLut(xlut(), str(xi(), "x"), str(yi(), "y"), str(ti_source(), "t")); }
-
-        public String str(int x, String def) {
-            switch(x) {
-                case NORTH: return "n";
-                case SOUTH: return "s";
-                case EAST:  return "e";
-                case WEST:  return "w";
-                case NW:    return "nw";
-                case SE:    return "se";
-                case NE:    return "ne";
-                case SW:    return "sw";
-                case FB:    return "fb";
-                case L0:    return (hx(0)&&vx(0))?"HV0":hx(0)?"H0":vx(0)?"V0":"L0";
-                case L1:    return (hx(1)&&vx(1))?"HV1":hx(1)?"H1":vx(1)?"V1":"L1";
-                case L2:    return (hx(2)&&vx(2))?"HV2":hx(2)?"H2":vx(2)?"V2":"L2";
-                case L3:    return (hx(3)&&vx(3))?"HV3":hx(3)?"H3":vx(3)?"V3":"L3";
-                case L4:    return (hx(4)&&vx(4))?"HV4":hx(4)?"H4":vx(4)?"V4":"L4";
-                default: return def;
-            }
-        }
-
-        /* bit positions mean:  [MSB] zxy zx_ z_y z__ _xy _x_ __y ___ [LSB] */
-        public void ylut(int table)    { mode4(6, row, col, (byte)(table & 0xff)); }
-        public byte ylut()             { return (byte)(mode4(6, row, col) & 0xff); }
-        public String printYLut()      { return FpslicUtil.printLut(ylut(), "y", "x", "t"); }
-        public String printYLutX()     { return FpslicUtil.printLut(ylut(), str(yi(), "y"), str(xi(), "x"), str(ti_source(), "t")) + Integer.toString(ylut() & 0xff, 16); }
-
-        public void ff_reset_value(boolean value) {
-            //mode4( /* FIXME WRONG!!! */, row, col, 3, !value); return;
-        }
-        /** FIXME!!! */
-        public boolean ff_reset_value() { return false; }
-        public boolean columnClocked() {
-            return false;
-        }
-
-        public void out(int plane, boolean enable) {
-            switch(plane) {
-                case L0: mode4(0x00, row, col, 2, enable); return;
-                case L1: mode4(0x00, row, col, 3, enable); return;
-                case L2: mode4(0x00, row, col, 5, enable); return;
-                case L3: mode4(0x00, row, col, 4, enable); return;
-                case L4: mode4(0x00, row, col, 1, enable); return;
-                default: throw new RuntimeException("invalid argument");
-            }
-        }
-
-        public boolean out(int plane) {
-            switch(plane) {
-                case L0: return (mode4(0x00, row, col) & (1<<2)) != 0;
-                case L1: return (mode4(0x00, row, col) & (1<<3)) != 0;
-                case L2: return (mode4(0x00, row, col) & (1<<5)) != 0;
-                case L3: return (mode4(0x00, row, col) & (1<<4)) != 0;
-                case L4: return (mode4(0x00, row, col) & (1<<1)) != 0;
-                default: throw new RuntimeException("invalid argument");
-            }
-        }
-
-        public void h(int plane, boolean enable) {
-            switch(plane) {
-                case 0: mode4(0x08, row, col, 0, enable); return;
-                case 1: mode4(0x08, row, col, 2, enable); return;
-                case 2: mode4(0x08, row, col, 5, enable); return;
-                case 3: mode4(0x08, row, col, 6, enable); return;
-                case 4: mode4(0x00, row, col, 6, enable); return;
-                default: throw new RuntimeException("invalid argument");
-            }
-        }
-        
-        public boolean hx(int plane) {
-            switch(plane) {
-                case 0: return (mode4(0x08, row, col) & (1<<0)) != 0;
-                case 1: return (mode4(0x08, row, col) & (1<<2)) != 0;
-                case 2: return (mode4(0x08, row, col) & (1<<5)) != 0;
-                case 3: return (mode4(0x08, row, col) & (1<<6)) != 0;
-                case 4: return (mode4(0x00, row, col) & (1<<6)) != 0;
-                default: throw new RuntimeException("invalid argument");
-            }
-        }
-        
-        public void v(int plane, boolean enable) {
-            switch(plane) {
-                case 0: mode4(0x08, row, col, 1, enable); return;
-                case 1: mode4(0x08, row, col, 3, enable); return;
-                case 2: mode4(0x08, row, col, 4, enable); return;
-                case 3: mode4(0x08, row, col, 7, enable); return;
-                case 4: mode4(0x00, row, col, 7, enable); return;
-                default: throw new RuntimeException("invalid argument");
-            }
-        }
-        
-        public boolean vx(int plane) {
-            switch(plane) {
-                case 0: return (mode4(0x08, row, col) & (1<<1)) != 0;
-                case 1: return (mode4(0x08, row, col) & (1<<3)) != 0;
-                case 2: return (mode4(0x08, row, col) & (1<<4)) != 0;
-                case 3: return (mode4(0x08, row, col) & (1<<7)) != 0;
-                case 4: return (mode4(0x00, row, col) & (1<<7)) != 0;
-                default: throw new RuntimeException("invalid argument");
-            }
-        }
-        
-
-        public int ti_source() {
-            switch(mode4(1, row, col) & 0x30) {
-                case 0x20: return zi();
-                case 0x10: return FB;
-                case 0x00: return wi();
-                default: throw new Error("ack!");
-            }
-        }
-
-        public int t() {
-            switch(mode4(1, row, col) & 0x30) {
-                case 0x00: return TMUX_W;
-                case 0x10: return wi()==NONE ? TMUX_FB : TMUX_W_AND_FB;
-                case 0x20: return wi()==NONE ? TMUX_Z  : TMUX_W_AND_Z;
-                case 0x30: throw new RuntimeException("illegal!");
-                default: return TMUX_W; 
-            }
-        }
-
-        public void t(int code) {
-            int result = 0;
-            switch(code) {
-                case TMUX_W:        result = 0x00; break;
-                case TMUX_Z:        result = 0x20; break;
-                case TMUX_W_AND_Z:  result = 0x20; break;
-                case TMUX_FB:       result = 0x10; break;
-                case TMUX_W_AND_FB: result = 0x10; break;
-                default: result = 0x00; break;
-            }
-            mode4(1, row, col, result, 0x30);
-        }
-        /*
-        private void fmux(int source) {
-            switch(source) {
-                case ZMUX:      
-                case FB:        
-                case ALWAYS_ON: 
-                default: throw new Error("unknown argument to fmux()");
-            }
-        }
-
-        public boolean win_easable() {
-        }
-        */
-
-        public int ti() {
-            return mode4(1, row, col) & 0x34;
-        }
-
-        public void t(boolean ignore_z_and_fb, boolean zm_drives_fb, boolean fb_drives_wm) {
-            // still not totally satisfied...
-            //     need to find the bit that sets the w-mux off
-            //     what does it mean for both bits (0x30) to be set to 1?
-            //if (fb && z) throw new RuntimeException("invalid combination");
-            int result = 0;
-            // ZM->FB = 0x04
-            // FB->WM = 0x10
-            // WZ->WM = 0x20
-
-            // tff => w&z      [0x20]
-            // fff => w        [0x00]
-            // ttt => fb&w     [0x34]
-            // ftt => fb&w     [0x14]
-            // fft => fb&w     [0x10]
-
-            // ttf => w&z      [0x24]
-            // ftf => w        [0x04]
-            // tft => fb&w     [0x30]
-            if (ignore_z_and_fb) result |= 0x20;
-            if (zm_drives_fb) result |= 0x04;
-            if (fb_drives_wm) result |= 0x10;
-            mode4(1, row, col, result, 0x34);
-        }
-
-
-        public void c(int source) {
-            switch(source) {
-                case XLUT: mode4(1, row, col, 0x00, 0xc0); break;
-                case YLUT: mode4(1, row, col, 0x40, 0xc0); break;
-                case ZMUX: mode4(1, row, col, 0x80, 0xc0); break;
-                default:   throw new RuntimeException("Invalid Argument");
-            }
-        }
-        public int c() {
-            int cval = mode4(1, row, col) & 0xc0;
-            switch (cval) {
-                case 0x00: return XLUT;
-                case 0x40: return YLUT;
-                case 0x80: return ZMUX;
-            }
-            throw new Error("c() => " + cval);
-        }
-        public void b(boolean registered) { mode4(1, row, col, 3, !registered); }
-        public void f(boolean registered) { mode4(1, row, col, 2, !registered); }
-        public boolean xo()               { return (mode4(1, row, col) & 0x01) != 0; }
-        public boolean yo()               { return (mode4(1, row, col) & 0x02) != 0; }
-        public void xo(boolean center)    { mode4(1, row, col, 0, center); }
-        public void yo(boolean center)    { mode4(1, row, col, 1, center); }
-
-        public void xo(Cell c) {
-            if (c.row==row || c.col==col) {   // use the y-input
-                xlut(LUT_OTHER);
-                yi(c);
-            } else {
-                xlut(LUT_SELF);
-                xi(c);
-            }
-            xo(false);
-        }
-
-        public void yo(Cell c) {
-            if (!(c.row==row || c.col==col)) {   // use the x-input
-                ylut(LUT_OTHER);
-                xi(c);
-            } else {
-                ylut(LUT_SELF);
-                yi(c);
-            }
-            yo(false);
-        }
-
-        public boolean b() { return (mode4(1, row, col) & (1 << 3)) == 0; }
-        public boolean f() { return (mode4(1, row, col) & (1 << 2)) == 0; }
-        public boolean x() { return (mode4(1, row, col) & (1 << 1)) != 0; }
-        public boolean y() { return (mode4(1, row, col) & (1 << 0)) != 0; }
-
-        public int oe() {
-            switch (mode4(0x02, row, col) & 0x3) {
-                case 0: return NONE;
-                case 1: return H4;
-                case 2: return V4;
-                default: throw new RuntimeException("invalid argument");                    
-            }
-        }
-        public void oe(int source) {
-            switch(source) {
-                case NONE: mode4(0x02, row, col, 0, 0x3); break;
-                case H4:   mode4(0x02, row, col, 1, 0x3); break;
-                case V4:   mode4(0x02, row, col, 2, 0x3); break;
-                default: throw new RuntimeException("invalid argument");
-            }
-        }
-
-        public int xi() {
-            // FIXME: can be multiple
-            if ((mode4(0x03, row, col) & (1<<4))!=0) return L4;
-            switch(mode4(0x05, row, col) & 0xff) {
-                case 0x80: return SW;
-                case (1<<6): return NE;
-                case (1<<5): return SE;
-                case (1<<4): return NW;
-                case (1<<3): return L0;
-                case (1<<2): return L1;
-                case (1<<1): return L2;
-                case (1<<0): return L3;
-                case 0: return NONE;
-                default: throw new Error();
-            }
-        }
-
-        public void xi(int source) {
-            switch(source) {
-                case SW: mode4(0x03, row, col, 4, false); mode4(0x05, row, col, 1<<7); break;
-                case NE: mode4(0x03, row, col, 4, false); mode4(0x05, row, col, 1<<6); break;
-                case SE: mode4(0x03, row, col, 4, false); mode4(0x05, row, col, 1<<5); break;
-                case NW: mode4(0x03, row, col, 4, false); mode4(0x05, row, col, 1<<4); break;
-
-                case L0: mode4(0x03, row, col, 4, false); mode4(0x05, row, col, 1<<3); break;
-                case L1: mode4(0x03, row, col, 4, false); mode4(0x05, row, col, 1<<2); break;
-                case L2: mode4(0x03, row, col, 4, false); mode4(0x05, row, col, 1<<1); break;
-                case L3: mode4(0x03, row, col, 4, false); mode4(0x05, row, col, 1<<0); break;
-                case L4: mode4(0x03, row, col, 4, true);  mode4(0x05, row, col,    0); break;
-
-                case NONE: mode4(0x03, row, col, 4, false); mode4(0x05, row, col, 0); break;
-                default: throw new RuntimeException("invalid argument");
-            }
-        }
-
-        public void xi(SectorWire sw) {
-            if (!sw.touches(this)) throw new RuntimeException("invalid argument");
-            xi(sw.plane);
-        }
-
-        public void xi(Cell c) {
-            if      (c.row==row-1 && c.col==col-1) xi(SW);
-            else if (c.row==row+1 && c.col==col-1) xi(NW);
-            else if (c.row==row-1 && c.col==col+1) xi(SE);
-            else if (c.row==row+1 && c.col==col+1) xi(NE);
-            else throw new RuntimeException("invalid argument");
-        }
-
-        public int yi() {
-            if ((mode4(0x02, row, col) & (1<<6))!=0) return L4;
-            switch(mode4(0x04, row, col) & 0xff) {
-                case (1<<7): return NORTH;
-                case (1<<5): return SOUTH;
-                case (1<<6): return WEST;
-                case (1<<4): return EAST;
-                case (1<<3): return L0;
-                case (1<<2): return L1;
-                case (1<<1): return L2;
-                case (1<<0): return L3;
-                case 0: return NONE;
-                default: throw new Error();
-            }
-        }
-
-        public void yi(int source) {
-            switch(source) {
-                case NORTH: mode4(0x02, row, col, 6, false); mode4(0x04, row, col, 1<<7); break;
-                case SOUTH: mode4(0x02, row, col, 6, false); mode4(0x04, row, col, 1<<5); break;
-                case WEST:  mode4(0x02, row, col, 6, false); mode4(0x04, row, col, 1<<6); break;
-                case EAST:  mode4(0x02, row, col, 6, false); mode4(0x04, row, col, 1<<4); break;
-                case L4:    mode4(0x02, row, col, 6, true);  mode4(0x04, row, col,    0); break;
-                case L3:    mode4(0x02, row, col, 6, false); mode4(0x04, row, col, 1<<0); break;
-                case L2:    mode4(0x02, row, col, 6, false); mode4(0x04, row, col, 1<<1); break;
-                case L1:    mode4(0x02, row, col, 6, false); mode4(0x04, row, col, 1<<2); break;
-                case L0:    mode4(0x02, row, col, 6, false); mode4(0x04, row, col, 1<<3); break;
-                case NONE:  mode4(0x02, row, col, 6, false); mode4(0x04, row, col,    0); break;
-                default: throw new RuntimeException("invalid argument");
-            }
-        }
-
-        public void yi(SectorWire sw) {
-            if (!sw.touches(this)) throw new RuntimeException("invalid argument");
-            yi(sw.plane);
-        }
-
-        public void yi(Cell c) {
-            if      (c.row==row-1 && c.col==col)   yi(SOUTH);
-            else if (c.row==row+1 && c.col==col)   yi(NORTH);
-            else if (c.row==row   && c.col==col-1) yi(WEST);
-            else if (c.row==row   && c.col==col+1) yi(EAST);
-            else throw new RuntimeException("invalid argument");
-        }
-
-        public void wi(SectorWire sw) {
-            if (!sw.touches(this)) throw new RuntimeException("invalid argument");
-            wi(sw.plane);
-        }
-
-        public void wi(int source) {
-            switch(source) {
-                case L4:    mode4(0x03, row, col, 1<<5, 0xEC); break;
-                case L3:    mode4(0x03, row, col, 1<<6, 0xEC); break;
-                case L2:    mode4(0x03, row, col, 1<<7, 0xEC); break;
-                case L1:    mode4(0x03, row, col, 1<<3, 0xEC); break;
-                case L0:    mode4(0x03, row, col, 1<<2, 0xEC); break;
-                case NONE:  mode4(0x03, row, col,    0, 0xEC); break;
-                default: throw new RuntimeException("invalid argument");
-            }
-        }
-
-        public int wi() {
-            int who = mode4(0x03, row, col) & 0xEC;
-            switch(who) {
-                case (1<<5): return L4;
-                case (1<<6): return L3;
-                case (1<<7): return L2;
-                case (1<<3): return L1;
-                case (1<<2): return L0;
-                case (1<<0): return NONE;  /* huh? */
-                case (0):    return NONE;
-                default: throw new RuntimeException("invalid argument: " + who);
-            }
-        }
-
-       
-        public void zi(SectorWire sw) {
-            if (!sw.touches(this)) throw new RuntimeException("invalid argument");
-            zi(sw.plane);
-        }
-
-        public void zi(int source) {
-            switch(source) {
-                case L4:    mode4(0x02, row, col, 1<<7, 0xDB); break;
-                case L3:    mode4(0x02, row, col, 1<<5, 0xDB); break;
-                case L2:    mode4(0x02, row, col, 1<<4, 0xDB); break;
-                case L1:    mode4(0x02, row, col, 1<<3, 0xDB); break;
-                case L0:    mode4(0x02, row, col, 1<<2, 0xDB); break;
-                case NONE:  mode4(0x02, row, col,    0, 0xDB); break;
-                default: throw new RuntimeException("invalid argument");
-            }
-        }
-
-        public int zi() {
-            switch(mode4(0x02, row, col) & 0x9B) {
-                case (1<<7): return L4;
-                case (1<<5): return L3;
-                case (1<<4): return L2;
-                case (1<<3): return L1;
-                case (1<<2): return L0;
-                case (1<<1): return NONE;  /* huh? */
-                case (1<<0): return NONE;  /* huh? */
-                case 0:      return NONE;
-                default: throw new RuntimeException("invalid argument: zi=="+(mode4(0x02, row, col) & 0x9B));
-            }
-        }
-
-        public Cell dir(int i) {
-            switch(i) {
-                case NORTH: return north();
-                case SOUTH: return south();
-                case EAST: return east();
-                case WEST: return west();
-                case NW: return nw();
-                case SW: return sw();
-                case SE: return se();
-                case NE: return ne();
-            }
-            return null;
-        }
-        public int dir(Cell c) {
-            if      (c.row==row-1 && c.col==col-1) return SW;
-            else if (c.row==row+1 && c.col==col-1) return NW;
-            else if (c.row==row-1 && c.col==col+1) return SE;
-            else if (c.row==row+1 && c.col==col+1) return NE;
-            else if (c.row==row-1 && c.col==col)   return SOUTH;
-            else if (c.row==row+1 && c.col==col)   return NORTH;
-            else if (c.row==row   && c.col==col-1) return WEST;
-            else if (c.row==row   && c.col==col+1) return EAST;
-            return -1;
-        }
-
-        public void generalized_c_element() {
-
-            /*
-            ylut(LUT_SELF & (~LUT_OTHER));
-            xlut((~LUT_SELF) | LUT_OTHER);
-            c(ZMUX);
-            zi(L2);
-            //h(L2, true);
-            out(L2, true);
-            xo(true);
-            yo(true);
-            */
-
-            //ylut(0xB2);
-            ylut((LUT_SELF & ~LUT_OTHER) | (LUT_Z & ~LUT_OTHER) | (LUT_Z & LUT_SELF & LUT_OTHER));
-            xlut(LUT_Z);
-            c(YLUT);
-            f(false);
-            b(false);
-            t(false, false, true);
-            yo(false);
-            xo(false);
-        }
-
-
-        // 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;
-                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;
-            }
-        }
-        public boolean yo_relevant() { return yo_relevant(NORTH) || yo_relevant(SOUTH) || yo_relevant(EAST) || yo_relevant(WEST); }
-        public boolean yo_relevant(int direction) {
-            switch(direction) {
-                case NORTH: return north() != null && north().yi()==SOUTH  /*&& north().yi_relevant()*/;
-                case EAST: return east() != null  && east().yi()==WEST     /*&& east().yi_relevant()*/;
-                case SOUTH: return south() != null && south().yi()==NORTH  /*&& south().yi_relevant()*/;
-                case WEST: return west() != null  && west().yi()==EAST     /*&& west().yi_relevant()*/;
-                default: return false;
-            }
-        }
-        public boolean xi_relevant() { return xi_to_xlut_relevant() || xi_to_ylut_relevant(); }
-        public boolean yi_relevant() { return yi_to_xlut_relevant() || yi_to_ylut_relevant(); }
-        public boolean xi_to_ylut_relevant() { return (((ylut() & 0xcc) >> 2) != (ylut() & 0x33)); }
-        public boolean yi_to_xlut_relevant() { return (((xlut() & 0xcc) >> 2) != (xlut() & 0x33)); }
-        public boolean zi_to_xlut_relevant() { return (((xlut() & LUT_Z) >> 4) != (xlut() & LUT_Z)); }
-        public boolean zi_to_ylut_relevant() { return (((ylut() & LUT_Z) >> 4) != (ylut() & LUT_Z)); }
-        public boolean xi_to_xlut_relevant() { return (((xlut() & LUT_SELF) >> 1) != (xlut() & (LUT_SELF >> 1))); }
-        public boolean yi_to_ylut_relevant() { return (((ylut() & LUT_SELF) >> 1) != (ylut() & (LUT_SELF >> 1))); }
-        public boolean xlut_relevant() {
-            if ((c()==XLUT || c()==ZMUX) && c_relevant()) return true;
-            if (xo()) return false;
-            return xo_relevant();
-        }
-        public boolean ylut_relevant() {
-            if ((c()==YLUT || c()==ZMUX) && c_relevant()) return true;
-            if (yo()) return false;
-            return yo_relevant();
-        }
-        public boolean c_relevant() {
-            switch(ti()) {
-                case 0x34: return true;
-                case 0x14: return true;
-                case 0x10: return true;
-                case 0x30: return true;
-            }
-            for(int i=0; i<5; i++)
-                if (out(i))
-                    return true;
-            if (xo() || yo()) return true;
-            return false;
-        }
-
-        public boolean register_relevant() {
-            if (!c_relevant()) return false;
-            if (f() && out_relevant()) return true;
-            if (f() && fb_relevant()) return true;
-            if (b() && xo()) return true;
-            if (b() && yo()) return true;
-            return false;
-        }
-        public boolean out_relevant() {
-            boolean out = false;
-            boolean connect = false;
-            for(int i=0; i<4; i++) {
-
-                // FIXME FIXME FIXME
-                if (i==3) continue;
-
-                if (out(L0+i)) out = true;
-                if (hx(L0+i)) connect = true;
-                if (vx(L0+i)) connect = true;
-            }
-            return out && connect;
-        }
-
-        public boolean fb_relevant() {
-            /*
-            if (!(zi_to_xlut_relevant()) ||
-                !(zi_to_ylut_relevant())) return false;
-            switch(ti()) {
-                case 0x34: return true;
-                case 0x14: return true;
-                case 0x10: return true;
-                case 0x30: return true;
-            }
-            return false;
-            */
-            return true;
-        }
-
-
-    }
-
-    public IOB iob_bot(int col, boolean primary)   { return new IOB(col, 0, primary, true); }
-    public IOB iob_top(int col, boolean primary)   { return new IOB(col, 1, primary, true); }
-    public IOB iob_left(int row, boolean primary)  { return new IOB(0, row, primary, false); }
-    public IOB iob_right(int row, boolean primary) { return new IOB(1, row, primary, false); }
-    /*
-    public IOB fromPin(int pin) {
-        if (pin >=  4 && pin <= 11) return io(pin-3);
-        if (pin >= 15 && pin <= 18) return io(pin-2);
-        if (pin >= 19 && pin <= 24) return io(pin);
-        if (pin >= 27 && pin <= 30) return io(pin-2);
-        if (pin >= 33 && pin <= 36) return io(pin);
-        if (pin >= 38 && pin <= 47) return io(pin+1);
-
-
-        if (pin >= 33 && pin <= 36) return io(pin+36);
-        if (pin >= 38 && pin <= 41) return io(pin+43);
-        if (pin >= 42 && pin <= 43) return io(pin+47);
-        if (pin >= 44 && pin <= 47) return io(pin+49);
-        if (pin >= 57 && pin <= 62) return io(pin+40);
-        if (pin >= 63 && pin <= 66) return io(pin+46);
-        if (pin >= 68 && pin <= 71) return io(pin+53);
-        if (pin >= 72 && pin <= 73) return io(pin+53);
-        if (pin >= 74 && pin <= 75) return io(pin+63);
-        if (pin >= 76 && pin <= 77) return io(143+(pin-76));
-        if (pin >= 80 && pin <= 81) return io(145+(pin-80));
-        if (pin >= 82 && pin <= 85) return io(151+(pin-82));
-        if (pin >= 86 && pin <= 89) return io(165+(pin-86));
-        if (pin >= 91 && pin <= 94) return io(177+(pin-91));
-        if (pin >= 95 && pin <= 96) return io(183+(pin-95));
-        if (pin >= 97 && pin <= 100) return io(189+(pin-97));
-        if (pin >= 161 && pin <= 164) return io(289+(pin-161));
-        if (pin >= 165 && pin <= 166) return io(297+(pin-165));
-        if (pin >= 167 && pin <= 168) return io(303+(pin-167));
-        if (pin >= 169 && pin <= 170) return io(309+(pin-169));
-        if (pin >= 172 && pin <= 173) return io(313+(pin-172));
-        if (pin >= 174 && pin <= 175) return io(325+(pin-174));
-        if (pin >= 176 && pin <= 179) return io(327+(pin-176));
-        if (pin >= 180 && pin <= 181) return io(335+(pin-180));
-        if (pin >= 184 && pin <= 185) return io(337+(pin-184));
-        if (pin >= 186 && pin <= 191) return io(343+(pin-186));
-        if (pin >= 192 && pin <= 193) return io(359+(pin-192));
-        if (pin >= 195 && pin <= 196) return io(363+(pin-195));
-        if (pin >= 197 && pin <= 200) return io(369+(pin-197));
-        if (pin >= 201 && pin <= 204) return io(381+(pin-201));
-    }
-    public io(int ionum) {
-        if (ionum <= 94) {
-            int cell = (94 - pin) / 2;
-            boolean primary = cell * 2 == (94-pin);
-        }
-    }
-    */
-    public final class IOB {
-        public final int col;
-        public final int row;
-        public final boolean primary;
-        public final boolean northsouth;
-        public IOB(int col, int row, boolean primary, boolean northsouth) {
-            this.col = col;
-            this.row = row;
-            this.northsouth = northsouth;
-            this.primary = primary;
-        }
-        /*
-        public String dump() {
-            System.out.println("[ "+
-                               (schmitt()?"schmitt ":"")+
-                               (slew()==3?"fast ":slew()==2?"med ":slew()==1?"slow ":"slew-unknown ")+
-                               (cr()?"cr ":"")+
-                               (reg()?"reg ":"")+
-                               
-        }
-        */
-        public void enableOutput(int direction) {
-            useoem(true);
-            output(direction);
-            pullnone();
-            useoem(true);
-            oem(ALWAYS_ON);
-            oe(true);
-            // note: east-side IOBs should have slew=med, others slew=fast
-            slew((!northsouth && col==1) ? MEDIUM : FAST);
-        }
-        public void enableInput() {
-            schmitt(true);
-            pullnone();
-        }
-
-        public void    useoem(boolean use)  { mode4(z(3), row, col, 6, use); }
-        public boolean useoem()             { return (mode4(z(3), row, col) & (1<<6))!=0; }
-        public void    schmitt(boolean use) { mode4(z(0), row, col, 7, use); }
-        public boolean schmitt()            { return (mode4(z(0), row, col) & (1<<7))!=0; }
-
-        public void    slew(int slew) {
-            switch(slew) {
-                case FAST:   mode4(z(0), row, col, 3<<5, 0x60); return;
-                case MEDIUM: mode4(z(0), row, col, 2<<5, 0x60); return;
-                case SLOW:   mode4(z(0), row, col, 1<<5, 0x60); return;
-                default: throw new Error();
-            }
-        }
-
-        public void    oem(int source) {
-            switch(source) {
-                case ALWAYS_ON:  mode4(z(3), row, col, 1<<5, 0x3f); return;
-                case ALWAYS_OFF: mode4(z(3), row, col,    0, 0x3f); return;
-                default: throw new Error();
-            }
-        }
-
-        private int z(int code) { return (northsouth ? 0x70 : 0x60) | (primary ? 0x00 : 0x04) | (code & 0x7); }
-        public void pullup()   { mode4(z(0), row, col, 0x00<<1, 0x06); }
-        public void pulldown() { mode4(z(0), row, col, 0x03<<1, 0x06); }
-        public void pullnone() { mode4(z(0), row, col, 0x01<<1, 0x06); }
-        public void oe(boolean oe) {
-            int old =  mode4(z(1), row, col) & (~(1<<5));
-            old     |= oe ? 0 : (1<<5);
-            mode4(z(1), row, col, old & 0xff);
-        }
-
-        public void output(int which) {
-            switch(which) {
-                case NONE:
-                    mode4(z(1), row, col, 0, 0x1f); return;
-                case WEST: case EAST: case NORTH: case SOUTH:
-                    mode4(z(1), row, col, 1<<0, 0x1f); return;
-                case NW: case SW: case NE: case SE:
-                    mode4(z(1), row, col, 1<<1, 0x1f); return;
-                default: throw new Error();
-            }
-        }
-
-    }
-
-
-}
index dd4b0e7..b7eb2a0 100644 (file)
@@ -17,7 +17,7 @@ public class FpslicUtil {
             (x & 0x01);
     }
 
-    public static void readMode4(InputStream in, Fpslic fpslic) throws IOException {
+    public static void readMode4(InputStream in, FpslicDevice fpslic) throws IOException {
         int count = 0;
         BufferedReader br = new BufferedReader(new InputStreamReader(in));
         for(String str = br.readLine(); str != null; str = br.readLine()) {
@@ -29,7 +29,7 @@ public class FpslicUtil {
         in.close();
     }
 
-    public static void writeMode4(Writer w, Fpslic fpslic) throws IOException {
+    public static void writeMode4(Writer w, FpslicDevice fpslic) throws IOException {
         for(int x=0; x<fpslic.getWidth(); x++)
             for(int y=0; y<fpslic.getWidth(); y++)
                 for(int z=0; z<255; z++) {
index c8fd7b9..33e2eff 100644 (file)
@@ -4,7 +4,6 @@ import edu.berkeley.obits.*;
 import org.ibex.util.Log;
 import java.io.*;
 import java.util.*;
-import gnu.io.*;
 
 public interface Board {
 
index a9be38a..6e579b7 100644 (file)
@@ -44,7 +44,7 @@ public class FakeBoard extends FpslicDevice implements Board {
         };
     }
 
-    public InputStream  getInputStream() throws IOException {
+    public InputStream  getInputStream() {
         return new InputStream() {
             public int available() { return 0; }
             public int read() { return -1; }
@@ -52,7 +52,7 @@ public class FakeBoard extends FpslicDevice implements Board {
         };
     }
 
-    public OutputStream getOutputStream() throws IOException {
+    public OutputStream getOutputStream() {
         return new OutputStream() {
             public void flush() { }
             public void write(int b) { }
@@ -60,9 +60,10 @@ public class FakeBoard extends FpslicDevice implements Board {
         };
     }
 
-    public void selfTest(SelfTestResultListener resultListener) throws Exception { }
+    //public void selfTest(SelfTestResultListener resultListener) throws Exception { }
 
     public Device getDevice() { return this; }
 
+    public void boot(Reader r) throws Exception { }
 }
 
diff --git a/src/edu/berkeley/slipway/FtdiBoard.java b/src/edu/berkeley/slipway/FtdiBoard.java
deleted file mode 100644 (file)
index ba84988..0000000
+++ /dev/null
@@ -1,214 +0,0 @@
-package edu.berkeley.slipway;
-
-import com.ftdi.usb.*;
-import com.atmel.fpslic.*;
-import edu.berkeley.obits.*;
-import org.ibex.util.*;
-import java.io.*;
-import java.util.*;
-import gnu.io.*;
-
-public class FtdiBoard extends Fpslic implements Board {
-
-    static {
-        System.load(new File("build/"+System.mapLibraryName("FtdiUartNative")).getAbsolutePath());
-    }
-
-    private final FpslicBoot chip;
-    private final DataInputStream in;
-    private final DataOutputStream out;
-
-    public InputStream getInputStream() { return in; }
-    public OutputStream getOutputStream() { return out; }
-
-    public FtdiBoard() throws Exception {
-        super(24, 24);
-        chip = new FpslicBoot(new FpslicBootPinsUsb(new FtdiUart(0x6666, 0x3133, 1500 * 1000/2)));
-        String bstFile = this.getClass().getName();
-        bstFile = bstFile.substring(0, bstFile.lastIndexOf('.'));
-        bstFile = bstFile.replace('.', '/')+"/slipway_drone.bst";
-        boot(new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream(bstFile)));
-        in = new DataInputStream(chip.getInputStream());
-        out = new DataOutputStream(chip.getOutputStream());
-        for(int i=0; i<255; i++) out.write(0);
-        out.flush();
-        init();
-    }
-
-    public void reset() throws IOException { chip.reset(); }
-
-    public void boot(Reader r) throws Exception {
-        chip.selfTest();
-
-        int total = 75090/9;
-        OutputStream os = new ProgressOutputStream("bootstrap bitstream:", chip.getConfigStream(), total);
-        BufferedReader br = new BufferedReader(r);
-
-        int bytes = 0;
-        while(true) {
-            String s = br.readLine();
-            if (s==null) break;
-            bytes++;
-            os.write((byte)Integer.parseInt(s, 2));
-            if ((bytes % 1000)==0) os.flush();
-        }
-        os.close();
-    }
-
-
-    // AvrDrone leftovers //////////////////////////////////////////////////////////////////////////////
-
-    private void init() throws IOException {
-        byte[] bytes = new byte[6];
-        int i=0;
-
-        out.write(0);
-        out.flush();
-
-        // read any crap that might be left in the buffer
-        while(true) {
-            System.arraycopy(bytes, 1, bytes, 0, 5);
-            bytes[5] = in.readByte();
-            i++;
-            System.out.print("\rsignature: read \"" + new String(bytes) + "\"                   ");
-            if (bytes[0] == (byte)'O' &&
-                bytes[1] == (byte)'B' &&
-                bytes[2] == (byte)'I' &&
-                bytes[3] == (byte)'T' &&
-                bytes[4] == (byte)'S') {
-                System.out.println("\rsignature: got proper signature                  ");
-                chip.purge();
-                break;
-            }
-        }
-
-        // FIXME: what if init() is called twice?
-        new Thread() {
-            public void run() {
-                while(true) {
-                    try {
-                        while(callbacks.size() == 0) Thread.sleep(50);
-                        byte b = in.readByte();
-                        ByteCallback bc = (ByteCallback)callbacks.remove(0);
-                        //System.out.println("readback " + b + " in " + (System.currentTimeMillis()-bc.time));
-                        bc.call(b);
-                        synchronized(lock) {
-                            lock.notifyAll();
-                        }
-                    } catch (Exception e) {
-                        e.printStackTrace();
-                    }
-                }
-            }
-        }.start();
-    }
-
-
-    // Programming ///////////////////////////////////////////////////////////////////////////////
-
-    private byte[][][] cache = new byte[24][][];
-    public byte mode4(int z, int y, int x) {
-        if (cache[x]==null) return 0;
-        if (cache[x][y]==null) return 0;
-        return cache[x][y][z];
-    }
-
-    public synchronized void mode4(int z, int y, int x, int d) {
-        try {
-            if (cache[x & 0xff]==null) cache[x & 0xff] = new byte[24][];
-            if (cache[x & 0xff][y & 0xff]==null) cache[x & 0xff][y & 0xff] = new byte[256];
-            cache[x & 0xff][y & 0xff][z & 0xff] = (byte)(d & 0xff);
-
-            out.writeByte(1);
-            out.writeByte(z);
-            out.writeByte(y);
-            out.writeByte(x);
-            out.writeByte(d);
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    public synchronized void flush() {
-        try { out.flush(); } catch (IOException e) { throw new RuntimeException(e); } }
-
-
-    // Callbacks //////////////////////////////////////////////////////////////////////////////
-
-    private Vector callbacks = new Vector();
-
-    private Object lock = new Object();
-    private static final int limit = 40;
-
-    private void enqueue(ByteCallback bcb) {
-        synchronized(lock) {
-            try {
-                while (callbacks.size() >= limit) {
-                    lock.wait(100);
-                }
-            } catch (Exception e) {
-                throw new RuntimeException(e);
-            }
-        }
-        bcb.time = System.currentTimeMillis();
-        callbacks.add(bcb);
-    }
-
-    public static abstract class ByteCallback {
-        public int result;
-        public long time;
-        public abstract void call(byte b) throws Exception;
-    }
-
-    public synchronized int readCount() {
-        try {
-            ByteCallback bc = new ByteCallback() {
-                    public synchronized void call(byte b) throws Exception {
-                        result =
-                            ((b & 0xff) << 24) |
-                            ((in.read() & 0xff) << 16) |
-                            ((in.read() & 0xff) << 8) |
-                            ((in.read() & 0xff) << 0);
-                        timer =
-                            ((in.read() & 0xff) << 24) |
-                            ((in.read() & 0xff) << 16) |
-                            ((in.read() & 0xff) << 8) |
-                            ((in.read() & 0xff) << 0);
-                        //System.out.println("timer => " + Integer.toString(timer, 16));
-                        this.notify();
-                    }
-                };
-            synchronized(bc) {
-                enqueue(bc);
-                out.writeByte(3);
-                out.flush();
-                bc.wait();
-            }
-            return bc.result;
-        } catch (Exception e) { throw new RuntimeException(e); }
-    }
-
-    public int timer = 0;
-    public synchronized void readBus(ByteCallback bc) throws IOException {
-        enqueue(bc);
-        out.writeByte(2);
-        out.flush();
-    }
-
-    /*
-    public synchronized void readInterrupts(ByteCallback bc) throws IOException {
-        enqueue(bc);
-        out.writeByte(3);
-        out.flush();
-    }
-    */
-
-    // Util //////////////////////////////////////////////////////////////////////////////
-
-    private String pad(int i, String s) { if (s.length()>i) return s; return "0"+pad((i-1),s); }
-    public static String pad(String s, int i) {
-        if (s.length() >= i) return s;
-        return "0"+pad(s, i-1);
-    }
-
-}
index bc3f41a..ff4f17d 100644 (file)
@@ -4,10 +4,10 @@ import edu.berkeley.obits.*;
 import org.ibex.util.Log;
 import java.io.*;
 import java.util.*;
-import gnu.io.*;
 
-public class SerialBoard implements Board {
+public abstract class SerialBoard implements Board {
 
+    /*
     private final SerialPort sp;
     private final DataInputStream in;
     private final DataOutputStream out;
@@ -43,7 +43,7 @@ public class SerialBoard implements Board {
 
     public InputStream getInputStream() { return in; }
     public OutputStream getOutputStream() { return out; }
-
+    */
     /*
     public static SerialPort detectObitsPort() throws Exception {
         Enumeration e = CommPortIdentifier.getPortIdentifiers();
@@ -1,4 +1,4 @@
-package edu.berkeley.slipway;
+package edu.berkeley.slipway.demos;
 
 import edu.berkeley.slipway.*;
 import com.atmel.fpslic.*;
@@ -11,25 +11,25 @@ import java.awt.color.*;
 import org.ibex.util.*;
 import java.io.*;
 import java.util.*;
-import gnu.io.*;
 
 public class AsyncPaperDemo {
 
-    public FtdiBoard fpslic;
+    public SlipwayBoard board;
+    public FpslicDevice fpslic;
 
     public AsyncPaperDemo() throws Exception {
-        fpslic = new FtdiBoard();
+        board = new SlipwayBoard();
+        fpslic = (FpslicDevice)board.getDevice();
     }
 
-    Fpslic.Cell start;
+    FpslicDevice.Cell start;
     public void main(String[] s) throws Exception {
 
         //turnOnLeds();
         setupScanCell();
 
         for(int i=0; i<255; i++)
-            fpslic.readCount();
-
+            board.readInterruptCount();
 
         //System.in.read();
         for(int i=400; i<402; i+=2) {
@@ -47,7 +47,7 @@ public class AsyncPaperDemo {
         pipe(start.west().north(), start.west(),
              new int[] { NE, EAST, SW, SOUTH });
 
-        Fpslic.Cell div = start.east();
+        FpslicDevice.Cell div = start.east();
         while(true) {
             divider(div);
             if (div.south()==null || div.south().south()==null) break;
@@ -64,12 +64,12 @@ public class AsyncPaperDemo {
         fpslic.flush();
         /*
         for(int i=0; i<23; i++){
-            Fpslic.Cell c = fpslic.cell(0, i);
+            FpslicDevice.Cell c = fpslic.cell(0, i);
             c.ylut(0x00);
             c.c(YLUT);
             c.out(L3, true);
             c.h(L3, true);
-            for(Fpslic.SectorWire sw = c.hwire(L3).east();
+            for(FpslicDevice.SectorWire sw = c.hwire(L3).east();
                 sw!=null;
                 sw=sw.east())
                 sw.west().drives(sw, true);
@@ -97,7 +97,7 @@ public class AsyncPaperDemo {
 
         fpslic.flush();
 
-        fpslic.readCount();
+        board.readInterruptCount();
         long now = System.currentTimeMillis();
         Thread.sleep(1000);
         topLeft().ylut(0xff);
@@ -105,10 +105,10 @@ public class AsyncPaperDemo {
         fpslic.flush();
         long then = System.currentTimeMillis();
 
-        int tokens = fpslic.readCount();
+        int tokens = board.readInterruptCount();
 
         int clockrate = 24; // (in mhz)
-        double elapsed = (double)((((FtdiBoard)fpslic).timer)/clockrate);
+        double elapsed = (double)((((SlipwayBoard)board).readInterruptCount())/clockrate);
         
         double occupancy = ((double)(2*count))/((double)size);
 
@@ -138,7 +138,7 @@ public class AsyncPaperDemo {
             }
             
             fpslic.flush();
-            fpslic.readCount();
+            board.readInterruptCount();
             try { Thread.sleep(100); } catch (Exception e) { }
             int rc = fpslic.readCount();
             if (rc!=0) { System.err.println("flush() failed REALLY BADLY => " + rc); continue; }
@@ -157,9 +157,9 @@ public class AsyncPaperDemo {
                 }
             fpslic.flush();
             
-            fpslic.readCount();
+            board.readInterruptCount();
             try { Thread.sleep(100); } catch (Exception e) { }
-            int rc = fpslic.readCount();
+            int rc = board.readInterruptCount();
             if (rc!=0) {
                 System.err.println("flush() failed => " + rc);
                 try { Thread.sleep(1000); } catch (Exception e) { }
@@ -212,10 +212,10 @@ public class AsyncPaperDemo {
         //try { Thread.sleep(2000); } catch (Exception _) { }
     }
 
-    private Fpslic.Cell topLeft() { return start.north().north(); }
-    private Fpslic.Cell topRight() { return start.north().ne(); }
+    private FpslicDevice.Cell topLeft() { return start.north().north(); }
+    private FpslicDevice.Cell topRight() { return start.north().ne(); }
     private void reconfigTopLeft() {
-        Fpslic.Cell c = topLeft();
+        FpslicDevice.Cell c = topLeft();
                 c.c(YLUT);
                 c.ylut(0x00);
                 c.xlut(0x00);
@@ -231,7 +231,7 @@ public class AsyncPaperDemo {
             fpslic.flush();
     }
     private void reconfigTopLeftNice() {
-        Fpslic.Cell c = topLeft();
+        FpslicDevice.Cell c = topLeft();
         c.c(YLUT);
         c.xlut(LUT_Z);
         fpslic.flush();
@@ -241,7 +241,7 @@ public class AsyncPaperDemo {
         fpslic.flush();
     }
     private void reconfigTopLeftPreserve(boolean on) {
-        Fpslic.Cell c = topLeft();
+        FpslicDevice.Cell c = topLeft();
         fpslic.flush();
         if (on) c.ylut(0x00);
         //else    c.ylut(0xff);
@@ -255,9 +255,9 @@ public class AsyncPaperDemo {
     }
     private void reconfigTopRight() { micropipelineStage(topRight(), topRight().west(), topRight().sw()); }
 
-    private Fpslic.Cell pipe(Fpslic.Cell c, Fpslic.Cell prev, int[] dirs) {
+    private FpslicDevice.Cell pipe(FpslicDevice.Cell c, FpslicDevice.Cell prev, int[] dirs) {
         for(int i=0; i<dirs.length; i++) {
-            Fpslic.Cell next = c.dir(dirs[i]);
+            FpslicDevice.Cell next = c.dir(dirs[i]);
             micropipelineStage(c, prev, next);
             prev = c;
             c = next;
@@ -265,7 +265,7 @@ public class AsyncPaperDemo {
         return c;
     }
 
-    private int createPipeline(Fpslic.Cell c, boolean downward, int length, boolean start) {
+    private int createPipeline(FpslicDevice.Cell c, boolean downward, int length, boolean start) {
         boolean stop = false;
         do {
         if (downward) {
@@ -303,7 +303,7 @@ public class AsyncPaperDemo {
             } else {
                 if (length < 8+4) { stop = true; break; }
                 length -= 8;
-                Fpslic.Cell ret = c = pipe(c, c.south(), new int[] { NE, NORTH, NW, NORTH });
+                FpslicDevice.Cell ret = c = pipe(c, c.south(), new int[] { NE, NORTH, NW, NORTH });
                 c = c.se();
                 c = pipe(c, c.north(), new int[] { SW, SOUTH, SE, SOUTH });
                 c = ret;
@@ -327,7 +327,7 @@ public class AsyncPaperDemo {
     }
 
     /*
-    private void createPipeline(Fpslic.Cell c, boolean downward, int length) {
+    private void createPipeline(FpslicDevice.Cell c, boolean downward, int length) {
         length -= 2;
         if (downward) {
             if (c.row == 0) {
@@ -353,10 +353,10 @@ public class AsyncPaperDemo {
     }
     */
 
-    private Fpslic.Cell micropipelineStage(Fpslic.Cell c, Fpslic.Cell prev, Fpslic.Cell next) {
+    private FpslicDevice.Cell micropipelineStage(FpslicDevice.Cell c, FpslicDevice.Cell prev, FpslicDevice.Cell next) {
         return micropipelineStage(c, prev, next, true);
     }
-    private Fpslic.Cell micropipelineStage(Fpslic.Cell c, Fpslic.Cell prev, Fpslic.Cell next, boolean configDir) {
+    private FpslicDevice.Cell micropipelineStage(FpslicDevice.Cell c, FpslicDevice.Cell prev, FpslicDevice.Cell next, boolean configDir) {
         c.b(false);
         c.f(false);
         switch(c.dir(next)) {
@@ -385,7 +385,7 @@ public class AsyncPaperDemo {
 
             //c.c(YLUT);
             /*
-            Fpslic.SectorWire sw = c.vwire(L3);
+            FpslicDevice.SectorWire sw = c.vwire(L3);
             while(sw.south() != null) {
                 sw.south().drives(sw, true);
                 sw = sw.south();
@@ -464,9 +464,9 @@ public class AsyncPaperDemo {
         fpslic.flush();
     }
 
-    public static void divider(Fpslic.Cell c) {
-        Fpslic.Cell detect1 = c;
-        Fpslic.Cell detect2 = c.east();
+    public static void divider(FpslicDevice.Cell c) {
+        FpslicDevice.Cell detect1 = c;
+        FpslicDevice.Cell detect2 = c.east();
 
         detect1.yi(NORTH);
         detect1.ylut(LUT_SELF);
@@ -513,7 +513,7 @@ public class AsyncPaperDemo {
     }
 
     public void runGui(int width, int height) throws Exception {
-        Gui vis = new Gui(fpslic, fpslic, width, height);
+        Gui vis = new Gui(fpslic, board, width, height);
         Frame fr = new Frame();
         fr.setTitle("SLIPWAY Live Fabric Debugger");
         fr.addKeyListener(vis);
index 08f9ca6..a06cf8f 100644 (file)
@@ -10,7 +10,6 @@ import java.awt.color.*;
 import org.ibex.util.*;
 import java.io.*;
 import java.util.*;
-import gnu.io.*;
 
 public class Demo {
 
index 56c07b3..c407fa0 100644 (file)
@@ -12,7 +12,6 @@ import java.awt.color.*;
 import org.ibex.util.*;
 import java.io.*;
 import java.util.*;
-import gnu.io.*;
 
 public class Demo2 implements KeyListener {
 
@@ -175,7 +174,7 @@ public class Demo2 implements KeyListener {
     }
     public void scan(final GuiCell c) {
         try {
-            final FpslicDevice.Cell cell = c.fpslicCell;
+            final FpslicDevice.Cell cell = (FpslicDevice.Cell)c.fpslicCell;
             scan(slipway, cell, YLUT, true);
             int x = cell.col;
             int y = cell.row;
similarity index 92%
rename from src/edu/berkeley/slipway/Demo.java
rename to src/edu/berkeley/slipway/demos/Demo3.java
index 51a9e54..1721b18 100644 (file)
@@ -1,4 +1,4 @@
-package edu.berkeley.slipway;
+package edu.berkeley.slipway.demos;
 
 import edu.berkeley.slipway.*;
 import com.atmel.fpslic.*;
@@ -11,9 +11,8 @@ import java.awt.color.*;
 import org.ibex.util.*;
 import java.io.*;
 import java.util.*;
-import gnu.io.*;
 
-public class Demo {
+public class Demo3 {
 
     public static boolean mullers = true;
     public static int masterx = 1;
@@ -25,15 +24,16 @@ public class Demo {
     }
 
     public static void mainw(String[] s) throws Exception {
-        FtdiBoard device = new FtdiBoard();
-        Fpslic at40k = device;
+        SlipwayBoard board = new SlipwayBoard();
+        FpslicDevice device = (FpslicDevice)board.getDevice();
+        FpslicDevice 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), board);
             long end = System.currentTimeMillis();
-            Log.info(Demo.class, "finished in " + ((end-begin)/1000) + "s");
+            Log.info(Demo3.class, "finished in " + ((end-begin)/1000) + "s");
             Thread.sleep(1000);
-            Log.info(Demo.class, "issuing command");
+            Log.info(Demo3.class, "issuing command");
 
             //at40k.iob_top(2, true).oe(false);
             //at40k.iob_top(2, false).oe(false);
@@ -63,12 +63,12 @@ public class Demo {
             /*
               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);
+              FpslicDevice.SectorWire h0p0 = at40k.new SectorWire(true, 0, 0, 0x17);
+              FpslicDevice.SectorWire h0p1 = at40k.new SectorWire(true, 1, 0, 0x17);
+              FpslicDevice.SectorWire h0p2 = at40k.new SectorWire(true, 2, 0, 0x17);
+              FpslicDevice.SectorWire h4p0 = at40k.new SectorWire(true, 0, 4, 0x17);
+              FpslicDevice.SectorWire h4p1 = at40k.new SectorWire(true, 1, 4, 0x17);
+              FpslicDevice.SectorWire h4p2 = at40k.new SectorWire(true, 2, 4, 0x17);
 
               //h4p1.drives(h0p1, false);
               //at40k.cell(0x04, 0x17).out(L1, false);
@@ -94,7 +94,7 @@ public class Demo {
             /*
               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);
+              FpslicDevice.Cell cell = at40k.cell(0x04, 0x17);
               //cell.xlut(0xff);
               //cell.f(false);
               System.out.println(cell.c());
@@ -223,7 +223,7 @@ public class Demo {
                at40k.cell(22,15).ylut(0xAA);
             */
 
-            Fpslic.Cell root = at40k.cell(10,20);
+            FpslicDevice.Cell root = at40k.cell(10,20);
             
             root.yo(root.north());
             root.ylut(~LUT_SELF);
@@ -252,7 +252,7 @@ public class Demo {
             at40k.iob_right(15, true).enableOutput(WEST);
 
 
-            Fpslic.Cell c = at40k.cell(10,10);
+            FpslicDevice.Cell c = at40k.cell(10,10);
             c.ylut(~LUT_SELF);
             c.xlut(LUT_Z);
             c.yi(WEST);
@@ -470,7 +470,7 @@ public class Demo {
             //at40k.cell(6,22).ylut(0xff);
             //at40k.cell(22,11).ylut(0xff);
             /*
-              Fpslic.Cell cell = at40k.cell(4, 16);
+              FpslicDevice.Cell cell = at40k.cell(4, 16);
               cell.xlut(0xff);
               cell.ylut(0xff);
               cell.b(false);
@@ -518,7 +518,7 @@ public class Demo {
 
             device.flush();
 
-            Gui vis = new Gui(at40k, device);
+            Gui vis = new Gui(device, board);
             Frame fr = new Frame();
             fr.addKeyListener(vis);
             fr.setLayout(new BorderLayout());
@@ -528,7 +528,7 @@ public class Demo {
             vis.repaint();
             fr.repaint();
             fr.show();
-            synchronized(Demo.class) { Demo.class.wait(); }
+            synchronized(Demo3.class) { Demo3.class.wait(); }
 
 
 
@@ -536,7 +536,7 @@ public class Demo {
               Visualizer v = new Visualizer(at40k, device);
               v.show();
               v.setSize(1380, 1080);
-              Fpslic.Cell cell = at40k.cell(4, 23);
+              FpslicDevice.Cell cell = at40k.cell(4, 23);
             */
             //Image img = v.createImage(v.getWidth(), v.getHeight());
             /*
@@ -554,7 +554,7 @@ public class Demo {
             //int y = 11;
 
             //selfTest(device, at40k, v);
-            //System.out.println("save: " + FtdiBoard.save + " of " + (FtdiBoard.saveof*5));
+            //System.out.println("save: " + SlipwayBoard.save + " of " + (SlipwayBoard.saveof*5));
 
             at40k.iob_top(0, true).enableInput();
             copy(at40k.cell(0, 23), NORTH, NORTH);
@@ -640,17 +640,17 @@ public class Demo {
               device.flush();
               Thread.sleep(3000);
 
-              Log.info(Demo.class, "issuing command");
+              Log.info(Demo3.class, "issuing command");
               at40k.iob_top(1, true).pulldown();
               device.flush();
             */
-            Log.info(Demo.class, "done");
+            Log.info(Demo3.class, "done");
             System.exit(0);
         } catch (Exception e) { e.printStackTrace(); }
     }
 
 
-    public static void copy(Fpslic.Cell c, int xdir, int ydir) {
+    public static void copy(FpslicDevice.Cell c, int xdir, int ydir) {
         switch(xdir) {
             case NW: case NE: case SW: case SE: {
                 c.xi(xdir);
@@ -686,7 +686,7 @@ public class Demo {
         return Long.toString(x & 0xffffffffL, 16);
     }
 
-    public static void handshaker(Fpslic.Cell cell) {
+    public static void handshaker(FpslicDevice.Cell cell) {
         cell.xlut(0x22);
         cell.ylut(0x71);
         cell.c(XLUT);
@@ -704,7 +704,7 @@ public class Demo {
         return ret;
     }
 
-    public static void bounce(Fpslic.Cell cell, int xi, int yi) {
+    public static void bounce(FpslicDevice.Cell cell, int xi, int yi) {
         cell.xlut((byte)0xCC);
         cell.ylut((byte)0xCC);
         cell.xi(xi);
@@ -712,7 +712,7 @@ public class Demo {
         cell.xo(false);
         cell.yo(false);
     }
-    public static void muller(Fpslic.Cell cell, int xi, int yi) {
+    public static void muller(FpslicDevice.Cell cell, int xi, int yi) {
         cell.ylut(0xB2);
         cell.c(YLUT);
         cell.f(false);
@@ -724,7 +724,7 @@ public class Demo {
     }
 
     /** watches for a rising/falling edge on Yin, emits a pulse on Xout */
-    public static void pulse_detect(Fpslic.Cell c, int in, boolean falling) {
+    public static void pulse_detect(FpslicDevice.Cell c, int in, boolean falling) {
         c.ylut(0x00);
         c.xlut(0x00);
         switch(in) {
@@ -749,7 +749,7 @@ public class Demo {
     }
 
     /** watches for a pulse on Xin, copies value of Yin */
-    public static void pulse_copy(Fpslic.Cell cell, int xi, int yi, boolean invert) {
+    public static void pulse_copy(FpslicDevice.Cell cell, int xi, int yi, boolean invert) {
         loopback(cell, YLUT);
         if (!invert) cell.ylut(0xB8);   /* yo = x ?  yi : z => 1011 1000 */
         else         cell.ylut(0x74);   /* yo = x ? !yi : z => 0111 0100 */
@@ -759,7 +759,7 @@ public class Demo {
         cell.yi(yi);
     }
 
-    public static void loopback(Fpslic.Cell cell, int cin) {
+    public static void loopback(FpslicDevice.Cell cell, int cin) {
         cell.f(false);
         cell.b(false);
         cell.t(false, false, true);
@@ -768,9 +768,9 @@ public class Demo {
         cell.c(cin);
     }
 
-    public static void doit(Fpslic at40k, FtdiBoard device) throws Exception {
+    public static void doit(FpslicDevice at40k, SlipwayBoard device) throws Exception {
 
-        Fpslic.Cell led = at40k.cell(1, 23);
+        FpslicDevice.Cell led = at40k.cell(1, 23);
         led.v(L2, true);
         led.h(L2, false);
         led.yi(L2);
@@ -778,7 +778,7 @@ public class Demo {
         led.xlut(LUT_SELF);
         led.yo(false);
 
-        Fpslic.Cell c = at40k.cell(1, 22);
+        FpslicDevice.Cell c = at40k.cell(1, 22);
         c.out(L1, true);
         c.out(L0, true);
         c.oe(V4);
@@ -794,7 +794,7 @@ public class Demo {
         c.c(YLUT);
 
         for(int i=0; i<4; i++) at40k.cell(i, 20).h(L0, false);
-        Fpslic.Cell z = at40k.cell(1, 20);
+        FpslicDevice.Cell z = at40k.cell(1, 20);
         z.out(L0, true);
         z.xlut(0xff);
         z.c(XLUT);
@@ -926,7 +926,7 @@ public class Demo {
     }
 
     public static int yofs = mullers ? 19 : 22;
-    public static void counter(Fpslic at40k, FtdiBoard device) throws Exception {
+    public static void counter(FpslicDevice at40k, SlipwayBoard device) throws Exception {
         // watch for rising edge from south, emit pulse on Xout (to NE)
         //copy(at40k.cell(16,23), SW, WEST);
         
@@ -967,43 +967,43 @@ public class Demo {
 
     }
 
-    public static void fill(Fpslic at40k, FtdiBoard device, int num) throws Exception {
+    public static void fill(FpslicDevice at40k, SlipwayBoard device, int num) throws Exception {
         //muller(at40k.cell(PIPELEN,22), NE, WEST);
-        Fpslic.Cell a = at40k.cell(10,22);
-        Fpslic.Cell b = at40k.cell(11,22);
+        FpslicDevice.Cell a = at40k.cell(10,22);
+        FpslicDevice.Cell b = at40k.cell(11,22);
         a.ylut(0x00);
         for(int i=0; i<num; i++) {
             //System.out.println(i);
             b.lut(0xff, 0xff);
-            device.flush();
+            at40k.flush();
             try { Thread.sleep(1); } catch (Exception e) { }
             b.lut(0x00, 0x00);
-            device.flush();
+            at40k.flush();
             try { Thread.sleep(1); } catch (Exception e) { }
         }
         b.ylut(0xB2);
         a.ylut(0xB2);
     }
 
-    public static void drain(Fpslic at40k, FtdiBoard device) throws Exception {
-        Fpslic.Cell a = at40k.cell(10,22);
-        Fpslic.Cell b = at40k.cell(11,22);
+    public static void drain(FpslicDevice at40k, SlipwayBoard device) throws Exception {
+        FpslicDevice.Cell a = at40k.cell(10,22);
+        FpslicDevice.Cell b = at40k.cell(11,22);
         a.lut(0x00, 0x00);
         b.lut(0x00, 0x00);
         for(int i=0; i<30; i++) {
             //System.out.println(i);
             a.lut(0xff, 0xff);
-            device.flush();
+            at40k.flush();
             try { Thread.sleep(1); } catch (Exception e) { }
             a.lut(0x00, 0x00);
-            device.flush();
+            at40k.flush();
             try { Thread.sleep(1); } catch (Exception e) { }
         }
         b.ylut(0xB2);
         a.ylut(0xB2);
     }
 
-    public static void doitx(Fpslic at40k, FtdiBoard device) throws Exception {
+    public static void doitx(FpslicDevice at40k, SlipwayBoard device) throws Exception {
         for(int i=5; i<PIPELEN+1; i++) bounce(at40k.cell(i, 23), SE,                     SOUTH);
         for(int x=5; x<PIPELEN;   x++) muller(at40k.cell(x, 22), x==PIPELEN-1 ? SE : NE, WEST);
         
similarity index 84%
rename from src/edu/berkeley/slipway/Demo2.java
rename to src/edu/berkeley/slipway/demos/Demo4.java
index 68289db..d3a06b0 100644 (file)
@@ -1,4 +1,4 @@
-package edu.berkeley.slipway;
+package edu.berkeley.slipway.demos;
 
 import static java.awt.event.KeyEvent.*;
 import edu.berkeley.slipway.*;
@@ -12,16 +12,17 @@ import java.awt.color.*;
 import org.ibex.util.*;
 import java.io.*;
 import java.util.*;
-import gnu.io.*;
 
-public class Demo2 implements KeyListener {
+public class Demo4 implements KeyListener {
 
     public static void main(String[] s) throws Exception {
-        new Demo2().go(); 
+        new Demo4().go(); 
     }
-    public FtdiBoard device;
-    public Demo2() throws Exception {
-        device = new FtdiBoard();
+    public SlipwayBoard board;
+    public FpslicDevice device;
+    public Demo4() throws Exception {
+        board = new SlipwayBoard();
+        device = (FpslicDevice)board.getDevice();
     }
     public void go() throws Exception {
         long begin = System.currentTimeMillis();
@@ -33,7 +34,7 @@ public class Demo2 implements KeyListener {
 
         Log.info(Demo.class, "issuing command");
 
-        Fpslic.Cell root = device.cell(5,5);
+        FpslicDevice.Cell root = device.cell(5,5);
 
         root.ylut(LUT_SELF);
         root.yi(NORTH);
@@ -64,7 +65,7 @@ public class Demo2 implements KeyListener {
         //root = root.n();
 
         device.iob_bot(12, false).enableOutput(NW);
-        Fpslic.Cell c = device.cell(12, 0);
+        FpslicDevice.Cell c = device.cell(12, 0);
         c.xo(c.east());
         while(c.east() != null && c.east().east() != null) {
             c.yo(c.east());
@@ -72,7 +73,7 @@ public class Demo2 implements KeyListener {
         }
         device.flush();
 
-        Fpslic.Cell div = device.cell(19, 21);
+        FpslicDevice.Cell div = device.cell(19, 21);
         while(true) {
             AsyncPaperDemo.divider(div);
             div = div.south().south();
@@ -83,9 +84,9 @@ public class Demo2 implements KeyListener {
         int MAX=17;
         for(int x=2; x<MAX+1; x++) {
             c = device.cell(x, 20);
-            Fpslic.Cell bridge = x==2 ? c.sw()    : c.nw();
-            Fpslic.Cell pred   = x==MAX ? c.south() : c.east();
-            Fpslic.Cell next   = x==2 ? c.south() : c.west();
+            FpslicDevice.Cell bridge = x==2 ? c.sw()    : c.nw();
+            FpslicDevice.Cell pred   = x==MAX ? c.south() : c.east();
+            FpslicDevice.Cell next   = x==2 ? c.south() : c.west();
             muller(c, pred, bridge, next);
 
             c = c.south();
@@ -110,7 +111,7 @@ public class Demo2 implements KeyListener {
         setupScanCell();
         device.flush();
 
-        vis = new Gui3((Fpslic)device, (FtdiBoard)device);
+        vis = new Gui3(device, board);
         vis.addKeyListener(this);
         Frame fr = new Frame();
         fr.setLayout(new BorderLayout());
@@ -129,7 +130,7 @@ public class Demo2 implements KeyListener {
         }
     }
     Gui3 vis;
-    public void muller(Fpslic.Cell c, Fpslic.Cell pred, Fpslic.Cell bridge, Fpslic.Cell next) {
+    public void muller(FpslicDevice.Cell c, FpslicDevice.Cell pred, FpslicDevice.Cell bridge, FpslicDevice.Cell next) {
         bridge.yi(next);
         bridge.xlut(LUT_OTHER);
 
@@ -145,7 +146,7 @@ public class Demo2 implements KeyListener {
     }
 
     public void setupScanCell() {
-        Fpslic fpslic = (Fpslic)device;
+        FpslicDevice fpslic = (FpslicDevice)device;
         fpslic.cell(23,15).h(3, true);
         fpslic.cell(23,15).yi(L3);
         fpslic.cell(23,15).ylut(0xAA);
@@ -175,18 +176,18 @@ public class Demo2 implements KeyListener {
     }
     public void scan(final GuiCell c) {
         try {
-            final Fpslic.Cell cell = c.fpslicCell;
+            final FpslicDevice.Cell cell = (FpslicDevice.Cell)(Object)c.fpslicCell;
             scan(device, cell, YLUT, true);
             int x = cell.col;
             int y = cell.row;
-            device.readBus(new BCB(c));
+            board.readFpgaData(new BCB(c));
             scan(device, cell, YLUT, false);
         } catch (IOException e) {
             throw new RuntimeException(e);
         }
     }
 
-    public static void scan(Fpslic dev, Fpslic.Cell cell, int source, boolean setup) {
+    public static void scan(FpslicDevice dev, FpslicDevice.Cell cell, int source, boolean setup) {
         if (setup) {
             //if (source != NONE) cell.c(source);
             if (cell.b()) cell.b(false);
@@ -195,7 +196,7 @@ public class Demo2 implements KeyListener {
         if (cell.out(L3)!=setup) cell.out(L3, setup);
         if (cell.vx(L3)!=setup) cell.v(L3, setup);
 
-        Fpslic.SectorWire sw = cell.vwire(L3);
+        FpslicDevice.SectorWire sw = cell.vwire(L3);
         //System.out.println("wire is: " + sw);
 
         if (sw.row > (12 & ~0x3) && sw.north()!=null && sw.north().drives(sw))
@@ -239,7 +240,7 @@ public class Demo2 implements KeyListener {
     }
 
 
-    private class BCB extends FtdiBoard.ByteCallback {
+    private class BCB extends SlipwayBoard.ByteCallback {
         GuiCell c;
         public BCB(GuiCell c) {
             this.c = c;
@@ -1,4 +1,4 @@
-package edu.berkeley.slipway;
+package edu.berkeley.slipway.demos;
 
 import edu.berkeley.slipway.*;
 import com.atmel.fpslic.*;
@@ -11,8 +11,7 @@ import java.awt.color.*;
 import org.ibex.util.*;
 import java.io.*;
 import java.util.*;
-import gnu.io.*;
-import static edu.berkeley.slipway.Demo.*;
+import static edu.berkeley.slipway.demos.Demo.*;
 
 public class DemoVisualizer extends Frame implements KeyListener, MouseMotionListener, MouseListener {
     public static final int WIDTH = 40;
@@ -21,11 +20,11 @@ public class DemoVisualizer extends Frame implements KeyListener, MouseMotionLis
     public static final int LH = 15;
     public static final Color RED  = new Color(0xaa, 0x55, 0x55);
     public static final Color BLUE = new Color(0x55, 0x55, 0xaa);
-    private final Fpslic dev;
-    private final FtdiBoard drone;
+    private final FpslicDevice dev;
+    private final SlipwayBoard drone;
     int selx = -1;
     int sely = -1;
-    public DemoVisualizer(final Fpslic dev, final FtdiBoard drone) {
+    public DemoVisualizer(final FpslicDevice dev, final SlipwayBoard drone) {
         this.dev = dev;
         this.drone = drone;
         show();
@@ -70,15 +69,15 @@ public class DemoVisualizer extends Frame implements KeyListener, MouseMotionLis
         switch(keyevent==null ? '_' : keyevent.getKeyChar()) {
             case '1': {
                 if (selx==-1 || sely==-1) break;
-                Fpslic.Cell cell = dev.cell(selx, sely);
+                FpslicDevice.Cell cell = dev.cell(selx, sely);
                 cell.xlut(0xff);
                 cell.ylut(0xff);
                 drawCell(getGraphics(), selx, sely);
-                drone.flush();
+                dev.flush();
                 break;
             }
             case 'i': {
-                System.out.println("interrupt_count: " + drone.readCount());
+                System.out.println("interrupt_count: " + drone.readInterruptCount());
                 break;
             }
             case 'x': {
@@ -120,7 +119,7 @@ public class DemoVisualizer extends Frame implements KeyListener, MouseMotionLis
                         */
                         copy(dev.cell(mx, Demo.yofs-1), NORTH, SW);
                         boolean left = true;
-                        Fpslic.Cell lc = null;
+                        FpslicDevice.Cell lc = null;
                         for(int k=0; k<10; k++) {
                             int y = Demo.yofs-2-(k*2);
                             copy(dev.cell(left?(mx-1):mx, y),        SOUTH, left?NE:NW);
@@ -163,10 +162,10 @@ public class DemoVisualizer extends Frame implements KeyListener, MouseMotionLis
                         try { Thread.sleep(100); } catch (Exception e) { }
                         //showit(dev, drone, this);
                         fill(dev, drone, cap);
-                        drone.readCount();
+                        drone.readInterruptCount();
                         long now = System.currentTimeMillis();
                         try { Thread.sleep(4000); } catch (Exception e) { }
-                        int count = drone.readCount();
+                        int count = drone.readInterruptCount();
                         long now2 = System.currentTimeMillis();
                         System.out.println(cap + " ,  " + (((float)count * (2*2*2*2*2*2*2*2*2*1000))/(now2-now)));
                     }
@@ -175,18 +174,18 @@ public class DemoVisualizer extends Frame implements KeyListener, MouseMotionLis
             }
             case 'C': {
                 if (selx==-1 || sely==-1) break;
-                Fpslic.Cell cell = dev.cell(selx, sely);
+                FpslicDevice.Cell cell = dev.cell(selx, sely);
                 cell.ylut(0xB2);
                 drawCell(getGraphics(), selx, sely);
                 break;
             }
             case '0': {
                 if (selx==-1 || sely==-1) break;
-                Fpslic.Cell cell = dev.cell(selx, sely);
+                FpslicDevice.Cell cell = dev.cell(selx, sely);
                 cell.xlut(0x00);
                 cell.ylut(0x00);
                 drawCell(getGraphics(), selx, sely);
-                drone.flush();
+                dev.flush();
                 break;
             }
         } 
@@ -194,10 +193,10 @@ public class DemoVisualizer extends Frame implements KeyListener, MouseMotionLis
         showit(dev, drone, this);
     }
     public void mousePressed(MouseEvent e) {
-        final Fpslic.Cell cell = dev.cell(selx, sely);
+        final FpslicDevice.Cell cell = dev.cell(selx, sely);
         if (cell==null) return;
         final int old = cell.c();
-        FtdiBoard.ByteCallback bc = new FtdiBoard.ByteCallback() {
+        SlipwayBoard.ByteCallback bc = new SlipwayBoard.ByteCallback() {
                 public void call(byte b) throws Exception {
                     boolean y = (b & 0x80) != 0;
                     //cell.c(old);
@@ -235,7 +234,7 @@ public class DemoVisualizer extends Frame implements KeyListener, MouseMotionLis
         if (selx >= 0 && selx < 24 && sely >= 0 && sely < 24) {
             int cx = selx;
             int cy = sely;
-            Fpslic.Cell cell = dev.cell(cx, cy);
+            FpslicDevice.Cell cell = dev.cell(cx, cy);
             selx = -1;
             sely = -1;
             /*
@@ -246,7 +245,7 @@ public class DemoVisualizer extends Frame implements KeyListener, MouseMotionLis
         selx = (x-20)/(WIDTH+2);
         sely = (23 - (y-20)/(HEIGHT+2))+1;
         /*
-          Fpslic.Cell cell = dev.cell(selx, sely);
+          FpslicDevice.Cell cell = dev.cell(selx, sely);
           if (selx >= 0 && selx < 24 && sely >= 0 && sely < 24) {
           drawCell(getGraphics(), selx, sely);
           drawSector(getGraphics(), dev.cell(selx, sely).sector());
@@ -284,9 +283,9 @@ public class DemoVisualizer extends Frame implements KeyListener, MouseMotionLis
           }
         */
     }
-    public static int left(Fpslic.Cell cell) { return (cell.col)   *(WIDTH+2)+20; }
-    public static int top(Fpslic.Cell cell)  { return (23-cell.row)*(HEIGHT+2)+60; }
-    public void drawSector(Graphics g, Fpslic.Sector sector) {
+    public static int left(FpslicDevice.Cell cell) { return (cell.col)   *(WIDTH+2)+20; }
+    public static int top(FpslicDevice.Cell cell)  { return (23-cell.row)*(HEIGHT+2)+60; }
+    public void drawSector(Graphics g, FpslicDevice.Sector sector) {
         g.setColor(Color.gray);
         ((Graphics2D)g).setStroke(new BasicStroke(1));
         int px = ((sector.col)*(WIDTH+2))+20-1;
@@ -297,9 +296,9 @@ public class DemoVisualizer extends Frame implements KeyListener, MouseMotionLis
           boolean h = dir==0;
           for(int y=h?sector.row:sector.col; y<(h?sector.row+4:sector.col+4); y++)
           for(int plane=0; plane<=4; plane++) {
-          Fpslic.Cell cell      = h ? dev.cell(sector.col,   y) : dev.cell(y, sector.row);
-          Fpslic.Cell cell_east = h ? dev.cell(sector.col-1, y) : dev.cell(y, sector.row-1);
-          Fpslic.Cell cell_west = h ? dev.cell(sector.col+4, y) : dev.cell(y, sector.row+4);
+          FpslicDevice.Cell cell      = h ? dev.cell(sector.col,   y) : dev.cell(y, sector.row);
+          FpslicDevice.Cell cell_east = h ? dev.cell(sector.col-1, y) : dev.cell(y, sector.row-1);
+          FpslicDevice.Cell cell_west = h ? dev.cell(sector.col+4, y) : dev.cell(y, sector.row+4);
           boolean draw = false;
           if (h) {
           if (cell_east!=null &&
@@ -356,7 +355,7 @@ public class DemoVisualizer extends Frame implements KeyListener, MouseMotionLis
         int y = ((23-cy)*(HEIGHT+2))+60;
 
         //System.out.println("drawcell " + cx + "," + cy);
-        Fpslic.Cell cell = dev.cell(cx, cy);
+        FpslicDevice.Cell cell = dev.cell(cx, cy);
         g.setColor(bg);
         g.fillRect(x, y, WIDTH, HEIGHT);
 
@@ -429,7 +428,7 @@ public class DemoVisualizer extends Frame implements KeyListener, MouseMotionLis
 
     }
 
-    public static void showit(Fpslic dev, FtdiBoard drone, final DemoVisualizer vis) {
+    public static void showit(FpslicDevice dev, SlipwayBoard drone, final DemoVisualizer vis) {
         final long then = System.currentTimeMillis();
         final Graphics g = vis.getGraphics();
         g.setFont(new Font("sansserif", Font.BOLD, 24));
@@ -441,9 +440,9 @@ public class DemoVisualizer extends Frame implements KeyListener, MouseMotionLis
                 //for(int yy=21; yy<=22; yy++) {
                 final int x = xx;
                 final int y = yy;
-                final Fpslic.Cell cell = dev.cell(x, y);
+                final FpslicDevice.Cell cell = dev.cell(x, y);
                 if ((cell.ylut()&0xff)!=0xB2) continue;
-                FtdiBoard.ByteCallback bc = new FtdiBoard.ByteCallback() {
+                SlipwayBoard.ByteCallback bc = new SlipwayBoard.ByteCallback() {
                         public void call(byte b) throws Exception {
                             boolean v = (b & 0x80) != 0;
                             vis.drawCell(g, x, y, v?red:green);
index 6eb1bd6..595aebf 100644 (file)
@@ -6,7 +6,7 @@ import byucc.edif.*;
 import java.io.*;
 import java.util.*;
 import edu.berkeley.slipway.*;
-import edu.berkeley.abits.*;
+//import edu.berkeley.abits.*;
 import com.atmel.fpslic.*;
 import static com.atmel.fpslic.FpslicConstants.*;
 import static edu.berkeley.slipway.mpar.PhysicalFpslic.*;
@@ -49,7 +49,7 @@ public class MPARDemo {
         int height = 12;
 
         //SlipwayBoard slipway = new SlipwayBoard();
-        Board slipway = new FakeBoard(24, 24);
+        FakeBoard slipway = new FakeBoard(24, 24);
 
         FpslicDevice fpslic = (FpslicDevice)slipway.getDevice();
         while(true) {