1 package edu.berkeley.slipway.demos;
3 import edu.berkeley.slipway.*;
4 import static java.awt.event.KeyEvent.*;
5 import com.atmel.fpslic.*;
6 import static com.atmel.fpslic.FpslicConstants.*;
7 import edu.berkeley.slipway.gui.*;
9 import java.awt.event.*;
10 import java.awt.color.*;
11 import org.ibex.util.*;
15 public class Demo2 implements KeyListener {
17 public static void main(String[] s) throws Exception {
20 public SlipwayBoard slipway;
21 public Demo2() throws Exception {
22 slipway = new SlipwayBoard();
24 public void go() throws Exception {
25 long begin = System.currentTimeMillis();
26 long end = System.currentTimeMillis();
27 Log.info(Demo.class, "finished in " + ((end-begin)/1000) + "s");
31 Log.info(Demo.class, "issuing command");
33 FpslicDevice device = slipway.getFpslicDevice();
34 FpslicDevice.Cell root = device.cell(5,5);
64 device.iob_bot(12, false).enableOutput(NW);
65 FpslicDevice.Cell c = device.cell(12, 0);
67 while(c.east() != null && c.east().east() != null) {
73 FpslicDevice.Cell div = device.cell(19, 21);
75 div = ExperimentUtils.divider(div);
79 for(int x=2; x<MAX+1; x++) {
80 c = device.cell(x, 20);
81 FpslicDevice.Cell bridge = x==2 ? c.sw() : c.nw();
82 FpslicDevice.Cell pred = x==MAX ? c.south() : c.east();
83 FpslicDevice.Cell next = x==2 ? c.south() : c.west();
84 muller(c, pred, bridge, next);
87 bridge = x==MAX ? c.ne() : c.se();
88 pred = x==2 ? c.north() : c.west();
89 next = x==MAX ? c.north() : c.east();
90 muller(c, pred, bridge, next);
92 //device.cell(MAX+0,20).yi(WEST);
93 //device.cell(MAX+0,20).ylut(LUT_SELF);
94 //device.cell(MAX+1,20).yi(WEST);
95 //device.cell(MAX+1,20).ylut(LUT_SELF);
96 device.cell(MAX+2,20).yi(WEST);
97 device.cell(MAX+2,20).ylut(LUT_SELF);
98 device.cell(MAX+2,20).xlut(LUT_OTHER);
99 device.cell(18,20).ylut(LUT_SELF);
104 public void go2() throws Exception {
105 FpslicDevice device = slipway.getFpslicDevice();
109 vis = new Gui3(device, slipway);
110 vis.addKeyListener(this);
111 Frame fr = new Frame();
112 fr.setLayout(new BorderLayout());
113 fr.add(vis, BorderLayout.CENTER);
115 fr.setSize(900, 900);
119 //synchronized(Demo.class) { Demo.class.wait(); }
121 try { Thread.sleep(500); } catch (Exception e) { }
128 public void muller(FpslicDevice.Cell c, FpslicDevice.Cell pred, FpslicDevice.Cell bridge, FpslicDevice.Cell next) {
129 FpslicDevice device = slipway.getFpslicDevice();
131 bridge.xlut(LUT_OTHER);
139 c.ylut((LUT_SELF & ~LUT_OTHER) |
140 (LUT_Z & ~LUT_OTHER) |
144 public void setupScanCell() {
145 FpslicDevice device = slipway.getFpslicDevice();
146 FpslicDevice fpslic = (FpslicDevice)device;
147 fpslic.cell(23,15).h(3, true);
148 fpslic.cell(23,15).yi(L3);
149 fpslic.cell(23,15).ylut(0xAA);
150 fpslic.iob_right(15, true).enableOutput(WEST);
152 fpslic.cell(23,0).ylut(0x00);
153 fpslic.iob_right(0, true).enableOutput(WEST);
157 public void keyTyped(KeyEvent k) { }
158 public void keyReleased(KeyEvent k) { }
159 public void keyPressed(KeyEvent k) {
160 switch(k.getKeyCode()) {
167 for(int x=0; x<4; x++)
168 for(int y=0; y<4; y++)
170 for(int x=0; x<4; x++)
171 for(int y=0; y<4; y++)
174 public void scan(final GuiCell c) {
176 final FpslicDevice.Cell cell = (FpslicDevice.Cell)c.fpslicCell;
177 scan(slipway, cell, YLUT, true);
180 slipway.readFpgaData(new BCB(c));
181 scan(slipway, cell, YLUT, false);
182 } catch (IOException e) {
183 throw new RuntimeException(e);
187 public static void scan(SlipwayBoard slipway, FpslicDevice.Cell cell, int source, boolean setup) {
188 ExperimentUtils.scan(cell, source, setup);
192 private class BCB extends SlipwayBoard.ByteCallback {
194 public BCB(GuiCell c) {
197 public void call(byte b) throws Exception {
198 boolean on = (b & 0x80) != 0;