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();
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()));
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;
}
}
}