Fpga.java: update mix of ships
[fleet.git] / src / edu / berkeley / fleet / fpga / Fpga.java
index 70f83fe..20567ed 100644 (file)
@@ -13,7 +13,7 @@ import java.io.*;
 import edu.berkeley.fleet.two.*;
 import static edu.berkeley.fleet.two.FleetTwoFleet.*;
 import static edu.berkeley.fleet.fpga.verilog.Verilog.*;
-import static edu.berkeley.fleet.fpga.verilog.Verilog.PercolatedPort;
+import edu.berkeley.fleet.two.PercolatedPort;
 
 
 public class Fpga extends FleetTwoFleet {
@@ -64,7 +64,7 @@ public class Fpga extends FleetTwoFleet {
     // Setup //////////////////////////////////////////////////////////////////////////////
 
     Ship createShip(String type) throws IOException {
-        ShipDescription sd = new ShipDescription(type, new BufferedReader(new InputStreamReader(new FileInputStream("ships/"+type+".ship"))));
+        ShipDescription sd = new ShipDescription(this, type, new BufferedReader(new InputStreamReader(new FileInputStream("ships/"+type+".ship"))));
         int count = 0;
         for(Ship ship : ships.values()) if (ship.getType().equals(type)) count++;
         String name = type+count;
@@ -78,34 +78,37 @@ public class Fpga extends FleetTwoFleet {
         this.top = top;
         debugShip = createShip("Debug");
 
-        boolean small = true;
-        //boolean small = false;
+        //boolean small = true;
+        boolean small = false;
 
         if (small) {
+            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");
-            for(int i=0; i<2; i++) createShip("Alu");
             createShip("Counter");
             createShip("CarrySaveAdder");
             createShip("Rotator");
             createShip("Lut3");
-            createShip("DDR2");
+
         } else {
-            for(int i=0; i<3; i++)  createShip("Memory");
-            for(int i=0; i<3; i++)  createShip("Alu");
-            for(int i=0; i<2; i++)  createShip("Fifo");
-            for(int i=0; i<14; i++) createShip("Counter");
 
-            // "really big" configuration: 138 docks
-            for(int i=0; i<4; i++)  createShip("Alu");
+            for(int i=0; i<2; i++)  createShip("Memory");
+            for(int i=0; i<6; i++)  createShip("Alu");
+            //for(int i=0; i<2; i++)  createShip("Fifo");
+            for(int i=0; i<12; i++) createShip("Counter");
+            //for(int i=0; i<2; i++)  createShip("Null");
+
             //createShip("CarrySaveAdder");
             //createShip("Rotator");
-            //createShip("Lut3");
+            createShip("Random");
+            createShip("Button");
 
-            createShip("DDR2");
-            //createShip("Video");
         }
 
+        createShip("Timer");
+        createShip("DDR2");
+        createShip("Dvi");
+
         // for FifoShip
         new Module.InstantiatedModule(top, new FifoModule(8, WIDTH_WORD));
 
@@ -127,6 +130,7 @@ public class Fpga extends FleetTwoFleet {
                 final Module.SourcePort sp = sp0;
                 sources.add(new FabricElement.AbstractFabricElement() {
                         private FabricElement upstream;
+                        public int      getPathLength(FpgaDestination dest) { return upstream.getPathLength(dest); }
                         public FpgaPath getPath(FpgaDestination dest, BitVector signal) { return upstream.getPath(dest, signal); }
                         public void addOutput(FabricElement out, Module.Port outPort) {
                             this.upstream = out;
@@ -162,6 +166,16 @@ public class Fpga extends FleetTwoFleet {
         try {
             if (sd.getSection("fpga")==null) return;
             String filename = sd.getName().toLowerCase();
+
+            if (sd.getSection("ucf") != null) {
+                File outf = new File("build/fpga/"+filename+".ucf");
+                FileOutputStream out = new FileOutputStream(outf);
+                PrintWriter pw = new PrintWriter(out);
+                pw.println(sd.getSection("ucf"));
+                pw.flush();
+                pw.close();
+            }
+
             File outf = new File("build/fpga/"+filename+".v");
             new File(outf.getParent()).mkdirs();
             System.err.println("writing to " + outf);