add Fleet.getMaxCodeBagSize() and makeCodeBagDescriptor()
authorAdam Megacz <adam@megacz.com>
Sat, 22 Aug 2009 21:27:37 +0000 (14:27 -0700)
committerAdam Megacz <adam@megacz.com>
Sat, 22 Aug 2009 21:27:37 +0000 (14:27 -0700)
src/edu/berkeley/fleet/api/Fleet.java
src/edu/berkeley/fleet/loops/Program.java
src/edu/berkeley/fleet/two/FleetTwoFleet.java

index ce0cfb2..361f5af 100644 (file)
@@ -35,6 +35,12 @@ public abstract class Fleet implements Iterable<Ship> {
 
     /** the width of the immediate field in the "set data latch" instruction */
     public abstract int getSetWidth();
+
+    /** FIXME: this will soon become a property of individual memories rather than the entire Fleet */
+    public abstract int getMaxCodeBagSize();
+
+    /** FIXME: this will soon become a property of individual memories rather than the entire Fleet */
+    public abstract BitVector makeCodeBagDescriptor(long offset, long length);
     
     /**
      *  Encodes an instruction as a BitVector
index 8cd4b01..597549d 100644 (file)
@@ -119,15 +119,14 @@ public class Program {
         // being dispatched than the maximum number that fit in the
         // data fifo at that dock.
 
-        int MAX_BAG_SIZE = (1<<6)-1;
+        int MAX_BAG_SIZE = fleet.getMaxCodeBagSize();
 
         // FUZZ is an estimate of the number of instructions required
         // to dispatch a code bag descriptor
         int FUZZ = 4;
 
         if (instructions.length <= MAX_BAG_SIZE) {
-            BitVector descriptor = new BitVector(fleet.getWordWidth());
-            descriptor.set( (leastUnallocatedAddress<<6) | instructions.length );
+            BitVector descriptor = fleet.makeCodeBagDescriptor(leastUnallocatedAddress, instructions.length);
             leastUnallocatedAddress += instructions.length;
             for(Instruction i : instructions)
                 all_instructions.add(i);
index 7936ad0..7e3ee4f 100644 (file)
@@ -261,6 +261,19 @@ public abstract class FleetTwoFleet extends Fleet {
     public int getShiftWidth() { return SHIFT.valmaskwidth; }
     public int getSetWidth() { return SET_IMMEDIATE.valmaskwidth+1; }
 
+
+    public int getMaxCodeBagSize() {
+        return (1<<CBD_SIZE.valmaskwidth)-1;
+    }
+    public BitVector makeCodeBagDescriptor(long offset, long length) {
+        BitVector descriptor = new BitVector(getWordWidth());
+        CBD_OFFSET.setval(descriptor, offset);
+        CBD_SIZE.setval(descriptor, length);
+        return descriptor;
+    }
+
+
+
     // FIXME: should use BitVector here
     public Instruction readInstruction(long inst, Dock dispatchFrom) {
         Dock dock = getPathByAddr(dispatchFrom, DISPATCH_PATH.getvalAsBitVector(inst)).getDestination().getDock();