IF valid <= max-bytesPerWord
THEN {
There is room to get more words into the buffer
fetchPC: Word ← IntToWord[WordToInt[newPC] + valid];
IF instBuffer.validWords = instBuffer.max
THEN FlushInstWord[];
We have completely filled the inst buffer, but still need more, so shift out the lowest address word, and update the base address and # of bytes valid.
[wordAddr, rbi] ← BytePCToWordAddress[[fetchPC]];
IF rbi # 0 THEN ERROR; -- rats! we blew it!
[word, tx, rCycles] ←
p.ifuCache.fetch[p.ifuCache, wordAddr, initCycles+cycles, p.userMode];
p.stats.lookaheadProbes ← p.stats.lookaheadProbes + 1;
IF rCycles # 0
THEN {
The reject cycles occur in the background, and are not counted towards elapsed cycles. But we do keep track of the next time that the ifu cache will be available.
instBuffer.busyUntil ← p.ifuCache.sharedBase.busyUntil;
p.stats.lookaheadRejects ← p.stats.lookaheadRejects + rCycles;
};
IF tx = NoFault
THEN {
The fetch was successful, so we can put more bytes into the inst buffer. Note that we restrict the max bytes in the buffer to be a multiple of bytesPerWord. There will be no wraparound in the buffer for this word fetch.
instBuffer[instBuffer.validWords] ← word;
instBuffer.validWords ← instBuffer.validWords + 1;
};
tx ← NoFault;
Make sure that the readahead fault does not show up later.
};