migrate verilog into ship files
[fleet.git] / src / edu / berkeley / fleet / slipway / Slipway.java
index 5989d5f..a73fd0f 100644 (file)
@@ -1,5 +1,6 @@
 package edu.berkeley.fleet.slipway;
 import edu.berkeley.fleet.interpreter.*;
+import edu.berkeley.fleet.doc.*;
 import edu.berkeley.fleet.api.*;
 import edu.berkeley.fleet.ies44.*;
 import edu.berkeley.fleet.*;
@@ -21,15 +22,33 @@ public class Slipway extends Interpreter {
         createShip("Alu2",    "alu2c");
         createShip("Alu2",    "alu2d");
         createShip("Debug",   "debug");
-        createShip("Execute", "execute");
+        //createShip("Execute", "execute");
         createShip("Fifo",    "fifo1");
         createShip("Fifo",    "fifo2");
         createShip("Fifo",    "fifo3");
         createShip("Fifo",    "fifo4");
-        createShip("Icache",  "icache1");
-        createShip("Icache",  "icache2");
-        createShip("Dcache",  "dcache1");
-        createShip("Dcache",  "dcache2");
+        createShip("Iscratch",  "iscratch1");
+        createShip("Iscratch",  "iscratch2");
+        createShip("Dscratch",  "dscratch1");
+        createShip("Dscratch",  "dscratch2");
+        dumpFabric(true);
+    }
+
+    public Ship createShip(String type, String name) {
+        InterpreterShip ship = (InterpreterShip)super.createShip(type, name);
+        if        (ship.getClass().getSimpleName().equals("Debug")) {
+            new DataOutbox(ship, "out", true);
+            
+        } else if (ship.getClass().getSimpleName().equals("Execute")) {
+            new DataOutbox(ship, "ihorn", true, true, false);
+            new DataOutbox(ship, "dhorn", true, false, true);
+            
+        } else if (ship.getClass().getSimpleName().equals("Iscratch")) {
+            new DataInbox(ship,  "command", true);
+            new DataOutbox(ship, "ihorn",   true, true, false);
+            new DataOutbox(ship, "dhorn",   true, false, true);
+        }
+        return ship;
     }
 
     public FleetProcess run(final byte[] instructions) {
@@ -84,17 +103,17 @@ public class Slipway extends Interpreter {
         
         if (quiet) return;
         System.out.println("`include \"macros.v\"");
-        System.out.println("module fabric(clk, data_Icache0_command_r, data_Icache0_command_a, data_Icache0_command,");
+        System.out.println("module fabric(clk, data_Iscratch0_command_r, data_Iscratch0_command_a, data_Iscratch0_command,");
         System.out.println("                   data_Debug0_out_r, data_Debug0_out_a, data_Debug0_out);");
         System.out.println("  input  clk;");
-        System.out.println("  input  data_Icache0_command_r;");
-        System.out.println("  output data_Icache0_command_a;");
+        System.out.println("  input  data_Iscratch0_command_r;");
+        System.out.println("  output data_Iscratch0_command_a;");
         System.out.println("  output data_Debug0_out_r;");
         System.out.println("  input  data_Debug0_out_a;");
         System.out.println("  output [(`PACKET_WIDTH-1):0]      data_Debug0_out;");
-        System.out.println("  input  [(`PACKET_WIDTH-1):0]      data_Icache0_command;");
-        //System.out.println("  wire   [(`INSTRUCTION_WIDTH-1):0] data_Icache0_ihorn;");
-        //System.out.println("  wire   [(`PACKET_WIDTH-1):0]      data_Icache0_dhorn;");
+        System.out.println("  input  [(`PACKET_WIDTH-1):0]      data_Iscratch0_command;");
+        //System.out.println("  wire   [(`INSTRUCTION_WIDTH-1):0] data_Iscratch0_ihorn;");
+        //System.out.println("  wire   [(`PACKET_WIDTH-1):0]      data_Iscratch0_dhorn;");
         System.out.println();
         
         System.out.println();
@@ -166,7 +185,7 @@ public class Slipway extends Interpreter {
         System.out.println("funnel topfun(clk,"+
                            "              dest_r, dest_a, dest,"+
                            "              source_r, source_a, source,"+
-                           "              data_Icache0_dhorn_r, data_Icache0_dhorn_a, data_Icache0_dhorn);");
+                           "              data_Iscratch0_dhorn_r, data_Iscratch0_dhorn_a, data_Iscratch0_dhorn);");
         */
         System.out.println("assign instruction_r = ihorn_r;");
         System.out.println("assign ihorn_a = instruction_a;");
@@ -284,4 +303,19 @@ public class Slipway extends Interpreter {
         return ship.getType() + ship.getOrdinal();
     }
 
+    public void expand(ShipDescription sd) {
+        try {
+            String filename = sd.name.toLowerCase();
+            File outf = new File("src/edu/berkeley/fleet/slipway/"+filename+".v");
+            new File(outf.getParent()).mkdirs();
+            System.err.println("writing to " + outf);
+            FileOutputStream out = new FileOutputStream(outf);
+            PrintWriter pw = new PrintWriter(out);
+
+            pw.println(sd.sections.get("fpga"));
+            pw.flush();
+            pw.close();
+        } catch (Exception e) { throw new RuntimeException(e); }
+    }
+
 }
\ No newline at end of file