1 package edu.berkeley.slipway;
3 import static java.awt.event.KeyEvent.*;
4 import edu.berkeley.slipway.*;
5 import com.atmel.fpslic.*;
6 import static com.atmel.fpslic.FpslicConstants.*;
7 import static com.atmel.fpslic.FpslicUtil.*;
8 import edu.berkeley.slipway.gui.*;
10 import java.awt.event.*;
11 import java.awt.color.*;
12 import org.ibex.util.*;
17 public class Demo2 implements KeyListener {
19 public static void main(String[] s) throws Exception {
22 public FtdiBoard device;
23 public Demo2() throws Exception {
24 device = new FtdiBoard();
26 public void go() throws Exception {
27 long begin = System.currentTimeMillis();
28 //FpslicUtil.readMode4(new ProgressInputStream("configuring fabric", System.in, 111740), device);
29 long end = System.currentTimeMillis();
30 Log.info(Demo.class, "finished in " + ((end-begin)/1000) + "s");
34 Log.info(Demo.class, "issuing command");
36 Fpslic.Cell root = device.cell(5,5);
66 device.iob_bot(12, false).enableOutput(NW);
67 Fpslic.Cell c = device.cell(12, 0);
69 while(c.east() != null && c.east().east() != null) {
75 Fpslic.Cell div = device.cell(19, 21);
77 AsyncPaperDemo.divider(div);
78 div = div.south().south();
79 if (div == null) break;
84 for(int x=2; x<MAX+1; x++) {
85 c = device.cell(x, 20);
86 Fpslic.Cell bridge = x==2 ? c.sw() : c.nw();
87 Fpslic.Cell pred = x==MAX ? c.south() : c.east();
88 Fpslic.Cell next = x==2 ? c.south() : c.west();
89 muller(c, pred, bridge, next);
92 bridge = x==MAX ? c.ne() : c.se();
93 pred = x==2 ? c.north() : c.west();
94 next = x==MAX ? c.north() : c.east();
95 muller(c, pred, bridge, next);
97 //device.cell(MAX+0,20).yi(WEST);
98 //device.cell(MAX+0,20).ylut(LUT_SELF);
99 //device.cell(MAX+1,20).yi(WEST);
100 //device.cell(MAX+1,20).ylut(LUT_SELF);
101 device.cell(MAX+2,20).yi(WEST);
102 device.cell(MAX+2,20).ylut(LUT_SELF);
103 device.cell(MAX+2,20).xlut(LUT_OTHER);
104 device.cell(18,20).ylut(LUT_SELF);
109 public void go2() throws Exception {
113 vis = new Gui3((Fpslic)device, (FtdiBoard)device);
114 vis.addKeyListener(this);
115 Frame fr = new Frame();
116 fr.setLayout(new BorderLayout());
117 fr.add(vis, BorderLayout.CENTER);
119 fr.setSize(900, 900);
123 //synchronized(Demo.class) { Demo.class.wait(); }
125 try { Thread.sleep(500); } catch (Exception e) { }
132 public void muller(Fpslic.Cell c, Fpslic.Cell pred, Fpslic.Cell bridge, Fpslic.Cell next) {
134 bridge.xlut(LUT_OTHER);
142 c.ylut((LUT_SELF & ~LUT_OTHER) |
143 (LUT_Z & ~LUT_OTHER) |
147 public void setupScanCell() {
148 Fpslic fpslic = (Fpslic)device;
149 fpslic.cell(23,15).h(3, true);
150 fpslic.cell(23,15).yi(L3);
151 fpslic.cell(23,15).ylut(0xAA);
152 fpslic.iob_right(15, true).enableOutput(WEST);
154 fpslic.cell(23,0).ylut(0x00);
155 fpslic.iob_right(0, true).enableOutput(WEST);
159 public void keyTyped(KeyEvent k) { }
160 public void keyReleased(KeyEvent k) { }
161 public void keyPressed(KeyEvent k) {
162 switch(k.getKeyCode()) {
169 for(int x=0; x<4; x++)
170 for(int y=0; y<4; y++)
172 for(int x=0; x<4; x++)
173 for(int y=0; y<4; y++)
176 public void scan(final GuiCell c) {
178 final Fpslic.Cell cell = c.fpslicCell;
179 scan(device, cell, YLUT, true);
182 device.readBus(new BCB(c));
183 scan(device, cell, YLUT, false);
184 } catch (IOException e) {
185 throw new RuntimeException(e);
189 public static void scan(Fpslic dev, Fpslic.Cell cell, int source, boolean setup) {
191 //if (source != NONE) cell.c(source);
192 if (cell.b()) cell.b(false);
193 if (cell.f()) cell.f(false);
195 if (cell.out(L3)!=setup) cell.out(L3, setup);
196 if (cell.vx(L3)!=setup) cell.v(L3, setup);
198 Fpslic.SectorWire sw = cell.vwire(L3);
199 //System.out.println("wire is: " + sw);
201 if (sw.row > (12 & ~0x3) && sw.north()!=null && sw.north().drives(sw))
202 sw.north().drives(sw, false);
203 while(sw.row > (12 & ~0x3) && sw.south() != null) {
204 //System.out.println(sw + " -> " + sw.south());
205 if (sw.drives(sw.south())!=setup) sw.drives(sw.south(), setup);
208 if (sw.row < (12 & ~0x3) && sw.south() != null && sw.south().drives(sw))
209 sw.north().drives(sw, false);
210 while(sw.row < (12 & ~0x3) && sw.north() != null) {
211 //System.out.println(sw + " -> " + sw.north());
212 if (sw.drives(sw.north())!=setup) sw.drives(sw.north(), setup);
216 //cell = dev.cell(19, 15);
217 cell = dev.cell(cell.col, 15);
219 System.out.println("cell is " + cell);
228 if (cell.hx(L3) != setup) cell.h(L3, setup);
229 if (cell.vx(L3) != setup) cell.v(L3, setup);
232 if (sw.west()!=null && sw.west().drives(sw)) { sw.west().drives(sw, false); }
233 while(sw.east() != null) {
234 //System.out.println(sw + " -> " + sw.east());
235 if (sw.drives(sw.east())!=setup) sw.drives(sw.east(), setup);
242 private class BCB extends FtdiBoard.ByteCallback {
244 public BCB(GuiCell c) {
247 public void call(byte b) throws Exception {
248 boolean on = (b & 0x80) != 0;