some cleanups, build fpga stuff in build/fpga, not src
authoradam <adam@megacz.com>
Mon, 20 Aug 2007 07:53:40 +0000 (08:53 +0100)
committeradam <adam@megacz.com>
Mon, 20 Aug 2007 07:53:40 +0000 (08:53 +0100)
Makefile
ships/Alu2b.ship [deleted file]
src/edu/berkeley/fleet/fpga/Fpga.java
src/edu/berkeley/fleet/fpga/Generator.java

index 1c1408c..0bae854 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -25,7 +25,7 @@ fleet.jar: $(shell find src -name \*.java) $(shell find ships -name \*.ship) src
        cd build/class/; jar cmf manifest ../../$@ .
 
 
-## Slipway ####################################################################################
+## Fpga ####################################################################################
 
 #host = sting.eecs.berkeley.edu
 #remote_xilinx = /opt/ISE81/
@@ -39,7 +39,7 @@ remote_dir = /scratch/megacz/fleet/
 #remote_xilinx = /scratch/megacz/xilinx/
 #remote_dir = /scratch/megacz/fleet/
 
-xilinx =  cd build; 
+xilinx =  cd build/fpga;
 xilinx += LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:$(XILINX)/bin/lin
 xilinx += XILINX=$(XILINX)
 xilinx += PATH=$$PATH:$(XILINX)/bin/lin
@@ -69,28 +69,29 @@ uploadtest:
 testmegacz:
        $(java) -jar fleet.jar target=fpga bitfile=megacz.bit test ships/*.ship tests
 
-build/fabric.v: $(verilog_files) src/edu/berkeley/fleet/slipway/Slipway.java
+build/fpga/fabric.v: $(verilog_files) src/edu/berkeley/fleet/fpga/Fpga.java
        make fleet.jar
-       mkdir -p build
-       $(java) $(cp) edu.berkeley.fleet.slipway.Slipway > build/fabric.v
+       mkdir -p build/fpga
+       $(java) $(cp) edu.berkeley.fleet.fpga.Fpga > build/fpga/fabric.v
 
-build/main.bit: build/fabric.v $(verilog_files)
+build/main.bit: build/fpga/fabric.v $(verilog_files)
        make fleet.jar
+       cp src/edu/berkeley/fleet/fpga/* build/fpga
        for A in `find ships -name \*.ship`;\
          do java -cp build/class edu.berkeley.fleet.Main target=fpga expand $$A;\
          done
-       $(java) -cp fleet.jar edu.berkeley.fleet.slipway.Generator
+       $(java) -cp fleet.jar edu.berkeley.fleet.fpga.Generator build/fpga/
        rsync -zare ssh --progress --delete --verbose ./ ${host}:${remote_dir}
        time ssh ${host} 'make -C ${remote_dir} synth XILINX=${remote_xilinx}'
        scp ${host}:${remote_dir}/build/main.bit build/
 
 synth:
-       cd build; ln -sf ../src/edu/berkeley/fleet/slipway/* .
-       cd build; echo work > main.lso
-       cd build; for A in *.v; do echo verilog work \""$$A"\"; done > main.prj
-       cd build; mkdir -p tmp
-       cd build; mkdir -p xst
-       rm -rf build/_ngo
+       cd build/fpga; ln -sf ../src/edu/berkeley/fleet/fpga/* .
+       cd build/fpga; echo work > main.lso
+       cd build/fpga; for A in *.v; do echo verilog work \""$$A"\"; done > main.prj
+       cd build/fpga; mkdir -p tmp
+       cd build/fpga; mkdir -p xst
+       rm -rf build/fpga/_ngo
        $(xilinx)xst -intstyle xflow -ifn main.xst -ofn main.syr < main.xst
        $(xilinx)ngdbuild -intstyle xflow -dd _ngo -nt timestamp -uc main.ucf -p xc2vp70-ff1704-6 main.ngc main.ngd
        $(xilinx)map -intstyle xflow -p xc2vp70-ff1704-6 -cm speed -l -pr b -k 4 -c 100 -tx off -o main_map.ncd main.ngd main.pcf
@@ -109,7 +110,7 @@ test:     fleet.jar; $(java) -jar fleet.jar             test ships/*.ship tests
 testfpga: fleet.jar; $(java) -jar fleet.jar target=fpga test ships/*.ship tests
 
 generate: fleet.jar
-       $(java) -cp fleet.jar edu.berkeley.fleet.slipway.Generator
+       $(java) -cp fleet.jar edu.berkeley.fleet.fpga.Generator build/fpga/
 
 ## API docs ####################################################################################
 
diff --git a/ships/Alu2b.ship b/ships/Alu2b.ship
deleted file mode 100644 (file)
index 29e7eb7..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-ship: Alu2b
-
-== Ports ===========================================================
-data  in:   in1.add
-data  in:   in1.sub
-data  in:   in1.max
-data  in:   in1.min
-
-data  in:   in2
-
-data  out:  out
-
-== Constants ========================================================
-
-== TeX ==============================================================
-This ship is a two-input arithmetic unit.  The first input is split
-into multiple virtual destinations that control the operation to be
-performed.
-
-== Fleeterpreter ====================================================
-public void service() {
-  if (!box_out.readyForDataFromShip() ||
-      !box_in1.dataReadyForShip() ||
-      !box_in2.dataReadyForShip()) return;
-
-  Packet selector = box_in1.removePacketForShip();
-  String port = selector.destination.getDestinationName();
-  long a      = selector.value;
-  long b      = box_in2.removeDataForShip();
-
-  if (port.equals("add")) {
-    box_out.addDataFromShip(a+b); // ADD
-  } else if (port.equals("sub")) {
-    box_out.addDataFromShip(a-b); // SUB
-  } else if (port.equals("max")) {
-    box_out.addDataFromShip(Math.max(a,b)); // MAX
-  } else if (port.equals("min")) {
-    box_out.addDataFromShip(Math.min(a,b)); // MIN
-  } else {
-    box_out.addDataFromShip(0);
-  }
-}
-
-== FleetSim ==============================================================
-
-== FPGA ==============================================================
-
-  reg                    have_a;
-  reg [(`PACKET_WIDTH-1):0] reg_a;
-  reg                    have_b;
-  reg [(`DATAWIDTH-1):0] reg_b;
-
-  reg a_val;
-
-  always @(posedge clk) begin
-    if (!have_a) begin
-      `onread(in1_r, in1_a) have_a = 1; reg_a = in1_d; end
-      end
-    if (!have_b) begin
-      `onread(in2_r, in2_a) have_b = 1; reg_b = in2_d; end
-      end
-  
-    if (have_a && have_b) begin
-      a_val = reg_a[`DATAWIDTH-1:0];
-      case (reg_a[`PACKET_WIDTH-1:`DATAWIDTH])
-        0: out_d = a_val + reg_b;
-        1: out_d = a_val - reg_b;
-        2: out_d = a_val > reg_b ? a_val : reg_b;
-        3: out_d = a_val > reg_b ? reg_b : a_val;
-        default: out_d = 0;
-      endcase        
-      `onwrite(out_r, out_a)
-        have_a  = 0;
-        have_b  = 0;
-      end
-    end
-  end
-
-
-
-== Test ==============================================================================
-#skip
-#ship debug : Debug
-#expect 0
-0: sendto debug.in;
-
-
-== Contributors =========================================================
-Adam Megacz <megacz@cs.berkeley.edu>
-Amir Kamil  <kamil@cs.berkeley.edu>
index 928ca64..eabc55a 100644 (file)
@@ -352,7 +352,7 @@ public class Fpga extends Fleet {
         try {
             if (sd.getSection("fpga")==null) return;
             String filename = sd.getName().toLowerCase();
-            File outf = new File("src/edu/berkeley/fleet/slipway/"+filename+".v");
+            File outf = new File("build/fpga/"+filename+".v");
             new File(outf.getParent()).mkdirs();
             System.err.println("writing to " + outf);
             FileOutputStream out = new FileOutputStream(outf);
index b9ffe54..025835b 100644 (file)
@@ -11,9 +11,12 @@ import edu.berkeley.sbp.meta.*;
 import edu.berkeley.sbp.util.*;
 import java.util.*;
 import java.io.*;
+import static edu.berkeley.fleet.ies44.InstructionEncoder.*;
 
 public class Generator {
 
+    public static final int WIDTH_PACKET = WIDTH_WORD + WIDTH_DEST_ADDR;
+
     public static class SimpleValue implements Value {
         private final String s;
         public SimpleValue(String s) { this.s = s; }
@@ -396,19 +399,13 @@ public class Generator {
         }
     }
 
-    public static final int WORD_WIDTH = 37;
-    public static final int DESTINATION_WIDTH = 11;
-    public static final int COUNT_WIDTH = 7;
-    public static final int PACKET_WIDTH = WORD_WIDTH + DESTINATION_WIDTH;
-    public static final int INSTRUCTION_WIDTH = WORD_WIDTH;
-
     public static void main(String[] s) throws Exception {
-        String prefix = "src/edu/berkeley/fleet/slipway/";
+        String prefix = s[0];
         PrintWriter pw;
 
         mkfunnel("funnel", prefix);
-        mkhorn(    "horn", prefix, PACKET_WIDTH-1, DESTINATION_WIDTH-1, 0, 0);
-        mkhorn(   "ihorn", prefix, PACKET_WIDTH-1, 34, 24, 0);
+        mkhorn(    "horn", prefix, WIDTH_PACKET-1, WIDTH_DEST_ADDR-1, 0, 0);
+        mkhorn(   "ihorn", prefix, WIDTH_PACKET-1, 34, 24, 0);
 
         Module fifostage = mkfifo("fifostage", 0, null,      prefix);
         Module fifo4     = mkfifo("fifo4",     4, fifostage, prefix);
@@ -419,9 +416,9 @@ public class Generator {
 
     private static Module mkfunnel(String name, String prefix) throws Exception {
         Module funnel = new Module(name);
-        Module.SinkPort    out = funnel.createOutputPort("out", PACKET_WIDTH, "");
-        Module.SourcePort  in1 = funnel.createInputPort("in1", PACKET_WIDTH);
-        Module.SourcePort  in2 = funnel.createInputPort("in2", PACKET_WIDTH);
+        Module.SinkPort    out = funnel.createOutputPort("out", WIDTH_PACKET, "");
+        Module.SourcePort  in1 = funnel.createInputPort("in1", WIDTH_PACKET);
+        Module.SourcePort  in2 = funnel.createInputPort("in2", WIDTH_PACKET);
         funnel.new Event(new Object[] { in1, out },
                          new Action[] { in1, out,
                                         new AssignAction(out, in1) });
@@ -436,8 +433,8 @@ public class Generator {
 
     private static Module mkfifo(String name, int len, Module instance, String prefix) throws Exception {
         Module fifo = new Module(name);
-        Module.SourcePort  in  = fifo.createInputPort("in", PACKET_WIDTH);
-        Module.SinkPort    out = fifo.createOutputPort("out", PACKET_WIDTH, "");
+        Module.SourcePort  in  = fifo.createInputPort("in", WIDTH_PACKET);
+        Module.SinkPort    out = fifo.createOutputPort("out", WIDTH_PACKET, "");
         Module.InstantiatedModule[] stages = new Module.InstantiatedModule[len];
         if (len==0) {
             fifo.new Event(new Object[] { in, out },
@@ -461,9 +458,9 @@ public class Generator {
                               int bot_of_addr_field,
                               int bot) throws Exception {
         Module horn = new Module(name);
-        Module.SourcePort in   = horn.createInputPort("in",    PACKET_WIDTH);
-        Module.SinkPort   out0 = horn.createOutputPort("out0", PACKET_WIDTH, "");
-        Module.SinkPort   out1 = horn.createOutputPort("out1", PACKET_WIDTH, "");
+        Module.SourcePort in   = horn.createInputPort("in",    WIDTH_PACKET);
+        Module.SinkPort   out0 = horn.createOutputPort("out0", WIDTH_PACKET, "");
+        Module.SinkPort   out1 = horn.createOutputPort("out1", WIDTH_PACKET, "");
         String shifted_packet = "{ ";
         if (top_of_addr_field+1 < top) shifted_packet += " in["+top+":"+(top_of_addr_field+1)+"], ";
         shifted_packet += " (in["+(top_of_addr_field)+":"+bot_of_addr_field+"] >> 1) ";
@@ -481,27 +478,27 @@ public class Generator {
 
     private static Module mkBox(String name, boolean inbox, String prefix, Module fifo) throws Exception {
         Module box = new Module(name);
-        Module.SourcePort instr         = box.createInputPort("instr",       INSTRUCTION_WIDTH);
-        Module.SourcePort fabric_in     = box.createInputPort("fabric_in",   PACKET_WIDTH);
-        Module.SinkPort   fabric_out    = box.createOutputPort("fabric_out", PACKET_WIDTH, "");
+        Module.SourcePort instr         = box.createInputPort("instr",       WIDTH_WORD);
+        Module.SourcePort fabric_in     = box.createInputPort("fabric_in",   WIDTH_PACKET);
+        Module.SinkPort   fabric_out    = box.createOutputPort("fabric_out", WIDTH_PACKET, "");
         Module.InstantiatedModule dfifo = box.new InstantiatedModule(fifo);
         fabric_in.connect(dfifo.getInputPort("in"));
         
         Module.SourcePort dfifo_out = dfifo.getOutputPort("out");
         Module.SourcePort   ship_out    = null;
         if (!inbox) {
-            ship_out = box.createInputPort("ship",        WORD_WIDTH);
+            ship_out = box.createInputPort("ship",        WIDTH_WORD);
             ship_out.hasLatch = true;
         }
 
         Module.SinkPort   ship_in     = null;
         if (inbox) {
-            ship_in = box.createOutputPort("ship",        PACKET_WIDTH, "");
+            ship_in = box.createOutputPort("ship",        WIDTH_PACKET, "");
             ship_in.hasLatch = true;
         }
 
-        Module.Latch     ondeck         = box.new Latch("ondeck", INSTRUCTION_WIDTH);
-        Module.Latch     repcount       = box.new Latch("repcount", COUNT_WIDTH);
+        Module.Latch     ondeck         = box.new Latch("ondeck", WIDTH_WORD);
+        Module.Latch     repcount       = box.new Latch("repcount", WIDTH_COUNT);
         Module.StateWire ondeckFull     = box.new StateWire("ondeck_full");
         Module.StateWire newMayProceed  = box.new StateWire("newmayproceed", true);
         Module.StateWire doRepeat       = box.new StateWire("dorepeat", false);
@@ -518,9 +515,9 @@ public class Generator {
         Module.SinkPort   ififo_in      = ififo.getInputPort("in");
         Module.SourcePort ififo_out     = ififo.getOutputPort("out");
 
-        Value instruction_count_ondeck        = ondeck  .getBits(1+DESTINATION_WIDTH+COUNT_WIDTH-1, 1+DESTINATION_WIDTH);
-        Value instruction_count_instr         = instr   .getBits(1+DESTINATION_WIDTH+COUNT_WIDTH-1, 1+DESTINATION_WIDTH);
-        Assignable instruction_count_ififo_in = ififo_in.getAssignableBits(1+DESTINATION_WIDTH+COUNT_WIDTH-1, 1+DESTINATION_WIDTH);
+        Value instruction_count_ondeck        = ondeck  .getBits(1+WIDTH_DEST_ADDR+WIDTH_COUNT-1, 1+WIDTH_DEST_ADDR);
+        Value instruction_count_instr         = instr   .getBits(1+WIDTH_DEST_ADDR+WIDTH_COUNT-1, 1+WIDTH_DEST_ADDR);
+        Assignable instruction_count_ififo_in = ififo_in.getAssignableBits(1+WIDTH_DEST_ADDR+WIDTH_COUNT-1, 1+WIDTH_DEST_ADDR);
 
         // Clog (must be first)
         box.new Event(