long size = val & 0x3f;
dispatch((int)addr, (int)size);
}
- if (count > 0 && writing) {
- if (box_inDataWrite.dataReadyForShip() && box_out.readyForDataFromShip()) {
- writeMem((int)addr, box_inDataWrite.removeDataForShip());
- box_out.addDataFromShip(0);
- count--;
- addr += stride;
+ if (count > 0) {
+ if (writing) {
+ if (box_inDataWrite.dataReadyForShip() && box_out.readyForDataFromShip()) {
+ writeMem((int)addr, box_inDataWrite.removeDataForShip());
+ box_out.addDataFromShip(0);
+ count--;
+ addr += stride;
+ }
+ } else {
+ if (box_out.readyForDataFromShip()) {
+ box_out.addDataFromShip(readMem((int)addr));
+ count--;
+ addr += stride;
+ }
}
- } else if (count > 0 && !writing) {
- if (box_out.readyForDataFromShip()) {
- box_out.addDataFromShip(readMem((int)addr));
- count--;
- addr += stride;
- }
-
- } else if (box_inAddrRead.dataReadyForShip() && box_out.readyForDataFromShip()) {
- Packet packet = box_inAddrRead.peekPacketForShip();
- if (packet.destination.getDestinationName().equals("read")) {
- box_out.addDataFromShip(readMem((int)box_inAddrRead.removeDataForShip()));
- } else if (packet.destination.getDestinationName().equals("write") && box_inDataWrite.dataReadyForShip()) {
- writeMem((int)box_inAddrRead.removeDataForShip(),
- box_inDataWrite.removeDataForShip());
- box_out.addDataFromShip(0);
- } else if (packet.destination.getDestinationName().equals("writeMany")
- && box_inStride.dataReadyForShip()
- && box_inCount.dataReadyForShip()) {
- addr = box_inAddrRead.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_inAddrRead.removeDataForShip();
- stride = box_inStride.removeDataForShip();
- count = box_inCount.removeDataForShip();
- writing = false;
- }
+ } else if (box_inAddrRead.dataReadyForShip()) {
+ addr = box_inAddrRead.removeDataForShip();
+ stride = 0;
+ count = 1;
+ writing = false;
+
+ } else if (box_inAddrWrite.dataReadyForShip()) {
+ addr = box_inAddrWrite.peekPacketForShip().value;
+ box_inAddrWrite.removeDataForShip();
+ stride = 0;
+ count = 1;
+ writing = true;
}
}