Hi all,
I am trying to optimize the throughput of an AHB-lite slave by taking advantage of INCR4, INCR8, INCR8 burst transactions from the master (only issues SINGLE, INCR4/8/16). The slave is running at half of the bus speed but with double the read width so I am trying to perform prefetch by generating the next addresses locally instead of sampling the HADDR on the bus when HREADY is high.
Is this safe?
Only sampling the begin haddr during the non-seq/burst add phase. Insert initial waitstate, self generate subsequent addresses and then internally align the data output such all subsequent data outs are aligned without required additional wait states.
Are there any signals that I should qualify at every cycle (or at least when hready is HIGH) to ensure that the slave response is still valid and related to the transactions of the master? Or it is ok to just go ahead ?
Thanks in advance.
The main thing to check is that HTRANS doesn't signal BUSY cycles in the middle of the defined length burst, as they will stall the burst progression, so will delay when the prefected read data is needed. So check HTRANS sampled on HCLK rising edges when HREADY is high to confirm it follows the expected NONSEQ-SEQ-SEQ-SEQ... sequence for the length of burst expected.
One problem you might face (again HTRANS related) is that Early Burst Termination can still occur, so you might not see the HBURST indicated number of transfers completed. This can happen when you have arbitration logic selecting which of multiple masters in your system is allowed access to your slave (usually implemented in a multi-layer BusMatrix). As this arbitration logic might switch part way through a burst, your slave might see only 5 beats of an INCR8 burst completed before a new master starts accessing the slave.
So nothing wrong with prefetching the read data as you describe, but make sure that you check the HTRANS cycle sequence. BUSY transfers just tell you the read data return needs to be stalled, but an unexpected IDLE or NONSEQ transfer will indicate that early burst termination has occured, and so any prefetched data must be discarded (the original master will still need that data when it is next allowed access, but you might need your read data buffer for the new master's transfer request).
Probably unlikley, but if the memory being accessed is read sensitive (i.e. a FIFO), you can't dump the prefetched read data as it will then be lost forever.
Those would be the main things to check in this design I think.
Hi Colin,
Thanks for the info.
Colin Campbell said:One problem you might face (again HTRANS related) is that Early Burst Termination can still occur, so you might not see the HBURST indicated number of transfers completed. This can happen when you have arbitration logic selecting which of multiple masters in your system is allowed access to your slave (usually implemented in a multi-layer BusMatrix). As this arbitration logic might switch part way through a burst, your slave might see only 5 beats of an INCR8 burst completed before a new master starts accessing the slave.
You do bring up a point of multiple masters on the matrix where by the arbiter may switch to another master that is driving the transactions. In this case how would the HTRANS change for early termination I'm reading Section 3.5.2 in the AMBA AHblite manual regarding this but its doesn't really specify.
Colin Campbell said:So nothing wrong with prefetching the read data as you describe, but make sure that you check the HTRANS cycle sequence. BUSY transfers just tell you the read data return needs to be stalled, but an unexpected IDLE or NONSEQ transfer will indicate that early burst termination has occured, and so any prefetched data must be discarded (the original master will still need that data when it is next allowed access, but you might need your read data buffer for the new master's transfer request).
In section 3.5.1 in the AMBA AHB lite manual, it says that for INCR4, 8, 16 is not allowed to terminate with a BUSY but should only terminate with SEQ. So for for an INCR4 early termination it would look like NONSEQ, BUSY, SEQ, NON-SEQ (new)? Did I get that correct? To me it would seem that we would get at least 2 burst transfers with early termination.
Contrasting with an early termination INCR (undefined burst length) it would be NONSEQ, BUSY, NON-SEQ (new). We would only get one burst transfer. While we are in this topic, what would the usual application of a burst with undefined burst length?
Per your recommendation, we will look into sampling HTRANS every time the HREADY is high to check that the burst is still valid and has not been terminated.
Thanks.
Early burst termination can be detected on HTRANS by observing any time the expected number of data transfers is not completed, and early burst termination can occur after just one transfer in a defined length burst, so you won't always see 2 transfers complete.
3.5.1 is talking about bursts ending (terminating) after a BUSY transfer. This is "normal" burst terminating, not "early" burst termination. So with a defined length burst (INCR4, WRAP8, etc) you know how many SEQ transfers will follow the starting NONSEQ transfer.
There might be BUSY transfers in between some of the NONSEQ/SEQ transfers, but the burst will end with a SEQ transfer because that SEQ transfer will be the 4th data transfer in a 4-beat burst, or the 8th transfer in an 8-beat burst. You cannot have the burst continue for a further BUSY transfer because the burst ended as soon as the 4th/8th/16th transfer occured (and you cannot have a BUSY outside of a burst)
3.5.2 is talking about "early" burst termination, where the defined length burst does not complete that defined number of transfers. So then you could see the burst end on a BUSY transfer if that was what the master was signalling when the "early" termination occured.
Equally you could see the defined length burst end "early" on a SEQ transfer, but maybe the 1st or 2nd SEQ in an INCR4 burst instead of after the 3rd SEQ.
So if you were looking at an INCR4 burst, it will be expected to complete 1 NONSEQ transfer, and 3 SEQ transfers, possibly with BUSY transfers in between some NONSEQ/SEQ transfers, i.e.
NONSEQ-(BUSY)-SEQ-(BUSY)-SEQ-(BUSY)-SEQ
The BUSY transfers are shown in brackets because they might not be seen, and could also be multiple BUSY transfers between the NONSEQ/SEQ transfers.
And so any "early" burst termination is a sequence which doesn't follow that pattern, so a NONSEQ or IDLE transfer occuring when a SEQ or BUSY was expected.
Undefined length bursts (INCR) by their very definition have no defined length, so can end at any time. There is no such thing as "early" burst termination for undefined length bursts, all you have is "normal" burst termination, detected by HTRANS signaling a NONSEQ or IDLE transfer.
Thanks for clarifying Colin, appreciate it.