package edu.berkeley.obits;
import edu.berkeley.slipway.*;
+import com.atmel.fpslic.*;
import static com.atmel.fpslic.FpslicConstants.*;
import static com.atmel.fpslic.Fpslic.Util.*;
import edu.berkeley.obits.device.atmel.*;
}
public static int PIPELEN=20;
public static void main(String[] s) throws Exception {
- //AvrDrone device = new AvrDrone(detectObitsPort());
- //AvrDrone device = new AvrDrone();
- AvrDrone device = new AvrDrone(new FtdiBoard());
- At40k at40k = new At40k.At40k10(device);
+ FtdiBoard device = new FtdiBoard();
+ Fpslic at40k = device;
try {
long begin = System.currentTimeMillis();
device.readMode4(new ProgressInputStream("configuring fabric", System.in, 111740));
/*
System.out.println("a: " + at40k.new SectorWire(true, 0, 4, 0x17).driverRight());
System.out.println("b: " + at40k.new SectorWire(true, 1, 4, 0x17).driverRight());
- At40k.SectorWire h0p0 = at40k.new SectorWire(true, 0, 0, 0x17);
- At40k.SectorWire h0p1 = at40k.new SectorWire(true, 1, 0, 0x17);
- At40k.SectorWire h0p2 = at40k.new SectorWire(true, 2, 0, 0x17);
- At40k.SectorWire h4p0 = at40k.new SectorWire(true, 0, 4, 0x17);
- At40k.SectorWire h4p1 = at40k.new SectorWire(true, 1, 4, 0x17);
- At40k.SectorWire h4p2 = at40k.new SectorWire(true, 2, 4, 0x17);
+ Fpslic.SectorWire h0p0 = at40k.new SectorWire(true, 0, 0, 0x17);
+ Fpslic.SectorWire h0p1 = at40k.new SectorWire(true, 1, 0, 0x17);
+ Fpslic.SectorWire h0p2 = at40k.new SectorWire(true, 2, 0, 0x17);
+ Fpslic.SectorWire h4p0 = at40k.new SectorWire(true, 0, 4, 0x17);
+ Fpslic.SectorWire h4p1 = at40k.new SectorWire(true, 1, 4, 0x17);
+ Fpslic.SectorWire h4p2 = at40k.new SectorWire(true, 2, 4, 0x17);
//h4p1.drives(h0p1, false);
//at40k.cell(0x04, 0x17).out(L1, false);
/*
System.out.println("xlut is " + hex(at40k.cell(0x04, 0x17).xlut()));
System.out.println("ylut is " + hex(at40k.cell(0x04, 0x17).ylut()));
- At40k.Cell cell = at40k.cell(0x04, 0x17);
+ Fpslic.Cell cell = at40k.cell(0x04, 0x17);
//cell.xlut(0xff);
//cell.f(false);
System.out.println(cell.c());
at40k.iob_right(15, true).enableOutput(WEST);
- At40k.Cell c = at40k.cell(10,10);
+ Fpslic.Cell c = at40k.cell(10,10);
c.ylut(~LUT_SELF);
c.xlut(LUT_Z);
c.yi(WEST);
//at40k.cell(6,22).ylut(0xff);
//at40k.cell(22,11).ylut(0xff);
/*
- At40k.Cell cell = at40k.cell(4, 16);
+ Fpslic.Cell cell = at40k.cell(4, 16);
cell.xlut(0xff);
cell.ylut(0xff);
cell.b(false);
Visualizer v = new Visualizer(at40k, device);
v.show();
v.setSize(1380, 1080);
- At40k.Cell cell = at40k.cell(4, 23);
+ Fpslic.Cell cell = at40k.cell(4, 23);
Image img = v.createImage(v.getWidth(), v.getHeight());
/*
//int y = 11;
//selfTest(device, at40k, v);
- System.out.println("save: " + AvrDrone.save + " of " + (AvrDrone.saveof*5));
+ System.out.println("save: " + FtdiBoard.save + " of " + (FtdiBoard.saveof*5));
at40k.iob_top(0, true).enableInput();
copy(at40k.cell(0, 23), NORTH, NORTH);
} catch (Exception e) { e.printStackTrace(); }
}
- public static void scan(At40k dev, At40k.Cell cell, int source, boolean setup) {
+ public static void scan(Fpslic dev, Fpslic.Cell cell, int source, boolean setup) {
if (setup) {
if (source != NONE) cell.c(source);
if (cell.b()) cell.b(false);
if (cell.out(L3)!=setup) cell.out(L3, setup);
if (cell.vx(L3)!=setup) cell.v(L3, setup);
- At40k.SectorWire sw = cell.vwire(L3);
+ Fpslic.SectorWire sw = cell.vwire(L3);
//System.out.println("wire is: " + sw);
if (sw.row > (12 & ~0x3) && sw.north()!=null && sw.north().drives(sw))
}
- public static void copy(At40k.Cell c, int xdir, int ydir) {
+ public static void copy(Fpslic.Cell c, int xdir, int ydir) {
switch(xdir) {
case NW: case NE: case SW: case SE: {
c.xi(xdir);
return Long.toString(x & 0xffffffffL, 16);
}
- public static void handshaker(At40k.Cell cell) {
+ public static void handshaker(Fpslic.Cell cell) {
cell.xlut(0x22);
cell.ylut(0x71);
cell.c(XLUT);
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 At40k dev;
- private final AvrDrone drone;
+ private final Fpslic dev;
+ private final FtdiBoard drone;
int selx = -1;
int sely = -1;
- public Visualizer(final At40k dev, final AvrDrone drone) {
+ public Visualizer(final Fpslic dev, final FtdiBoard drone) {
this.dev = dev;
this.drone = drone;
show();
Thread.sleep(500);
if (!enabled) continue;
/*
- At40k.Cell cell = dev.cell(21, 22);
+ Fpslic.Cell cell = dev.cell(21, 22);
cell.xlut(0xff);
cell.ylut(0xff);
*/
switch(keyevent==null ? '_' : keyevent.getKeyChar()) {
case '1': {
if (selx==-1 || sely==-1) break;
- At40k.Cell cell = dev.cell(selx, sely);
+ Fpslic.Cell cell = dev.cell(selx, sely);
cell.xlut(0xff);
cell.ylut(0xff);
drawCell(getGraphics(), selx, sely);
*/
copy(dev.cell(mx, yofs-1), NORTH, SW);
boolean left = true;
- At40k.Cell lc = null;
+ Fpslic.Cell lc = null;
for(int k=0; k<10; k++) {
int y = yofs-2-(k*2);
copy(dev.cell(left?(mx-1):mx, y), SOUTH, left?NE:NW);
}
case 'C': {
if (selx==-1 || sely==-1) break;
- At40k.Cell cell = dev.cell(selx, sely);
+ Fpslic.Cell cell = dev.cell(selx, sely);
cell.ylut(0xB2);
drawCell(getGraphics(), selx, sely);
break;
}
case '0': {
if (selx==-1 || sely==-1) break;
- At40k.Cell cell = dev.cell(selx, sely);
+ Fpslic.Cell cell = dev.cell(selx, sely);
cell.xlut(0x00);
cell.ylut(0x00);
drawCell(getGraphics(), selx, sely);
showit(dev, drone, this);
}
public void mousePressed(MouseEvent e) {
- final At40k.Cell cell = dev.cell(selx, sely);
+ final Fpslic.Cell cell = dev.cell(selx, sely);
if (cell==null) return;
final int old = cell.c();
- AvrDrone.ByteCallback bc = new AvrDrone.ByteCallback() {
+ FtdiBoard.ByteCallback bc = new FtdiBoard.ByteCallback() {
public void call(byte b) throws Exception {
boolean y = (b & 0x80) != 0;
//cell.c(old);
if (selx >= 0 && selx < 24 && sely >= 0 && sely < 24) {
int cx = selx;
int cy = sely;
- At40k.Cell cell = dev.cell(cx, cy);
+ Fpslic.Cell cell = dev.cell(cx, cy);
selx = -1;
sely = -1;
/*
selx = (x-20)/(WIDTH+2);
sely = (23 - (y-20)/(HEIGHT+2))+1;
/*
- At40k.Cell cell = dev.cell(selx, sely);
+ Fpslic.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());
}
*/
}
- public static int left(At40k.Cell cell) { return (cell.col) *(WIDTH+2)+20; }
- public static int top(At40k.Cell cell) { return (23-cell.row)*(HEIGHT+2)+60; }
- public void drawSector(Graphics g, At40k.Sector sector) {
+ 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) {
g.setColor(Color.gray);
((Graphics2D)g).setStroke(new BasicStroke(1));
int px = ((sector.col)*(WIDTH+2))+20-1;
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++) {
- At40k.Cell cell = h ? dev.cell(sector.col, y) : dev.cell(y, sector.row);
- At40k.Cell cell_east = h ? dev.cell(sector.col-1, y) : dev.cell(y, sector.row-1);
- At40k.Cell cell_west = h ? dev.cell(sector.col+4, y) : dev.cell(y, sector.row+4);
+ 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);
boolean draw = false;
if (h) {
if (cell_east!=null &&
int y = ((23-cy)*(HEIGHT+2))+60;
//System.out.println("drawcell " + cx + "," + cy);
- At40k.Cell cell = dev.cell(cx, cy);
+ Fpslic.Cell cell = dev.cell(cx, cy);
g.setColor(bg);
g.fillRect(x, y, WIDTH, HEIGHT);
return ret;
}
- public static void selfTest(AvrDrone device, At40k at40k, Visualizer v) {
+ public static void selfTest(FtdiBoard device, Fpslic at40k, Visualizer v) {
/*
int fail = 0;
long now = System.currentTimeMillis();
for(int x=0; x<24; x++)
for(int y=0; y<24; y++) {
- At40k.Cell cell = at40k.cell(x,y);
+ Fpslic.Cell cell = at40k.cell(x,y);
scan(at40k, cell, YLUT, true);
//v.paint(img.getGraphics());
//v.getGraphics().drawImage(img, 0, 0, null);
*/
}
- public static void bounce(At40k.Cell cell, int xi, int yi) {
+ public static void bounce(Fpslic.Cell cell, int xi, int yi) {
cell.xlut((byte)0xCC);
cell.ylut((byte)0xCC);
cell.xi(xi);
cell.xo(false);
cell.yo(false);
}
- public static void muller(At40k.Cell cell, int xi, int yi) {
+ public static void muller(Fpslic.Cell cell, int xi, int yi) {
cell.ylut(0xB2);
cell.c(YLUT);
cell.f(false);
}
/** watches for a rising/falling edge on Yin, emits a pulse on Xout */
- public static void pulse_detect(At40k.Cell c, int in, boolean falling) {
+ public static void pulse_detect(Fpslic.Cell c, int in, boolean falling) {
c.ylut(0x00);
c.xlut(0x00);
switch(in) {
}
/** watches for a pulse on Xin, copies value of Yin */
- public static void pulse_copy(At40k.Cell cell, int xi, int yi, boolean invert) {
+ public static void pulse_copy(Fpslic.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 */
cell.yi(yi);
}
- public static void loopback(At40k.Cell cell, int cin) {
+ public static void loopback(Fpslic.Cell cell, int cin) {
cell.f(false);
cell.b(false);
cell.t(false, false, true);
cell.xo(false);
cell.c(cin);
}
- public static void doit(At40k at40k, AvrDrone device) throws Exception {
+ public static void doit(Fpslic at40k, FtdiBoard device) throws Exception {
- At40k.Cell led = at40k.cell(1, 23);
+ Fpslic.Cell led = at40k.cell(1, 23);
led.v(L2, true);
led.h(L2, false);
led.yi(L2);
led.xlut(LUT_SELF);
led.yo(false);
- At40k.Cell c = at40k.cell(1, 22);
+ Fpslic.Cell c = at40k.cell(1, 22);
c.out(L1, true);
c.out(L0, true);
c.oe(V4);
c.c(YLUT);
for(int i=0; i<4; i++) at40k.cell(i, 20).h(L0, false);
- At40k.Cell z = at40k.cell(1, 20);
+ Fpslic.Cell z = at40k.cell(1, 20);
z.out(L0, true);
z.xlut(0xff);
z.c(XLUT);
}
public static int yofs = mullers ? 19 : 22;
- public static void counter(At40k at40k, AvrDrone device) throws Exception {
+ public static void counter(Fpslic at40k, FtdiBoard device) throws Exception {
// watch for rising edge from south, emit pulse on Xout (to NE)
//copy(at40k.cell(16,23), SW, WEST);
//at40k.iob_top(1, false).slew(SLOW);
}
- public static void fill(At40k at40k, AvrDrone device, int num) throws Exception {
+ public static void fill(Fpslic at40k, FtdiBoard device, int num) throws Exception {
//muller(at40k.cell(PIPELEN,22), NE, WEST);
- At40k.Cell a = at40k.cell(10,22);
- At40k.Cell b = at40k.cell(11,22);
+ Fpslic.Cell a = at40k.cell(10,22);
+ Fpslic.Cell b = at40k.cell(11,22);
a.ylut(0x00);
for(int i=0; i<num; i++) {
//System.out.println(i);
b.ylut(0xB2);
a.ylut(0xB2);
}
- public static void showit(At40k dev, AvrDrone drone, final Visualizer vis) {
+ public static void showit(Fpslic dev, FtdiBoard drone, final Visualizer vis) {
final long then = System.currentTimeMillis();
final Graphics g = vis.getGraphics();
g.setFont(new Font("sansserif", Font.BOLD, 24));
//for(int yy=21; yy<=22; yy++) {
final int x = xx;
final int y = yy;
- final At40k.Cell cell = dev.cell(x, y);
+ final Fpslic.Cell cell = dev.cell(x, y);
if ((cell.ylut()&0xff)!=0xB2) continue;
- AvrDrone.ByteCallback bc = new AvrDrone.ByteCallback() {
+ FtdiBoard.ByteCallback bc = new FtdiBoard.ByteCallback() {
public void call(byte b) throws Exception {
boolean v = (b & 0x80) != 0;
vis.drawCell(g, x, y, v?red:green);
}
}
}
- public static void drain(At40k at40k, AvrDrone device) throws Exception {
- At40k.Cell a = at40k.cell(10,22);
- At40k.Cell b = at40k.cell(11,22);
+ public static void drain(Fpslic at40k, FtdiBoard device) throws Exception {
+ Fpslic.Cell a = at40k.cell(10,22);
+ Fpslic.Cell b = at40k.cell(11,22);
a.lut(0x00, 0x00);
b.lut(0x00, 0x00);
for(int i=0; i<30; i++) {
b.ylut(0xB2);
a.ylut(0xB2);
}
- public static void doitx(At40k at40k, AvrDrone device) throws Exception {
+ public static void doitx(Fpslic at40k, FtdiBoard 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);