X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Ffleet%2Ffpga%2FBee2.java;h=5a223a141063ad234814d619a08a9d811f376afe;hb=8ef6f34f6a3eea2a8c2a60139e90fb07e3cf96de;hp=e0af6b68a6e7bf03e2392a7c9b50d283de6bb787;hpb=c2326dd4649b1b8ba1a71fcb977d871c8e7c9d3e;p=fleet.git diff --git a/src/edu/berkeley/fleet/fpga/Bee2.java b/src/edu/berkeley/fleet/fpga/Bee2.java index e0af6b6..5a223a1 100644 --- a/src/edu/berkeley/fleet/fpga/Bee2.java +++ b/src/edu/berkeley/fleet/fpga/Bee2.java @@ -10,15 +10,40 @@ import java.util.concurrent.Semaphore; public class Bee2 extends Fpga { + /* + Secondly, here is the EDK core: + + http://repository.eecs.berkeley.edu/viewvc/Projects/BEE/trunk/2/hardware/pcores/interchip_block_v1_00_a/ + + This core generates the links for both control-user and user-user using some crazy scripts possibly written by Yury. Some EDK system examples are here: + + http://repository.eecs.berkeley.edu/viewvc/Projects/BEE/trunk/2/applications/reference/MPI_demo/XPS_Ctrlfpga/ + http://repository.eecs.berkeley.edu/viewvc/Projects/BEE/trunk/2/applications/reference/MPI_demo/XPS_Userfpga/ + + You can either attempt to execute these scripts in order to generate output for your desired configuration or use already generated output for a 100 Mhz configuration as we did when we converted RAMP Blue to RDL: + + http://repository.eecs.berkeley.edu/viewvc/Projects/RAMP/tags/RAMPBlue_Final/Blue/UserFPGA/Infrastructure/Interchip/ + + You can see how we used the generated output here: + + http://repository.eecs.berkeley.edu/viewvc/Projects/RAMP/tags/RAMPBlue_Final/Blue/UserFPGA/ + + I may be able to assist you further if you run into difficulties, but my memory of how this is supposed to work is hazy at best--and I never understood the interchip core scripts anyway. + + Alex + + */ + protected String getDirName() { return "bee2"; } + public Bee2() throws IOException { for(int i=0; i<2; i++) createShip("Alu"); for(int i=0; i<1; i++) createShip("Memory"); for(int i=0; i<2; i++) createShip("Fifo"); - createShip("Random"); - createShip("Counter"); + //createShip("Random"); //createShip("CarrySaveAdder"); createShip("Rotator"); createShip("Lut3"); + createShip("Counter"); /* for(int i=0; i<2; i++) createShip("Memory"); for(int i=0; i<6; i++) createShip("Alu"); @@ -45,7 +70,7 @@ public class Bee2 extends Fpga { public void run() { try { for(String s = br.readLine(); s!=null; s=br.readLine()) - System.err.println(s); + System.err.println(" > " + s); } catch (Exception e) { throw new RuntimeException(e); } } } @@ -57,83 +82,78 @@ public class Bee2 extends Fpga { public static String pass_string = "password=security_is_for_wimps "; public static void main(String[] args) throws Exception { - int idx = Integer.parseInt(args[0]); + if (args.length != 2) { + System.err.println("usage: java " + Bee2.class.getName() + " {-client|-server} "); + System.exit(-1); + } + int idx = Integer.parseInt(args[1]); + String host = "bee2"; Process proc; - System.err.println("== unprogramming fpga " + idx); - proc = Runtime.getRuntime().exec("user_unprogram "+idx); - new Gobbler(proc.getInputStream()).start(); - proc.waitFor(); - System.err.println("== programming fpga " + idx); - proc = Runtime.getRuntime().exec("user_program "+idx+" main.bit"); - new Gobbler(proc.getInputStream()).start(); - int ret = proc.waitFor(); - if (ret!=0) System.exit(ret); - - raf = new RandomAccessFile(new File("/dev/selectmap"+idx), "rw"); - fos = new FileOutputStream(raf.getFD()); - fis = new BufferedInputStream(new FileInputStream(raf.getFD())); - ServerSocket ss = new ServerSocket(3133); - - while(true) { - System.out.println("listening..."); - Socket socket = ss.accept(); - try { - socket.setKeepAlive(true); - System.out.println("accept!"); - - //final InputStream is = new BufferedInputStream(socket.getInputStream()); - final InputStream is = socket.getInputStream(); - final OutputStream os = socket.getOutputStream(); //new BufferedOutputStream(socket.getOutputStream()); + int res; + + if (args[0].equals("-client")) { + + System.err.println("== rsyncing"); + proc = Runtime.getRuntime().exec("rsync -are ssh --progress --verbose fleet.jar build/bee2/main.bit misc/bicat.c "+host+":"); + new Gobbler(proc.getInputStream()).start(); + res = proc.waitFor(); + if (res != 0) throw new RuntimeException("nonzero exit code"); + + System.err.println("== (un)programming fpga " + idx); + proc = Runtime.getRuntime().exec("ssh "+host+" -- user_unprogram "+idx+"; user_program "+idx+" main.bit"); + new Gobbler(proc.getInputStream()).start(); + res = proc.waitFor(); + if (res != 0) throw new RuntimeException("nonzero exit code"); + + System.err.println("== launching java"); + proc = Runtime.getRuntime().exec("ssh "+host+" -- gcc -o bicat bicat.c && ./bicat /dev/selectmap"+idx); + //return proc.getInputStream(); + + } else if (args[0].equals("-server")) { + + raf = new RandomAccessFile(new File("/dev/selectmap"+idx), "rw"); + fos = new FileOutputStream(raf.getFD()); + fis = new BufferedInputStream(new FileInputStream(raf.getFD())); + + //socket.setKeepAlive(true); + //final InputStream is = new BufferedInputStream(socket.getInputStream()); + //final InputStream is = socket.getInputStream(); + //final OutputStream os = socket.getOutputStream(); //new BufferedOutputStream(socket.getOutputStream()); + + final InputStream is = System.in; + final OutputStream os = System.out; + PrintStream log = new PrintStream(new FileOutputStream("log")); - // read login string - 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); + //socket.setSoTimeout(10); + while(true) { + boolean ok = false; + while (fis.available() > 0) { + ok = true; + int val = fis.read(); + if (val==-1) break; + log.println("fpga->host: 0x"+Integer.toString(val & 0xff, 16)); + if ((val & (3<<6)) == 0) + fos.write( (1<<6) | 1); + os.write((byte)val); + os.flush(); + } + while(is.available() > 0) { + int r = is.read(); + if (r == -1) break; + ok = true; + log.println("host->fpga: 0x"+Integer.toString(r & 0xff, 16)); + fos.write(r); } - System.err.println("login string: " + sb.toString()); - if (!sb.toString().startsWith(pass_string)) return; - - socket.setSoTimeout(10); - while(true) { - boolean ok = false; - while (fis.available() > 0) { - ok = true; - int val = fis.read(); - if (val==-1) break; - System.err.println("fpga->host: 0x"+Integer.toString(val & 0xff, 16)); - if ((val & (3<<6)) == 0) - fos.write( (1<<6) | 1); - os.write((byte)val); - os.flush(); - } - try { - int r = is.read(); - if (r == -1) break; - ok = true; - System.err.println("host->fpga: 0x"+Integer.toString(r & 0xff, 16)); - fos.write(r); - } catch (SocketTimeoutException _) { } - if (!ok) { - if (socket.isOutputShutdown() || socket.isInputShutdown() || socket.isClosed() || !socket.isConnected()) { - socket.close(); - break; - } - System.err.println("flushing os..."); - os.flush(); - System.err.println("flushing fos..."); - fos.flush(); - System.err.println("sleeping..."); - Thread.sleep(10); - } + if (!ok) { + log.println("flushing os..."); + os.flush(); + log.println("flushing fos..."); + fos.flush(); + log.println("sleeping..."); + Thread.sleep(10); } - } catch (IOException e) { - e.printStackTrace(); } } } -} +} \ No newline at end of file