1 package edu.berkeley.fleet.fpga;
3 import static edu.berkeley.fleet.util.BitManipulations.*;
4 import edu.berkeley.fleet.api.*;
8 import java.util.concurrent.*;
9 import static edu.berkeley.fleet.api.Instruction.Set.*;
10 import static edu.berkeley.fleet.api.Predicate.*;
11 import static edu.berkeley.fleet.api.Instruction.*;
14 public class Client extends FleetProcess {
17 private BlockingQueue<BitVector> queue = new LinkedBlockingQueue<BitVector>();
19 public void invokeInstruction(Instruction i) {
20 throw new RuntimeException("not implemented");
23 public static long signExtend(long val) {
24 if ((val & (1L << 36)) != 0)
25 val = val | (0xffffffffffffffffL << 36);
29 public Dock getDebugInputDock() {
30 throw new RuntimeException();
32 public BitVector readWord() {
34 throw new RuntimeException("this fleet has been terminated");
37 } catch (InterruptedException e) { throw new RuntimeException(e); }
40 protected void _terminate() {
43 } catch (Exception e) { e.printStackTrace(); }
48 public Client(Fpga fpga, String bitfile, Instruction[] instructions) throws Exception {
51 s = new Socket(InetAddress.getByName("goliath.megacz.com"), 3133);
52 OutputStream os = new BufferedOutputStream(s.getOutputStream());
53 PrintWriter pw = new PrintWriter(new OutputStreamWriter(os));
54 pw.print(Server.pass_string+" "+bitfile+"\n");
57 DataOutputStream dos = new DataOutputStream(os);
58 for(Instruction inst : instructions)
59 fpga.writeInstruction(dos, fpga.getUniversalSource(), inst);
62 final InputStream is = new BufferedInputStream(s.getInputStream());
69 for(int i=0; i<6; i++) {
72 long val2 = (val & 0xffL);
73 val2 = val2 << (i * 8);
77 BitVector bs = new BitVector(37);
78 for(int i=0; i<37; i++)
79 bs.set(i, ((result >> i) & 1L)!=0);
82 } catch (SocketException e) {
83 } catch (Exception e) { throw new RuntimeException(e);
84 } finally { terminate(); }
89 public void dispatchInstruction(Instruction i) { throw new RuntimeException(); }
90 private static Move discard(Dock dock) { return new Move(dock, false, IgnoreOLC, false, null, false, true, false, false, false, false); }
91 private static Move deliver(Dock dock) { return new Move(dock, false, IgnoreOLC, false, null, false, false, false, false, true, false); }
92 private static Move wait(Dock dock) { return new Move(dock, false, IgnoreOLC, false, null, true, false, false, false, false, false); }
93 private static Move sendto(Dock dock, Path path) { return new Move(dock, false, IgnoreOLC, false, path, false, false, false, false, true, false); }