## Fleeterpreter ##############################################################################
interpreter_class = edu.berkeley.fleet.interpreter.Main
-cp = -cp lib/edu.berkeley.sbp.jar -cp fleet.jar
+cp = -cp fleet.jar
java = java -Xmx500m
run: fleet.jar
cp src/edu/berkeley/fleet/assembler/fleet.g build/class/edu/berkeley/fleet/assembler/
javac -cp lib/edu.berkeley.sbp.jar -d build/class/ $(shell find src -name \*.java)
cd build/class/; jar xvf ../../lib/edu.berkeley.sbp.jar
- echo 'Main-Class: $(interpreter_class)' > build/class/manifest
+ echo 'Main-Class: edu.berkeley.fleet.Main' > build/class/manifest
cd build/class/; jar cvmf manifest ../../$@ .
remote_run += echo running;
remote_run += ./a.out /dev/selectmap1 fleet.bin
-runfpga: fleet.jar build/main.bit
+runfpga: fleet.jar
+ $(java) $(cp) $(interpreter_class) --dump-code
+ $(java) $(cp) edu.berkeley.fleet.slipway.Client < build/fleet.bin
+
+mrunfpga: fleet.jar build/main.bit
$(java) $(cp) $(interpreter_class) --dump-code
rsync -zare ssh --progress --verbose build/fleet.bin build/main.bit src/edu/berkeley/fleet/slipway/test.c root@bee441.cs.berkeley.edu:
ssh root@bee441.cs.berkeley.edu '$(remote_run)'
#ship execute : Execute
#ship fifo : Fifo
+#ship alu2_02 : Alu2
+#ship alu2_03 : Alu2
+#ship alu2_04 : Alu2
+#ship alu2_05 : Alu2
+#ship alu2_06 : Alu2
+#ship alu2_07 : Alu2
+#ship alu2_08 : Alu2
+#ship alu2_09 : Alu2
+#ship alu2_10 : Alu2
+#ship alu2_11 : Alu2
+#ship alu2_12 : Alu2
+#ship alu2_13 : Alu2
+#ship alu2_14 : Alu2
+#ship alu2_15 : Alu2
+#ship alu2_16 : Alu2
+
+#ship fifo_02 : Fifo
+#ship fifo_03 : Fifo
+#ship fifo_04 : Fifo
+#ship fifo_05 : Fifo
+#ship fifo_06 : Fifo
+#ship fifo_07 : Fifo
+#ship fifo_08 : Fifo
+#ship fifo_09 : Fifo
+#ship fifo_10 : Fifo
+#ship fifo_11 : Fifo
+#ship fifo_12 : Fifo
+#ship fifo_13 : Fifo
+#ship fifo_14 : Fifo
+#ship fifo_15 : Fifo
+#ship fifo_16 : Fifo
+
+
// alu1
// alu2
// sort2
//#ship demux1 : DeMux
//#ship demux2 : DeMux
//#ship sort : Sort2
+
--- /dev/null
+#include "contrib/demo.ships"
+
+// your solution goes here
+
+12: sendto debug.data;
+debug.data: [*] take, deliver;
+
+0: sendto alu2.op;
+1: sendto alu2.a;
+1: sendto alu2.b;
+
+alu2.a: [*] take, deliver;
+alu2.b: [*] take, deliver;
+alu2.op: [*] take, deliver;
+
+alu2.out: take, sendto debug.data;
--- /dev/null
+package edu.berkeley.fleet;
+
+public class Main {
+
+ public static void main(String[] s) throws Exception {
+ if (s.length == 0) {
+ usage();
+ System.exit(-1);
+ }
+ }
+
+ static void usage() {
+ System.err.println(".........................................................................");
+ System.err.println("Fleet Framework UC Berkeley, Sun Labs / 2007");
+ System.err.println("");
+ System.err.println("usage: java -jar fleet.jar [options] [command] [filename] [args]");
+ System.err.println("");
+ System.err.println("[options] is in the form key=val; supported keys are:");
+ System.err.println(" target={igor,fpga,interp}");
+ System.err.println(" verbose={yes,no}");
+ System.err.println("");
+ System.err.println("[command] is one of:");
+ System.err.println(" asm");
+ System.err.println(" disasm");
+ System.err.println(" typeset");
+ System.err.println(" extract [section]");
+ System.err.println(" run");
+ System.err.println("");
+ System.err.println("[filename] is one of:");
+ System.err.println(" *.fa Fleet assembler");
+ System.err.println(" *.f0 F0 code (not yet supported)");
+ System.err.println(" *.fo Fleet binary object");
+ System.err.println(" *.ship Ship description");
+ System.err.println("");
+ System.err.println("All [args] not consumed by [command] are passed to target");
+ System.err.println("");
+ }
+
+}
\ No newline at end of file
public void dump(OutputStream os, long data_) throws IOException {
int data = (int)data_;
os.write((byte)data);
- System.out.println(data);
+ //System.out.println(data);
}
public Iterator<Ship> iterator() {
--- /dev/null
+package edu.berkeley.fleet.slipway;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+
+public class Client {
+
+ public static void main(String[] args) throws Exception {
+ Socket s = new Socket(InetAddress.getByName("bee441.cs.berkeley.edu"), 3133);
+ OutputStream os = s.getOutputStream();
+ PrintWriter pw = new PrintWriter(new OutputStreamWriter(os));
+ pw.print(Server.pass_string+" main.bit\n");
+ pw.flush();
+
+ byte[] buf = new byte[1024];
+ while(true) {
+ int numread = System.in.read(buf, 0, buf.length);
+ if (numread==-1) break;
+ os.write(buf, 0, numread);
+ }
+
+ InputStream is = s.getInputStream();
+ while(true) {
+ long result = 0;
+ int val = 0;
+ for(int i=0; i<6; i++) {
+ val = is.read();
+ if (val==-1) break;
+ result |= ((long)val) << (i * 8);
+ }
+ if (val==-1) break;
+ System.err.print(result);
+ System.err.print(" 0x");
+ System.err.print(Long.toString(result, 16));
+ System.err.println();
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+package edu.berkeley.fleet.slipway;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+
+public class Server {
+
+ public static void main(String[] args) throws Exception {
+ ServerSocket ss = new ServerSocket(3133);
+ while(true) {
+ System.err.println("listening");
+ Socket s = ss.accept();
+ System.err.println("connection");
+ //new Handler(s).start();
+ new Handler(s).run();
+ }
+ }
+
+ public static String pass_string = "password=security_is_for_wimps ";
+
+ static class Handler extends Thread {
+ private Socket socket;
+ boolean closed = false;
+ public Handler(Socket s) { this.socket = s; }
+ public void run() {
+ RandomAccessFile raf = null;
+ FileInputStream fis = null;
+ try {
+
+ final InputStream is = socket.getInputStream();
+ byte[] buf = new byte[1024];
+ StringBuffer sb = new StringBuffer();
+ while(true) {
+ int i = is.read();
+ if (i==-1) return;
+ if (((char)i)=='\n') break;
+ sb.append((char)i);
+ }
+ System.err.println("login string: " + sb.toString());
+ if (!sb.toString().startsWith(pass_string)) return;
+ String file = sb.toString().substring(pass_string.length()).trim();
+
+ System.err.println("unprogramming...");
+ int ret = Runtime.getRuntime().exec(new String[] { "/usr/bin/user_unprogram", "2" }).waitFor();
+ if (ret != 0) {
+ System.err.println("programming error: " + ret);
+ return;
+ }
+ System.err.println("programming...");
+ ret = Runtime.getRuntime().exec(new String[] {
+ "/usr/bin/user_program", "2", "/var/slipway/"+file }).waitFor();
+ if (ret != 0) {
+ System.err.println("programming error: " + ret);
+ return;
+ }
+ System.err.println("done programming.");
+ try { Thread.sleep(2000); } catch(Exception e) { }
+ final OutputStream os = socket.getOutputStream();
+ System.err.println("sending instructions...");
+ raf = new RandomAccessFile("/dev/selectmap2", "rw");
+
+
+ final RandomAccessFile raf2 = raf;
+ new Thread() {
+ public void run() {
+ FileOutputStream fos = null;
+ try {
+ fos = new FileOutputStream(raf2.getFD());
+ byte[] buf = new byte[1024];
+ while(true) {
+ int numread = is.read(buf, 0, buf.length);
+ if (numread == -1) break;
+ fos.write(buf, 0, numread);
+ fos.flush();
+ }
+ } catch (Exception e) { throw new RuntimeException(e);
+ } finally {
+ if (raf2 != null) {
+ System.err.println("closing...");
+ try { raf2.close(); } catch (Throwable t) { t.printStackTrace(); }
+ try { fos.close(); } catch (Throwable t) { t.printStackTrace(); }
+ closed = true;
+ }
+ }
+ }
+ }.start();
+
+ System.err.println("reading back...");
+ fis = new FileInputStream(raf.getFD());
+ while(true) {
+ long result = 0;
+ int val = 0;
+ for(int i=0; i<6; i++) {
+ while(fis.available()==0) {
+ if (closed) return;
+ System.err.println("sleep");
+ Thread.sleep(10);
+ }
+ val = fis.read();
+ if (val==-1) break;
+ os.write((byte)val);
+ os.flush();
+ result |= ((long)val) << (i * 8);
+ }
+ if (val==-1) break;
+ System.err.print(result);
+ System.err.print(" 0x");
+ System.err.print(Long.toString(result, 16));
+ System.err.println();
+ }
+ System.err.println("done.");
+
+ } catch (Exception e) { throw new RuntimeException(e);
+ } finally {
+ try {
+ if (raf != null) {
+ System.err.println("closing...");
+ raf.close();
+ }
+ if (fis != null) fis.close();
+ } catch (Throwable t) { t.printStackTrace(); }
+ }
+ }
+ }
+
+}
\ No newline at end of file