add stride/count to fleeterpreter Memory ship
authoradam <adam@megacz.com>
Sun, 4 Mar 2007 11:51:48 +0000 (12:51 +0100)
committeradam <adam@megacz.com>
Sun, 4 Mar 2007 11:51:48 +0000 (12:51 +0100)
ships/Memory.ship

index dc266c6..8cb7df9 100644 (file)
@@ -51,6 +51,11 @@ data  out:   out
         dispatch(base, size);
     }
 
+    private long stride = 0;
+    private long count = 0;
+    private long addr = 0;
+    private boolean writing = false;
+
     public void service() {
         if (box_inCBD.dataReadyForShip()) {
             long val = box_inCBD.removeDataForShip();
@@ -58,7 +63,22 @@ data  out:   out
             long size = val & 0x3f;
             dispatch((int)addr, (int)size);
         }
-        if (box_inAddr.dataReadyForShip() && box_out.readyForDataFromShip()) {
+        if (count > 0 && writing) {
+            if (box_inData.dataReadyForShip() && box_out.readyForDataFromShip()) {
+               writeMem((int)addr, box_inData.removeDataForShip());
+               box_out.addDataFromShip(0);
+               count--;
+               addr += stride;
+            }
+
+        } else if (count > 0 && !writing) {
+            if (box_out.readyForDataFromShip()) {
+               box_out.addDataFromShip(readMem((int)addr));
+               count--;
+               addr += stride;
+            }
+
+        } else if (box_inAddr.dataReadyForShip() && box_out.readyForDataFromShip()) {
             Packet packet = box_inAddr.peekPacketForShip();
             if (packet.destination.getDestinationName().equals("read")) {
                 box_out.addDataFromShip(readMem((int)box_inAddr.removeDataForShip()));
@@ -66,6 +86,20 @@ data  out:   out
                 writeMem((int)box_inAddr.removeDataForShip(),
                          box_inData.removeDataForShip());
                 box_out.addDataFromShip(0);
+            } else if (packet.destination.getDestinationName().equals("writeMany")
+                       && box_inStride.dataReadyForShip()
+                       && box_inCount.dataReadyForShip()) {
+                addr = box_inAddr.removeDataForShip();
+                stride = box_inStride.removeDataForShip();
+                count = box_inCount.removeDataForShip();
+                writing = true;
+            } else if (packet.destination.getDestinationName().equals("readMany")
+                       && box_inStride.dataReadyForShip()
+                       && box_inCount.dataReadyForShip()) {
+                addr = box_inAddr.removeDataForShip();
+                stride = box_inStride.removeDataForShip();
+                count = box_inCount.removeDataForShip();
+                writing = false;
             }
         }
     }