X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ships%2FMemory.ship;h=2d1d6f15dbe6abc7fe5b7e02c51d47ebcdfdf943;hb=ecab47750a7599e2193969961c43992c66d2efeb;hp=65a08b06ac0d351790acbc6ae191ac7e9eb3ae10;hpb=686a997301e70a7c249c4bcae7d3e702e2a27f6f;p=fleet.git diff --git a/ships/Memory.ship b/ships/Memory.ship index 65a08b0..2d1d6f1 100644 --- a/ships/Memory.ship +++ b/ships/Memory.ship @@ -5,8 +5,6 @@ data in: inCBD data in: inAddrRead data in: inAddrWrite data in: inDataWrite -data in: inStride -data in: inCount data out: out @@ -14,7 +12,25 @@ data out: out The {\tt Memory} ship represents an interface to a storage space, which can be used to read from it or write to it. This storage space -might be a fast on-chip cache, off chip DRAM, or perhaps even a disk drive. +might be a fast on-chip cache, off chip DRAM, or perhaps even a disk +drive. + +Generally, distinct {\tt Memory} ships do not access the same backing +storage, although this is not strictly prohibited. + +Each {\tt Memory} ship may have multiple {\it interfaces}, numbered +starting with {\tt 0}. Each interface may have any subset of the +following docks: {\tt inCBD}, {\tt inAddrRead}, {\tt inAddrWrite}, +{\tt inDataWrite}, and {\tt out}. If {\tt inCBD} or {\tt inAddrRead} +is present on an interface, then {\tt out} must be present as well. +If {\tt inAddrWrite} is present then {\tt inDataWrite} must be present +as well. + +Each interface serializes the operations presented to it; this means +that an interface with both read and write capabilities will not be +able to read and write concurrently. Instead, a {\tt Memory} ship +with the ability to read and write concurrently should have two +interfaces, one which is read-only and one which is write-only. There may be multiple {\tt Memory} ships which interface to the same physical storage space. An implementation of Fleet must provide @@ -46,7 +62,8 @@ inCount=size}. \subsection*{Reading} When a word is delivered to {\tt inAddrRead}, the word residing in -memory at that address is provided at {\tt out}. +memory at that address is provided at {\tt out}. The {\tt c-flag} at +the {\tt out} port is set to zero. \subsection*{Writing} @@ -54,7 +71,8 @@ When a word is delivered to {\tt inAddrWrite} and {\tt inDataWrite}, the word at {\tt inDataWrite} is written to the address specified by {\tt inAddrWrite}. Once the word is successfully committed to memory, the value {\tt inAddr+inStride} is provided at {\tt out} (that is, the -address of the next word to be written). +address of the next word to be written). The {\tt c-flag} at +the {\tt out} port is set to one. \subsection*{To Do} @@ -78,7 +96,7 @@ sequence guarantee problem mentioned in the previous paragraph. == Fleeterpreter ==================================================== private long[] mem = new long[0]; - public long readMem(int addr) { return mem[addr]; } + public long readMem(int addr) { return addr >= mem.length ? 0 : mem[addr]; } public void writeMem(int addr, long val) { if (addr >= mem.length) { long[] newmem = new long[addr * 2 + 1]; @@ -87,317 +105,141 @@ sequence guarantee problem mentioned in the previous paragraph. } mem[addr] = val; } - - public void dispatch(int addr, int size) { - for(int i=addr; i> 6); - base = base & ~(0xffffffff << 18); - int size = (int)launch; - size = size & ~(0xffffffff << 6); - dispatch(base, size); + private Queue toDispatch = new LinkedList(); + public void reset() { + super.reset(); + mem = new long[0]; + toDispatch.clear(); } - - private long stride = 0; - private long count = 0; - private long addr = 0; - private boolean writing = false; - public void service() { + if (toDispatch.size() > 0) { + if (!box_out.readyForDataFromShip()) return; + box_out.addDataFromShip(toDispatch.remove()); + } if (box_inCBD.dataReadyForShip()) { long val = box_inCBD.removeDataForShip(); - long addr = val >> 6; - long size = val & 0x3f; - dispatch((int)addr, (int)size); - } - 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 (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; + long addr = ((Interpreter)getFleet()).CBD_OFFSET.getval(val); + long size = ((Interpreter)getFleet()).CBD_SIZE.getval(val); + for(int i=0; i